257b29715b
Summary: This is the first patch implementing the new Flang driver as outlined in [1], [2] & [3]. It creates Flang driver (`flang-new`) and Flang frontend driver (`flang-new -fc1`). These will be renamed as `flang` and `flang -fc1` once the current Flang throwaway driver, `flang`, can be replaced with `flang-new`. Currently only 2 options are supported: `-help` and `--version`. `flang-new` is implemented in terms of libclangDriver, defaulting the driver mode to `FlangMode` (added to libclangDriver in [4]). This ensures that the driver runs in Flang mode regardless of the name of the binary inferred from argv[0]. The design of the new Flang compiler and frontend drivers is inspired by it counterparts in Clang [3]. Currently, the new Flang compiler and frontend drivers re-use Clang libraries: clangBasic, clangDriver and clangFrontend. To identify Flang options, this patch adds FlangOption/FC1Option enums. Driver::printHelp is updated so that `flang-new` prints only Flang options. The new Flang driver is disabled by default. To enable it, set `-DBUILD_FLANG_NEW_DRIVER=ON` when configuring CMake and add clang to `LLVM_ENABLE_PROJECTS` (e.g. -DLLVM_ENABLE_PROJECTS=“clang;flang;mlir”). [1] “RFC: new Flang driver - next steps” http://lists.llvm.org/pipermail/flang-dev/2020-July/000470.html [2] “RFC: Adding a fortran mode to the clang driver for flang” http://lists.llvm.org/pipermail/cfe-dev/2019-June/062669.html [3] “RFC: refactoring libclangDriver/libclangFrontend to share with Flang” http://lists.llvm.org/pipermail/cfe-dev/2020-July/066393.html [4] https://reviews.llvm.org/rG6bf55804924d5a1d902925ad080b1a2b57c5c75c co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com> Reviewed By: richard.barton.arm, sameeranjoshi Differential Revision: https://reviews.llvm.org/D86089
73 lines
1.9 KiB
CMake
73 lines
1.9 KiB
CMake
# Test runner infrastructure for Flang. This configures the Flang test trees
|
|
# for use by Lit, and delegates to LLVM's lit test handlers.
|
|
|
|
llvm_canonicalize_cmake_booleans(
|
|
FLANG_STANDALONE_BUILD
|
|
)
|
|
|
|
set(FLANG_INTRINSIC_MODULES_DIR ${FLANG_BINARY_DIR}/include/flang)
|
|
|
|
set(FLANG_TOOLS_DIR ${FLANG_BINARY_DIR}/bin)
|
|
|
|
configure_lit_site_cfg(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
|
|
MAIN_CONFIG
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
|
|
)
|
|
|
|
configure_lit_site_cfg(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
|
|
MAIN_CONFIG
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
|
|
)
|
|
|
|
configure_lit_site_cfg(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/NonGtestUnit/lit.site.cfg.py.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/NonGtestUnit/lit.site.cfg.py
|
|
MAIN_CONFIG
|
|
${CMAKE_CURRENT_SOURCE_DIR}/NonGtestUnit/lit.cfg.py
|
|
)
|
|
|
|
set(FLANG_TEST_PARAMS
|
|
flang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)
|
|
|
|
set(FLANG_TEST_DEPENDS
|
|
f18 FileCheck count not module_files
|
|
)
|
|
|
|
if (LINK_WITH_FIR)
|
|
list(APPEND FLANG_TEST_DEPENDS tco)
|
|
endif()
|
|
|
|
if (FLANG_BUILD_NEW_DRIVER)
|
|
list(APPEND FLANG_TEST_DEPENDS flang-new)
|
|
endif()
|
|
|
|
if (FLANG_INCLUDE_TESTS)
|
|
if (FLANG_GTEST_AVAIL)
|
|
list(APPEND FLANG_TEST_DEPENDS FlangUnitTests)
|
|
endif()
|
|
endif()
|
|
|
|
add_custom_target(flang-test-depends DEPENDS ${FLANG_TEST_DEPENDS})
|
|
|
|
add_lit_testsuite(check-flang "Running the Flang regression tests"
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
PARAMS ${FLANG_TEST_PARAMS}
|
|
DEPENDS ${FLANG_TEST_DEPENDS}
|
|
)
|
|
set_target_properties(check-flang PROPERTIES FOLDER "Tests")
|
|
|
|
# In case of standalone builds.
|
|
if (FLANG_STANDALONE_BUILD)
|
|
add_lit_testsuites(FLANG ${CMAKE_CURRENT_BINARY_DIR}
|
|
PARAMS ${FLANG_TEST_PARAMS}
|
|
DEPENDS ${FLANG_TEST_DEPENDS})
|
|
else()
|
|
add_lit_testsuites(FLANG ${CMAKE_CURRENT_SOURCE_DIR}
|
|
PARAMS ${FLANG_TEST_PARAMS}
|
|
DEPENDS ${FLANG_TEST_DEPENDS})
|
|
endif()
|