diff --git a/clang/lib/Support/CMakeLists.txt b/clang/lib/Support/CMakeLists.txt --- a/clang/lib/Support/CMakeLists.txt +++ b/clang/lib/Support/CMakeLists.txt @@ -9,24 +9,7 @@ Support ) -set(clangSupport_sources - RISCVVIntrinsicUtils.cpp - ) - -add_clang_library(clangSupport ${clangSupport_sources}) - -if (NOT XCODE) - add_library(clangSupport_tablegen ALIAS obj.clangSupport) -elseif (NOT LLVM_LINK_LLVM_DYLIB) - add_library(clangSupport_tablegen ALIAS clangSupport) -else() - # Build a version of the support library that does not link against - # libLLVM-*.so, to be used by clang-tblgen. This is so clang-tblgen doesn't - # link against libLLVMSupport twice (once statically and once via - # libLLVM-*.so). - add_llvm_library(clangSupport_tablegen - BUILDTREE_ONLY STATIC DISABLE_LLVM_LINK_LLVM_DYLIB - ${clangSupport_sources}) -endif() +add_clang_library(clangSupport + RISCVVIntrinsicUtils.cpp) set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS_OLD}) diff --git a/clang/utils/TableGen/CMakeLists.txt b/clang/utils/TableGen/CMakeLists.txt --- a/clang/utils/TableGen/CMakeLists.txt +++ b/clang/utils/TableGen/CMakeLists.txt @@ -25,6 +25,6 @@ TableGen.cpp ) -target_link_libraries(clang-tblgen PRIVATE clangSupport_tablegen) +target_link_libraries(clang-tblgen PRIVATE clangSupport) set_target_properties(clang-tblgen PROPERTIES FOLDER "Clang tablegenning") diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake --- a/llvm/cmake/modules/CrossCompile.cmake +++ b/llvm/cmake/modules/CrossCompile.cmake @@ -96,7 +96,7 @@ endfunction() # Sets up a native build for a tool, used e.g. for cross-compilation and -# LLVM_OPTIMIZED_TABLEGEN. Always builds in Release. +# LLVM_OPTIMIZED_TABLEGEN. Always builds in Release and with static linking. # - target: The target to build natively # - output_path_var: A variable name which receives the path to the built target # - DEPENDS: Any additional dependencies for the target diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake --- a/llvm/cmake/modules/TableGen.cmake +++ b/llvm/cmake/modules/TableGen.cmake @@ -141,7 +141,7 @@ endfunction() macro(add_tablegen target project) - cmake_parse_arguments(ADD_TABLEGEN "" "DESTINATION;EXPORT" "" ${ARGN}) + cmake_parse_arguments(ADD_TABLEGEN "DISABLE_LLVM_LINK_LLVM_DYLIB" "DESTINATION;EXPORT" "" ${ARGN}) set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS}) set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen) @@ -152,10 +152,17 @@ set(LLVM_ENABLE_OBJLIB ON) endif() - add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB + set(add_executable_dylib_opt "") + if(ADD_TABLEGEN_DISABLE_LLVM_LINK_LLVM_DYLIB) + set(add_executable_dylib_opt "DISABLE_LLVM_LINK_LLVM_DYLIB") + endif() + + add_llvm_executable(${target} ${add_executable_dylib_opt} ${ADD_TABLEGEN_UNPARSED_ARGUMENTS}) set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) + unset(add_executable_dylib_opt) + set(${project}_TABLEGEN "${target}" CACHE STRING "Native TableGen executable. Saves building one when cross-compiling.") diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt --- a/llvm/utils/TableGen/CMakeLists.txt +++ b/llvm/utils/TableGen/CMakeLists.txt @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS Support) add_tablegen(llvm-tblgen LLVM + DISABLE_LLVM_LINK_LLVM_DYLIB DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" EXPORT LLVM AsmMatcherEmitter.cpp diff --git a/mlir/lib/Support/CMakeLists.txt b/mlir/lib/Support/CMakeLists.txt --- a/mlir/lib/Support/CMakeLists.txt +++ b/mlir/lib/Support/CMakeLists.txt @@ -30,8 +30,6 @@ add_llvm_library(MLIRSupportIndentedOstream IndentedOstream.cpp - DISABLE_LLVM_LINK_LLVM_DYLIB - LINK_COMPONENTS Support ) diff --git a/mlir/lib/TableGen/CMakeLists.txt b/mlir/lib/TableGen/CMakeLists.txt --- a/mlir/lib/TableGen/CMakeLists.txt +++ b/mlir/lib/TableGen/CMakeLists.txt @@ -1,14 +1,5 @@ -# This library is unusual, since mlir-tblgen depends on it, which is -# built with DISABLE_LLVM_LINK_LLVM_DYLIB, this must also be built -# with that option. Otherwise builds with LLVM_BUILD_LLVM_DYLIB and -# LLVM_LINK_LLVM_DYLIB fail. (Note that even if this has no llvm -# component dependencies, LLVM_LINK_LLVM_DYLIB tends to introduce a -# dependence on libLLVM.so) However, it must also be linkable against -# libMLIR.so in some contexts (see unittests/Tablegen, for instance, which -# has a dependence on MLIRIR, which must depend on libLLVM.so). This works -# in this special case because this library is static. -llvm_add_library(MLIRTableGen STATIC +llvm_add_library(MLIRTableGen Argument.cpp Attribute.cpp AttrOrTypeDef.cpp @@ -30,8 +21,6 @@ Trait.cpp Type.cpp - DISABLE_LLVM_LINK_LLVM_DYLIB - ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/TableGen ) diff --git a/mlir/lib/Tools/PDLL/Parser/CMakeLists.txt b/mlir/lib/Tools/PDLL/Parser/CMakeLists.txt --- a/mlir/lib/Tools/PDLL/Parser/CMakeLists.txt +++ b/mlir/lib/Tools/PDLL/Parser/CMakeLists.txt @@ -4,8 +4,6 @@ Lexer.cpp Parser.cpp - DISABLE_LLVM_LINK_LLVM_DYLIB - LINK_COMPONENTS Support TableGen diff --git a/mlir/lib/Tools/mlir-tblgen/CMakeLists.txt b/mlir/lib/Tools/mlir-tblgen/CMakeLists.txt --- a/mlir/lib/Tools/mlir-tblgen/CMakeLists.txt +++ b/mlir/lib/Tools/mlir-tblgen/CMakeLists.txt @@ -4,8 +4,6 @@ ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Tools/mlir-tblgen - DISABLE_LLVM_LINK_LLVM_DYLIB - LINK_COMPONENTS TableGen diff --git a/mlir/lib/Tools/tblgen-lsp-server/CMakeLists.txt b/mlir/lib/Tools/tblgen-lsp-server/CMakeLists.txt --- a/mlir/lib/Tools/tblgen-lsp-server/CMakeLists.txt +++ b/mlir/lib/Tools/tblgen-lsp-server/CMakeLists.txt @@ -12,8 +12,6 @@ ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Tools/tblgen-lsp-server - DISABLE_LLVM_LINK_LLVM_DYLIB - LINK_LIBS PUBLIC MLIRLspServerSupportLib MLIRSupport