[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
This commit is contained in:
Serge Guelton 2020-10-05 15:35:38 -04:00 committed by serge-sans-paille
parent 82a71822a5
commit cde06f783c
7 changed files with 41 additions and 41 deletions

View File

@ -229,9 +229,8 @@ if(LINK_WITH_FIR)
endif() endif()
# Always build tco tool # Always build tco tool
set(LLVM_BUILD_TOOLS ON) set(LLVM_BUILD_TOOLS ON)
message(STATUS "Linking driver with FIR and LLVM") set(LLVM_COMMON_COMPONENTS Support)
llvm_map_components_to_libnames(LLVM_COMMON_LIBS support) message(STATUS "Linking driver with FIR and LLVM, using LLVM components: ${LLVM_COMMON_COMPONENTS}")
message(STATUS "LLVM libraries: ${LLVM_COMMON_LIBS}")
endif() endif()
# Add Flang-centric modules to cmake path. # Add Flang-centric modules to cmake path.

View File

@ -61,7 +61,6 @@ macro(add_flang_library name)
llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs}) llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
if (TARGET ${name}) if (TARGET ${name})
target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libflang") if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libflang")
set(export_to_flangtargets) set(export_to_flangtargets)

View File

@ -7,20 +7,23 @@ link_directories(${LLVM_LIBRARY_DIR})
add_flang_tool(flang-new add_flang_tool(flang-new
driver.cpp driver.cpp
fc1_main.cpp fc1_main.cpp
LINK_COMPONENTS
${LLVM_COMMON_COMPONENTS}
Support
Target
Option
) )
# Link against LLVM and Clang libraries # Link against LLVM and Clang libraries
target_link_libraries(flang-new target_link_libraries(flang-new
PRIVATE PRIVATE
${LLVM_COMMON_LIBS}
flangFrontend flangFrontend
flangFrontendTool flangFrontendTool
clangDriver clangDriver
clangBasic clangBasic
clangFrontend clangFrontend
LLVMSupport
LLVMTarget
LLVMOption
) )
install(TARGETS flang-new DESTINATION bin) install(TARGETS flang-new DESTINATION bin)

View File

@ -10,11 +10,30 @@ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
endif() endif()
function(add_flang_nongtest_unittest test_name) 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() endfunction()
add_subdirectory(Optimizer) add_subdirectory(Optimizer)

View File

@ -1,15 +1,10 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_flang_nongtest_unittest(quick-sanity-test add_flang_nongtest_unittest(quick-sanity-test
FortranDecimal FortranDecimal
LLVMSupport
) )
# This test is not run by default as it takes a long time to execute # This test is not run by default as it takes a long time to execute.
add_executable(thorough-test add_flang_nongtest_unittest(thorough-test
thorough-test.cpp SLOW_TEST
)
target_link_libraries(thorough-test
FortranDecimal FortranDecimal
LLVMSupport
) )

View File

@ -3,24 +3,24 @@ add_library(FortranEvaluateTesting
testing.cpp testing.cpp
fp-testing.cpp fp-testing.cpp
) )
if (LLVM_LINK_LLVM_DYLIB)
target_link_libraries(FortranEvaluateTesting set(llvm_libs LLVM)
LLVMSupport else()
) llvm_map_components_to_libnames(llvm_libs Support)
endif()
target_link_libraries(FortranEvaluateTesting
${llvm_libs})
add_flang_nongtest_unittest(leading-zero-bit-count add_flang_nongtest_unittest(leading-zero-bit-count
FortranEvaluateTesting FortranEvaluateTesting
LLVMSupport
) )
add_flang_nongtest_unittest(bit-population-count add_flang_nongtest_unittest(bit-population-count
FortranEvaluateTesting FortranEvaluateTesting
LLVMSupport
) )
add_flang_nongtest_unittest(uint128 add_flang_nongtest_unittest(uint128
FortranEvaluateTesting FortranEvaluateTesting
LLVMSupport
) )
add_flang_nongtest_unittest(expression add_flang_nongtest_unittest(expression
@ -29,14 +29,12 @@ add_flang_nongtest_unittest(expression
FortranEvaluate FortranEvaluate
FortranSemantics FortranSemantics
FortranParser FortranParser
LLVMSupport
) )
add_flang_nongtest_unittest(integer add_flang_nongtest_unittest(integer
FortranEvaluateTesting FortranEvaluateTesting
FortranEvaluate FortranEvaluate
FortranSemantics FortranSemantics
LLVMSupport
) )
add_flang_nongtest_unittest(intrinsics add_flang_nongtest_unittest(intrinsics
@ -47,14 +45,12 @@ add_flang_nongtest_unittest(intrinsics
FortranSemantics FortranSemantics
FortranParser FortranParser
FortranRuntime FortranRuntime
LLVMSupport
) )
add_flang_nongtest_unittest(logical add_flang_nongtest_unittest(logical
FortranEvaluateTesting FortranEvaluateTesting
FortranEvaluate FortranEvaluate
FortranSemantics FortranSemantics
LLVMSupport
) )
# GCC -fno-exceptions breaks the fenv.h interfaces needed to capture # GCC -fno-exceptions breaks the fenv.h interfaces needed to capture
@ -68,7 +64,6 @@ add_flang_nongtest_unittest(real
FortranEvaluate FortranEvaluate
FortranDecimal FortranDecimal
FortranSemantics FortranSemantics
LLVMSupport
) )
llvm_update_compile_flags(real.test) llvm_update_compile_flags(real.test)
@ -77,7 +72,6 @@ add_flang_nongtest_unittest(reshape
FortranSemantics FortranSemantics
FortranEvaluate FortranEvaluate
FortranRuntime FortranRuntime
LLVMSupport
) )
add_flang_nongtest_unittest(ISO-Fortran-binding add_flang_nongtest_unittest(ISO-Fortran-binding
@ -85,7 +79,6 @@ add_flang_nongtest_unittest(ISO-Fortran-binding
FortranEvaluate FortranEvaluate
FortranSemantics FortranSemantics
FortranRuntime FortranRuntime
LLVMSupport
) )
add_flang_nongtest_unittest(folding add_flang_nongtest_unittest(folding
@ -93,5 +86,4 @@ add_flang_nongtest_unittest(folding
FortranEvaluateTesting FortranEvaluateTesting
FortranEvaluate FortranEvaluate
FortranSemantics FortranSemantics
LLVMSupport
) )

View File

@ -10,19 +10,16 @@ llvm_update_compile_flags(RuntimeTesting)
target_link_libraries(RuntimeTesting target_link_libraries(RuntimeTesting
FortranRuntime FortranRuntime
LLVMSupport
) )
add_flang_nongtest_unittest(format add_flang_nongtest_unittest(format
RuntimeTesting RuntimeTesting
FortranRuntime FortranRuntime
LLVMSupport
) )
add_flang_nongtest_unittest(hello add_flang_nongtest_unittest(hello
RuntimeTesting RuntimeTesting
FortranRuntime FortranRuntime
LLVMSupport
) )
# This test is not run by default as it requires input. # 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 target_link_libraries(external-hello-world
FortranRuntime FortranRuntime
LLVMSupport
) )
add_flang_nongtest_unittest(external-io add_flang_nongtest_unittest(external-io
RuntimeTesting RuntimeTesting
FortranRuntime FortranRuntime
LLVMSupport
) )
add_flang_nongtest_unittest(list-input add_flang_nongtest_unittest(list-input
RuntimeTesting RuntimeTesting
FortranRuntime FortranRuntime
LLVMSupport
) )
add_flang_nongtest_unittest(character add_flang_nongtest_unittest(character
RuntimeTesting RuntimeTesting
FortranRuntime FortranRuntime
LLVMSupport
) )