[flang-commits] [flang] cde06f7 - [flang] Make flang build compatible with LLVM dylib
via flang-commits
flang-commits at lists.llvm.org
Wed Oct 14 05:27:41 PDT 2020
Author: Serge Guelton
Date: 2020-10-14T14:27:25+02:00
New Revision: cde06f783ce9811ed5e6d4c9a4e803b76842eccc
URL: https://github.com/llvm/llvm-project/commit/cde06f783ce9811ed5e6d4c9a4e803b76842eccc
DIFF: https://github.com/llvm/llvm-project/commit/cde06f783ce9811ed5e6d4c9a4e803b76842eccc.diff
LOG: [flang] Make flang build compatible with LLVM dylib
Harmonize usage of LLVM components througout Flang.
Explicit LLVM Libs where used across several CMakeFIles, which led to
incompatibilities with LLVM shlibs.
Fortunately, the LLVM component system can be relied on to harmoniously handle
both cases.
Differential Revision: https://reviews.llvm.org/D87893
Added:
Modified:
flang/CMakeLists.txt
flang/cmake/modules/AddFlang.cmake
flang/tools/flang-driver/CMakeLists.txt
flang/unittests/CMakeLists.txt
flang/unittests/Decimal/CMakeLists.txt
flang/unittests/Evaluate/CMakeLists.txt
flang/unittests/Runtime/CMakeLists.txt
Removed:
################################################################################
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index ceba69c55dfb6..2e6c5f1bd2973 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -229,9 +229,8 @@ if(LINK_WITH_FIR)
endif()
# Always build tco tool
set(LLVM_BUILD_TOOLS ON)
- message(STATUS "Linking driver with FIR and LLVM")
- llvm_map_components_to_libnames(LLVM_COMMON_LIBS support)
- message(STATUS "LLVM libraries: ${LLVM_COMMON_LIBS}")
+ set(LLVM_COMMON_COMPONENTS Support)
+ message(STATUS "Linking driver with FIR and LLVM, using LLVM components: ${LLVM_COMMON_COMPONENTS}")
endif()
# Add Flang-centric modules to cmake path.
diff --git a/flang/cmake/modules/AddFlang.cmake b/flang/cmake/modules/AddFlang.cmake
index 7fe8b7e9f4062..ba36a234babff 100644
--- a/flang/cmake/modules/AddFlang.cmake
+++ b/flang/cmake/modules/AddFlang.cmake
@@ -61,7 +61,6 @@ macro(add_flang_library name)
llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
if (TARGET ${name})
- target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libflang")
set(export_to_flangtargets)
diff --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt
index 5e34a33b8d998..d4bbe2339fde6 100644
--- a/flang/tools/flang-driver/CMakeLists.txt
+++ b/flang/tools/flang-driver/CMakeLists.txt
@@ -7,20 +7,23 @@ link_directories(${LLVM_LIBRARY_DIR})
add_flang_tool(flang-new
driver.cpp
fc1_main.cpp
+
+ LINK_COMPONENTS
+
+ ${LLVM_COMMON_COMPONENTS}
+ Support
+ Target
+ Option
)
# Link against LLVM and Clang libraries
target_link_libraries(flang-new
PRIVATE
- ${LLVM_COMMON_LIBS}
flangFrontend
flangFrontendTool
clangDriver
clangBasic
clangFrontend
- LLVMSupport
- LLVMTarget
- LLVMOption
)
install(TARGETS flang-new DESTINATION bin)
diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index 9f068fb30ffad..54af3aff21d62 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -10,11 +10,30 @@ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
endif()
function(add_flang_nongtest_unittest test_name)
- add_executable(${test_name}.test ${test_name}.cpp)
+ cmake_parse_arguments(ARG
+ "SLOW_TEST"
+ ""
+ ""
+ ${ARGN})
- target_link_libraries(${test_name}.test ${ARGN})
+ if(ARG_SLOW_TEST)
+ set(suffix .slow)
+ else()
+ set(suffix .test)
+ endif()
- add_dependencies(FlangUnitTests ${test_name}.test)
+ add_executable(${test_name}${suffix} ${test_name}.cpp)
+
+ if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
+ set(llvm_libs LLVM)
+ else()
+ llvm_map_components_to_libnames(llvm_libs Support)
+ endif()
+ target_link_libraries(${test_name}${suffix} ${llvm_libs} ${ARG_UNPARSED_ARGUMENTS})
+
+ if(NOT ARG_SLOW_TEST)
+ add_dependencies(FlangUnitTests ${test_name}${suffix})
+ endif()
endfunction()
add_subdirectory(Optimizer)
diff --git a/flang/unittests/Decimal/CMakeLists.txt b/flang/unittests/Decimal/CMakeLists.txt
index 112b02f9029f9..d301a9d3628c5 100644
--- a/flang/unittests/Decimal/CMakeLists.txt
+++ b/flang/unittests/Decimal/CMakeLists.txt
@@ -1,15 +1,10 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_flang_nongtest_unittest(quick-sanity-test
FortranDecimal
- LLVMSupport
)
-# This test is not run by default as it takes a long time to execute
-add_executable(thorough-test
- thorough-test.cpp
-)
-
-target_link_libraries(thorough-test
+# This test is not run by default as it takes a long time to execute.
+add_flang_nongtest_unittest(thorough-test
+ SLOW_TEST
FortranDecimal
- LLVMSupport
)
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index c56789b598ce7..f9e522727ae40 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -3,24 +3,24 @@ add_library(FortranEvaluateTesting
testing.cpp
fp-testing.cpp
)
-
-target_link_libraries(FortranEvaluateTesting
- LLVMSupport
-)
+ if (LLVM_LINK_LLVM_DYLIB)
+ set(llvm_libs LLVM)
+ else()
+ llvm_map_components_to_libnames(llvm_libs Support)
+ endif()
+ target_link_libraries(FortranEvaluateTesting
+ ${llvm_libs})
add_flang_nongtest_unittest(leading-zero-bit-count
FortranEvaluateTesting
- LLVMSupport
)
add_flang_nongtest_unittest(bit-population-count
FortranEvaluateTesting
- LLVMSupport
)
add_flang_nongtest_unittest(uint128
FortranEvaluateTesting
- LLVMSupport
)
add_flang_nongtest_unittest(expression
@@ -29,14 +29,12 @@ add_flang_nongtest_unittest(expression
FortranEvaluate
FortranSemantics
FortranParser
- LLVMSupport
)
add_flang_nongtest_unittest(integer
FortranEvaluateTesting
FortranEvaluate
FortranSemantics
- LLVMSupport
)
add_flang_nongtest_unittest(intrinsics
@@ -47,14 +45,12 @@ add_flang_nongtest_unittest(intrinsics
FortranSemantics
FortranParser
FortranRuntime
- LLVMSupport
)
add_flang_nongtest_unittest(logical
FortranEvaluateTesting
FortranEvaluate
FortranSemantics
- LLVMSupport
)
# GCC -fno-exceptions breaks the fenv.h interfaces needed to capture
@@ -68,7 +64,6 @@ add_flang_nongtest_unittest(real
FortranEvaluate
FortranDecimal
FortranSemantics
- LLVMSupport
)
llvm_update_compile_flags(real.test)
@@ -77,7 +72,6 @@ add_flang_nongtest_unittest(reshape
FortranSemantics
FortranEvaluate
FortranRuntime
- LLVMSupport
)
add_flang_nongtest_unittest(ISO-Fortran-binding
@@ -85,7 +79,6 @@ add_flang_nongtest_unittest(ISO-Fortran-binding
FortranEvaluate
FortranSemantics
FortranRuntime
- LLVMSupport
)
add_flang_nongtest_unittest(folding
@@ -93,5 +86,4 @@ add_flang_nongtest_unittest(folding
FortranEvaluateTesting
FortranEvaluate
FortranSemantics
- LLVMSupport
)
diff --git a/flang/unittests/Runtime/CMakeLists.txt b/flang/unittests/Runtime/CMakeLists.txt
index 041b631f59d6b..45dc65bd0feff 100644
--- a/flang/unittests/Runtime/CMakeLists.txt
+++ b/flang/unittests/Runtime/CMakeLists.txt
@@ -10,19 +10,16 @@ llvm_update_compile_flags(RuntimeTesting)
target_link_libraries(RuntimeTesting
FortranRuntime
- LLVMSupport
)
add_flang_nongtest_unittest(format
RuntimeTesting
FortranRuntime
- LLVMSupport
)
add_flang_nongtest_unittest(hello
RuntimeTesting
FortranRuntime
- LLVMSupport
)
# This test is not run by default as it requires input.
@@ -32,23 +29,19 @@ add_executable(external-hello-world
target_link_libraries(external-hello-world
FortranRuntime
- LLVMSupport
)
add_flang_nongtest_unittest(external-io
RuntimeTesting
FortranRuntime
- LLVMSupport
)
add_flang_nongtest_unittest(list-input
RuntimeTesting
FortranRuntime
- LLVMSupport
)
add_flang_nongtest_unittest(character
RuntimeTesting
FortranRuntime
- LLVMSupport
)
More information about the flang-commits
mailing list