[clang] 1e03c37 - Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all
Author: John Ericson Date: 2021-07-13T15:21:41Z New Revision: 1e03c37b97b6176a60404d84665c40321f4e33a4 URL: https://github.com/llvm/llvm-project/commit/1e03c37b97b6176a60404d84665c40321f4e33a4 DIFF: https://github.com/llvm/llvm-project/commit/1e03c37b97b6176a60404d84665c40321f4e33a4.diff LOG: Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all This is a second attempt at D101497, which landed as 9a9bc76c0eb72f0f2732c729a460abbd5239c2e3 but had to be reverted in 8cf7ddbdd4e5af966a369e170c73250f2e3920e7. This issue was that in the case that `COMPILER_RT_INSTALL_PATH` is empty, expressions like "${COMPILER_RT_INSTALL_PATH}/bin" evaluated to "/bin" not "bin" as intended and as was originally. One solution is to make `COMPILER_RT_INSTALL_PATH` always non-empty, defaulting it to `CMAKE_INSTALL_PREFIX`. D99636 adopted that approach. But, I think it is more ergonomic to allow those project-specific paths to be relative the global ones. Also, making install paths absolute by default inhibits the proper behavior of functions like `GNUInstallDirs_get_absolute_install_dir` which make relative install paths absolute in a more complicated way. Given all this, I will define a function like the one asked for in https://gitlab.kitware.com/cmake/cmake/-/issues/19568 (and needed for a similar use-case). --- Original message: Instead of using `COMPILER_RT_INSTALL_PATH` through the CMake for complier-rt, just use it to define variables for the subdirs which themselves are used. This preserves compatibility, but later on we might consider getting rid of `COMPILER_RT_INSTALL_PATH` and just changing the defaults for the subdir variables directly. --- There was a seaming bug where the (non-Apple) per-target libdir was `${target}` not `lib/${target}`. I suspect that has to do with the docs on `COMPILER_RT_INSTALL_PATH` saying was the library dir when that's no longer true, so I just went ahead and fixed it, allowing me to define fewer and more sensible variables. That last part should be the only behavior changes; everything else should be a pure refactoring. --- I added some documentation of these variables too. In particular, I wanted to highlight the gotcha where `-DSomeCachePath=...` without the `:PATH` will lead CMake to make the path absolute. See [1] for discussion of the problem, and [2] for the brief official documentation they added as a result. [1]: https://cmake.org/pipermail/cmake/2015-March/060204.html [2]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#options In 38b2dec37ee735d5409148e71ecba278caf0f969 the problem was somewhat misidentified and so `:STRING` was used, but `:PATH` is better as it sets the correct type from the get-go. --- D99484 is the main thrust of the `GnuInstallDirs` work. Once this lands, it should be feasible to follow both of these up with a simple patch for compiler-rt analogous to the one for libcxx. Reviewed By: phosek, #libc_abi, #libunwind Differential Revision: https://reviews.llvm.org/D105765 Added: compiler-rt/docs/BuildingCompilerRT.rst Modified: clang/runtime/CMakeLists.txt compiler-rt/cmake/Modules/AddCompilerRT.cmake compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake compiler-rt/cmake/Modules/CompilerRTUtils.cmake compiler-rt/cmake/base-config-ix.cmake compiler-rt/include/CMakeLists.txt compiler-rt/lib/dfsan/CMakeLists.txt libcxx/CMakeLists.txt libcxx/docs/BuildingLibcxx.rst libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt libunwind/docs/BuildingLibunwind.rst Removed: diff --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt index 1716c53b031ef..61b1c60bf590b 100644 --- a/clang/runtime/CMakeLists.txt +++ b/clang/runtime/CMakeLists.txt @@ -82,7 +82,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/) -DLLVM_LIT_ARGS=${LLVM_LIT_ARGS} -DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION} -DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR} - -DCOMPILER_RT_INSTALL_PATH:STRING=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION} + -DCOMPILER_RT_INSTALL_PATH:PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION} -DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake index 1e9e7c58664b6..bc69ec95c4195 100644 --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -371,7 +371,7 @@ function(add_compiler_rt_runtime name type) add_custom_command(TARGET ${libname} POST_BUILD COMMAND codesign --sign - $ - WORKING_DIRECTORY
[clang] a3ab2c9 - [clang][cmake] Rearrange top-level CMakeLists.txt for D116492
Author: John Ericson Date: 2022-01-03T18:28:34Z New Revision: a3ab2c94a2715c45e39abdb36b4d78e028b051d2 URL: https://github.com/llvm/llvm-project/commit/a3ab2c94a2715c45e39abdb36b4d78e028b051d2 DIFF: https://github.com/llvm/llvm-project/commit/a3ab2c94a2715c45e39abdb36b4d78e028b051d2.diff LOG: [clang][cmake] Rearrange top-level CMakeLists.txt for D116492 In that revision, I make LLD match Clang in deprecating `llvm-config`. This patch isn't to worthwhile on its own --- there isn't a sense in which the new order is "better" in isolation --- but by putting the steps that LLD also neeeds to do first, I make the diff between LLD and Clang's top-level `CMakeLists.txt` very legible. Longer term I hope: 1. We can remove calling `llvm-config` altogether, and just go strait to finding the CMake config file. This is what Flang does, at least. 2. Hopefully the diffable part is smaller then --- i.e. there is less duplicated boilerplate. 3. Any duplicate boilerplate that remains can be factored out. I didn't both trying to factor anything out in e.g. the top level common CMake Utility modules because this deprecated-but-not-removed state is a merely transitional. Reviewed By: beanz Differential Revision: https://reviews.llvm.org/D116548 Added: Modified: clang/CMakeLists.txt Removed: diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 69d639fcec1b2..aa21d05882430 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13.4) # If we are not building as a part of LLVM, build Clang as an # standalone project, using LLVM as an external library: -if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(Clang) set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to") @@ -10,7 +10,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) set(CMAKE_CXX_EXTENSIONS NO) # Rely on llvm-config. - set(CONFIG_OUTPUT) + set(LLVM_CONFIG_OUTPUT) if(LLVM_CONFIG) set (LLVM_CONFIG_FOUND 1) message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") @@ -20,35 +20,36 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) automatically, but you can also use LLVM_DIR to specify \ the path containing LLVMConfig.cmake.") set(CONFIG_COMMAND ${LLVM_CONFIG} - "--assertion-mode" - "--bindir" - "--libdir" "--includedir" "--prefix" "--src-root" - "--cmakedir") + "--cmakedir" + "--bindir" + "--libdir" + "--assertion-mode" + ) execute_process( COMMAND ${CONFIG_COMMAND} RESULT_VARIABLE HAD_ERROR - OUTPUT_VARIABLE CONFIG_OUTPUT + OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT ) if(NOT HAD_ERROR) string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" -CONFIG_OUTPUT ${CONFIG_OUTPUT}) +LLVM_CONFIG_OUTPUT ${LLVM_CONFIG_OUTPUT}) else() string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}") message(STATUS "${CONFIG_COMMAND_STR}") message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}") endif() -list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS) -list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR) -list(GET CONFIG_OUTPUT 2 LIBRARY_DIR) -list(GET CONFIG_OUTPUT 3 INCLUDE_DIR) -list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT) -list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR) -list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_DIR) +list(GET LLVM_CONFIG_OUTPUT 0 MAIN_INCLUDE_DIR) +list(GET LLVM_CONFIG_OUTPUT 1 LLVM_OBJ_ROOT) +list(GET LLVM_CONFIG_OUTPUT 2 MAIN_SRC_DIR) +list(GET LLVM_CONFIG_OUTPUT 3 LLVM_CONFIG_CMAKE_DIR) +list(GET LLVM_CONFIG_OUTPUT 4 TOOLS_BINARY_DIR) +list(GET LLVM_CONFIG_OUTPUT 5 LIBRARY_DIR) +list(GET LLVM_CONFIG_OUTPUT 6 ENABLE_ASSERTIONS) # Normalize LLVM_CMAKE_DIR. --cmakedir might contain backslashes. # CMake assumes slashes as PATH. @@ -71,17 +72,17 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) if (NOT LLVM_CONFIG_FOUND) # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config # path is removed. +set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR}) +set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR}) set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR}) set(LIBRARY_DIR ${LLVM_LIBRARY_DIR}) -set(INCLUDE_DIR ${LLVM_INCLUDE_DIR}) -set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR}) endif() - set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") - set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib") - set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include") + set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include") set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") set(LLVM_MAIN_SRC_DIR
[libclc] 6fd2db0 - Use `GNUInstallDirs` to support custom installation dirs. -- LLVM
Author: John Ericson Date: 2021-11-02T10:23:30-04:00 New Revision: 6fd2db04d0f22ea22c5317d98ce2126aa64b6a73 URL: https://github.com/llvm/llvm-project/commit/6fd2db04d0f22ea22c5317d98ce2126aa64b6a73 DIFF: https://github.com/llvm/llvm-project/commit/6fd2db04d0f22ea22c5317d98ce2126aa64b6a73.diff LOG: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM This is a new draft of D28234. I previously did the unorthodox thing of pushing to it when I wasn't the original author, but since this version - Uses `GNUInstallDirs`, rather than mimics it, as the original author was hesitant to do but others requested. - Is much broader, effecting many more projects than LLVM itself. I figured it was time to make a new revision. I am using this patch (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful. --- As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. For example `LLVM_LIBDIR_SUFFIX`, or `COMPILER_RT_INSTALL_PATH`. Because it's not quite clear yet what to do about those, we are holding off on changing libdirs and `compiler-rt`. for this initial PR. --- On the advice of @lebedev.ri, I am splitting this up a bit per subproject, starting with LLVM. To allow it to be more easily reviewed. This and the subsequent patch must be landed together, as this will not build alone. But the rest can be landed on their own. Reviewed By: compnerd Differential Revision: https://reviews.llvm.org/D100810 Added: Modified: clang/tools/scan-build/CMakeLists.txt libclc/CMakeLists.txt lldb/cmake/modules/FindLibEdit.cmake llvm/CMakeLists.txt llvm/cmake/modules/AddLLVM.cmake llvm/cmake/modules/AddSphinxTarget.cmake llvm/cmake/modules/CMakeLists.txt llvm/cmake/modules/LLVMInstallSymlink.cmake llvm/docs/CMake.rst llvm/examples/Bye/CMakeLists.txt llvm/include/llvm/CMakeLists.txt llvm/tools/llvm-config/BuildVariables.inc.in llvm/tools/llvm-config/llvm-config.cpp llvm/tools/lto/CMakeLists.txt llvm/tools/opt-viewer/CMakeLists.txt llvm/tools/remarks-shlib/CMakeLists.txt openmp/runtime/src/CMakeLists.txt Removed: diff --git a/clang/tools/scan-build/CMakeLists.txt b/clang/tools/scan-build/CMakeLists.txt index ec0702d76f184..74334e53c9b18 100644 --- a/clang/tools/scan-build/CMakeLists.txt +++ b/clang/tools/scan-build/CMakeLists.txt @@ -66,16 +66,16 @@ if(CLANG_INSTALL_SCANBUILD) endforeach() foreach(ManPage ${ManPages}) -add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage} +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}" COMMAND ${CMAKE_COMMAND} -E make_directory - ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1 + "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1" COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage} - ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/ + "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}" + "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/" DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}) -list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}) +list(APPEND Depends "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}") install(PROGRAMS man/${ManPage} -DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 +DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" COMPONENT scan-build) endforeach() diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index ec39ea63f2d02..e90e0fd852012 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -183,8 +183,8 @@ endif() # pkg-config file configure_file( libclc.pc.in libclc.pc @ONLY ) -install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig ) -install( DIRECTORY generic/include/clc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) +install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig" ) +install( DIRECTORY generic/include/clc DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) if( ENABLE_RUNTIME_SUBNORMAL ) add_library( subnormal_use_default STATIC @@ -192,7 +192,7 @@ if( ENABLE_RUNTIME_SUBNORMAL ) add_library( subnormal_disable STATIC generic/lib/subnormal_disable.ll ) install( TARGETS subnormal_use_default subnormal_disable ARCHIVE - DESTINATION ${CMAKE_INSTALL_DATADIR}/clc ) +
[clang] 6fd2db0 - Use `GNUInstallDirs` to support custom installation dirs. -- LLVM
Author: John Ericson Date: 2021-11-02T10:23:30-04:00 New Revision: 6fd2db04d0f22ea22c5317d98ce2126aa64b6a73 URL: https://github.com/llvm/llvm-project/commit/6fd2db04d0f22ea22c5317d98ce2126aa64b6a73 DIFF: https://github.com/llvm/llvm-project/commit/6fd2db04d0f22ea22c5317d98ce2126aa64b6a73.diff LOG: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM This is a new draft of D28234. I previously did the unorthodox thing of pushing to it when I wasn't the original author, but since this version - Uses `GNUInstallDirs`, rather than mimics it, as the original author was hesitant to do but others requested. - Is much broader, effecting many more projects than LLVM itself. I figured it was time to make a new revision. I am using this patch (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful. --- As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. For example `LLVM_LIBDIR_SUFFIX`, or `COMPILER_RT_INSTALL_PATH`. Because it's not quite clear yet what to do about those, we are holding off on changing libdirs and `compiler-rt`. for this initial PR. --- On the advice of @lebedev.ri, I am splitting this up a bit per subproject, starting with LLVM. To allow it to be more easily reviewed. This and the subsequent patch must be landed together, as this will not build alone. But the rest can be landed on their own. Reviewed By: compnerd Differential Revision: https://reviews.llvm.org/D100810 Added: Modified: clang/tools/scan-build/CMakeLists.txt libclc/CMakeLists.txt lldb/cmake/modules/FindLibEdit.cmake llvm/CMakeLists.txt llvm/cmake/modules/AddLLVM.cmake llvm/cmake/modules/AddSphinxTarget.cmake llvm/cmake/modules/CMakeLists.txt llvm/cmake/modules/LLVMInstallSymlink.cmake llvm/docs/CMake.rst llvm/examples/Bye/CMakeLists.txt llvm/include/llvm/CMakeLists.txt llvm/tools/llvm-config/BuildVariables.inc.in llvm/tools/llvm-config/llvm-config.cpp llvm/tools/lto/CMakeLists.txt llvm/tools/opt-viewer/CMakeLists.txt llvm/tools/remarks-shlib/CMakeLists.txt openmp/runtime/src/CMakeLists.txt Removed: diff --git a/clang/tools/scan-build/CMakeLists.txt b/clang/tools/scan-build/CMakeLists.txt index ec0702d76f184..74334e53c9b18 100644 --- a/clang/tools/scan-build/CMakeLists.txt +++ b/clang/tools/scan-build/CMakeLists.txt @@ -66,16 +66,16 @@ if(CLANG_INSTALL_SCANBUILD) endforeach() foreach(ManPage ${ManPages}) -add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage} +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}" COMMAND ${CMAKE_COMMAND} -E make_directory - ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1 + "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1" COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage} - ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/ + "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}" + "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/" DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}) -list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}) +list(APPEND Depends "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}") install(PROGRAMS man/${ManPage} -DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 +DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" COMPONENT scan-build) endforeach() diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index ec39ea63f2d02..e90e0fd852012 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -183,8 +183,8 @@ endif() # pkg-config file configure_file( libclc.pc.in libclc.pc @ONLY ) -install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig ) -install( DIRECTORY generic/include/clc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) +install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig" ) +install( DIRECTORY generic/include/clc DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) if( ENABLE_RUNTIME_SUBNORMAL ) add_library( subnormal_use_default STATIC @@ -192,7 +192,7 @@ if( ENABLE_RUNTIME_SUBNORMAL ) add_library( subnormal_disable STATIC generic/lib/subnormal_disable.ll ) install( TARGETS subnormal_use_default subnormal_disable ARCHIVE - DESTINATION ${CMAKE_INSTALL_DATADIR}/clc ) +
[clang] 492de35 - Revert "Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM""
Author: John Ericson Date: 2021-12-10T20:59:43Z New Revision: 492de35df443d5f31480173d5f1274c7835cd3d8 URL: https://github.com/llvm/llvm-project/commit/492de35df443d5f31480173d5f1274c7835cd3d8 DIFF: https://github.com/llvm/llvm-project/commit/492de35df443d5f31480173d5f1274c7835cd3d8.diff LOG: Revert "Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM"" This reverts commit 797b50d4be873b4662983413a06806fca544c276. See the original D99484. @mib who noticed the original problem could not longer reproduce it, after I tried and also failed. We are threfore hoping it went away on its own! Reviewed By: mib Differential Revision: https://reviews.llvm.org/D115544 Added: Modified: clang/tools/scan-build/CMakeLists.txt libclc/CMakeLists.txt lldb/cmake/modules/FindLibEdit.cmake llvm/CMakeLists.txt llvm/cmake/modules/AddLLVM.cmake llvm/cmake/modules/AddSphinxTarget.cmake llvm/cmake/modules/CMakeLists.txt llvm/cmake/modules/LLVMInstallSymlink.cmake llvm/docs/CMake.rst llvm/examples/Bye/CMakeLists.txt llvm/include/llvm/CMakeLists.txt llvm/tools/llvm-config/BuildVariables.inc.in llvm/tools/llvm-config/llvm-config.cpp llvm/tools/lto/CMakeLists.txt llvm/tools/opt-viewer/CMakeLists.txt llvm/tools/remarks-shlib/CMakeLists.txt openmp/runtime/src/CMakeLists.txt Removed: diff --git a/clang/tools/scan-build/CMakeLists.txt b/clang/tools/scan-build/CMakeLists.txt index ec0702d76f184..74334e53c9b18 100644 --- a/clang/tools/scan-build/CMakeLists.txt +++ b/clang/tools/scan-build/CMakeLists.txt @@ -66,16 +66,16 @@ if(CLANG_INSTALL_SCANBUILD) endforeach() foreach(ManPage ${ManPages}) -add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage} +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}" COMMAND ${CMAKE_COMMAND} -E make_directory - ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1 + "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1" COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage} - ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/ + "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}" + "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/" DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}) -list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}) +list(APPEND Depends "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}") install(PROGRAMS man/${ManPage} -DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 +DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" COMPONENT scan-build) endforeach() diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index ec39ea63f2d02..e90e0fd852012 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -183,8 +183,8 @@ endif() # pkg-config file configure_file( libclc.pc.in libclc.pc @ONLY ) -install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig ) -install( DIRECTORY generic/include/clc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) +install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig" ) +install( DIRECTORY generic/include/clc DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) if( ENABLE_RUNTIME_SUBNORMAL ) add_library( subnormal_use_default STATIC @@ -192,7 +192,7 @@ if( ENABLE_RUNTIME_SUBNORMAL ) add_library( subnormal_disable STATIC generic/lib/subnormal_disable.ll ) install( TARGETS subnormal_use_default subnormal_disable ARCHIVE - DESTINATION ${CMAKE_INSTALL_DATADIR}/clc ) + DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) endif() find_package( Python3 REQUIRED COMPONENTS Interpreter ) @@ -343,7 +343,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) add_custom_target( "prepare-${spv_suffix}" ALL DEPENDS "${spv_suffix}" ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${spv_suffix} -DESTINATION ${CMAKE_INSTALL_DATADIR}/clc ) +DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) else() # Add prepare target @@ -366,7 +366,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) PROPERTIES ENVIRONMENT "LLVM_CONFIG=${LLVM_CONFIG}" ) endif() - install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION ${CMAKE_INSTALL_DATADIR}/clc ) + install( FILES
[clang] ddcc02d - Quote some more destination paths with variables
Author: John Ericson Date: 2021-12-13T17:29:08Z New Revision: ddcc02dbcc4767b289776f73f26fe444964d0942 URL: https://github.com/llvm/llvm-project/commit/ddcc02dbcc4767b289776f73f26fe444964d0942 DIFF: https://github.com/llvm/llvm-project/commit/ddcc02dbcc4767b289776f73f26fe444964d0942.diff LOG: Quote some more destination paths with variables Just defensive CMake-ing. I pulled this from D115544 and D99484 which are blocked on some lldb CI failures I don't yet understand. Hoping to land something smaller in the meantime. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D115566 Added: Modified: clang/tools/scan-build/CMakeLists.txt libclc/CMakeLists.txt libcxx/include/CMakeLists.txt lldb/cmake/modules/FindLibEdit.cmake llvm/cmake/modules/AddSphinxTarget.cmake openmp/runtime/src/CMakeLists.txt Removed: diff --git a/clang/tools/scan-build/CMakeLists.txt b/clang/tools/scan-build/CMakeLists.txt index ec0702d76f184..74334e53c9b18 100644 --- a/clang/tools/scan-build/CMakeLists.txt +++ b/clang/tools/scan-build/CMakeLists.txt @@ -66,16 +66,16 @@ if(CLANG_INSTALL_SCANBUILD) endforeach() foreach(ManPage ${ManPages}) -add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage} +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}" COMMAND ${CMAKE_COMMAND} -E make_directory - ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1 + "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1" COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage} - ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/ + "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}" + "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/" DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}) -list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}) +list(APPEND Depends "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}") install(PROGRAMS man/${ManPage} -DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 +DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" COMPONENT scan-build) endforeach() diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index ec39ea63f2d02..e90e0fd852012 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -183,8 +183,8 @@ endif() # pkg-config file configure_file( libclc.pc.in libclc.pc @ONLY ) -install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig ) -install( DIRECTORY generic/include/clc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) +install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig" ) +install( DIRECTORY generic/include/clc DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) if( ENABLE_RUNTIME_SUBNORMAL ) add_library( subnormal_use_default STATIC @@ -192,7 +192,7 @@ if( ENABLE_RUNTIME_SUBNORMAL ) add_library( subnormal_disable STATIC generic/lib/subnormal_disable.ll ) install( TARGETS subnormal_use_default subnormal_disable ARCHIVE - DESTINATION ${CMAKE_INSTALL_DATADIR}/clc ) + DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) endif() find_package( Python3 REQUIRED COMPONENTS Interpreter ) @@ -343,7 +343,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) add_custom_target( "prepare-${spv_suffix}" ALL DEPENDS "${spv_suffix}" ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${spv_suffix} -DESTINATION ${CMAKE_INSTALL_DATADIR}/clc ) +DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) else() # Add prepare target @@ -366,7 +366,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) PROPERTIES ENVIRONMENT "LLVM_CONFIG=${LLVM_CONFIG}" ) endif() - install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION ${CMAKE_INSTALL_DATADIR}/clc ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) foreach( a ${${d}_aliases} ) set( alias_suffix "${a}-${t}.bc" ) add_custom_target( ${alias_suffix} ALL @@ -374,7 +374,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) create_symlink ${obj_suffix} ${alias_suffix}
[libunwind] 914fffc - [libunwind][cmake] Create `LIBUNWIND_INSTALL_INCLUDE_DIR` CACHE PATH
Author: John Ericson Date: 2022-01-10T21:31:52Z New Revision: 914fffc7f2492a1e4bc419a80c30fdb3f9440698 URL: https://github.com/llvm/llvm-project/commit/914fffc7f2492a1e4bc419a80c30fdb3f9440698 DIFF: https://github.com/llvm/llvm-project/commit/914fffc7f2492a1e4bc419a80c30fdb3f9440698.diff LOG: [libunwind][cmake] Create `LIBUNWIND_INSTALL_INCLUDE_DIR` CACHE PATH This is created on analogy with the other CACHE PATHs in this package, and other `*_INSTALL_INCLUDE_DIR` in other packages. The branching is adjusted to deduplicate some existing code, and likewise avoid having to define this new variable more than once. This will be used for D99484. Reviewed By: #libunwind, compnerd Differential Revision: https://reviews.llvm.org/D116873 Added: Modified: libunwind/CMakeLists.txt libunwind/include/CMakeLists.txt Removed: diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index e3cc66dd22267..efbd88a27f05a 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -141,26 +141,25 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH "Path where built libunwind libraries should be installed.") - set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH - "Path where built libunwind runtime libraries should be installed.") if(LIBCXX_LIBDIR_SUBDIR) string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) string(APPEND LIBUNWIND_INSTALL_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) endif() -elseif(LLVM_LIBRARY_OUTPUT_INTDIR) - set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH - "Path where built libunwind libraries should be installed.") - set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH - "Path where built libunwind runtime libraries should be installed.") else() - set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) + if(LLVM_LIBRARY_OUTPUT_INTDIR) +set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) + else() +set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) + endif() set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH "Path where built libunwind libraries should be installed.") - set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH - "Path where built libunwind runtime libraries should be installed.") endif() +set(LIBUNWIND_INSTALL_INCLUDE_DIR include CACHE PATH +"Path where built libunwind headers should be installed.") +set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH +"Path where built libunwind runtime libraries should be installed.") + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR}) diff --git a/libunwind/include/CMakeLists.txt b/libunwind/include/CMakeLists.txt index c3bb1dd0f69fa..adf1766c44cbc 100644 --- a/libunwind/include/CMakeLists.txt +++ b/libunwind/include/CMakeLists.txt @@ -14,7 +14,7 @@ if(LIBUNWIND_INSTALL_HEADERS) foreach(file ${files}) get_filename_component(dir ${file} DIRECTORY) install(FILES ${file} - DESTINATION "include/${dir}" + DESTINATION "${LIBUNWIND_INSTALL_INCLUDE_DIR}/${dir}" COMPONENT unwind-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 0a8d15a - [libc++][libc++abi][libunwind] Dedup install path var definitions
Author: John Ericson Date: 2022-01-11T18:24:50Z New Revision: 0a8d15ad55e344419400f037393f2208214e33e0 URL: https://github.com/llvm/llvm-project/commit/0a8d15ad55e344419400f037393f2208214e33e0 DIFF: https://github.com/llvm/llvm-project/commit/0a8d15ad55e344419400f037393f2208214e33e0.diff LOG: [libc++][libc++abi][libunwind] Dedup install path var definitions In D116873 I did this for libunwind prior to defining a new install path variable. But I think the change is good on its own, and libc++{,abi} could also use it. libc++ needed the base header var defined above the conditional part to use it for the prefi+ed headers in the non-target-specific case. For consistency, I therefore put the unconditional ones above for all 3 libs, which is why I touched the libunwind code (seeing that it had the core change already) Reviewed By: phosek, #libunwind, #libc, #libc_abi, ldionne Differential Revision: https://reviews.llvm.org/D116988 Added: Modified: libcxx/CMakeLists.txt libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt Removed: diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index b0569a4a54ca..82a643e74eb7 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -411,44 +411,35 @@ endif () # TODO: Projects that depend on libc++ should use LIBCXX_GENERATED_INCLUDE_DIR # instead of hard-coding include/c++/v1. + +set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH +"Path where target-agnostic libc++ headers should be installed.") +set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH +"Path where built libc++ runtime libraries should be installed.") + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH "Path where built libc++ libraries should be installed.") - set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH - "Path where built libc++ runtime libraries should be installed.") - set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH - "Path where target-agnostic libc++ headers should be installed.") set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH "Path where target-specific libc++ headers should be installed.") if(LIBCXX_LIBDIR_SUBDIR) string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) endif() -elseif(LLVM_LIBRARY_OUTPUT_INTDIR) - set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) - set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") - set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") - set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH - "Path where built libc++ libraries should be installed.") - set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH - "Path where built libc++ runtime libraries should be installed.") - set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH - "Path where target-agnostic libc++ headers should be installed.") - set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH - "Path where target-specific libc++ headers should be installed.") else() - set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) - set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") + if(LLVM_LIBRARY_OUTPUT_INTDIR) +set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) +set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") + else() +set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) +set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") + endif() set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH "Path where built libc++ libraries should be installed.") - set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH - "Path where built libc++ runtime libraries should be installed.") - set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH - "Path where target-agnostic libc++ headers should be installed.") set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH "Path where target-specific libc++ headers should be installed.") endif() diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index 858f5d5cfd7f..89722df0bf46 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -210,31 +210,28 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} )
[libunwind] 6e52bfe - Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."
Author: John Ericson Date: 2022-01-15T07:35:02Z New Revision: 6e52bfe09d3ab3ae6c43c079d06ebeb7bb241dec URL: https://github.com/llvm/llvm-project/commit/6e52bfe09d3ab3ae6c43c079d06ebeb7bb241dec DIFF: https://github.com/llvm/llvm-project/commit/6e52bfe09d3ab3ae6c43c079d06ebeb7bb241dec.diff LOG: Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs." Sorry for the disruption, I will try again later. This reverts commit efeb50197091b2ade24c00b9d55814bc433a7fd1. Added: Modified: clang-tools-extra/CMakeLists.txt clang-tools-extra/clang-doc/tool/CMakeLists.txt clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt clang-tools-extra/clang-tidy/CMakeLists.txt clang-tools-extra/clang-tidy/tool/CMakeLists.txt clang-tools-extra/modularize/CMakeLists.txt clang/CMakeLists.txt clang/cmake/modules/AddClang.cmake clang/tools/c-index-test/CMakeLists.txt clang/tools/clang-format/CMakeLists.txt clang/tools/clang-nvlink-wrapper/CMakeLists.txt clang/tools/clang-rename/CMakeLists.txt clang/tools/libclang/CMakeLists.txt clang/tools/scan-build-py/CMakeLists.txt clang/tools/scan-build/CMakeLists.txt clang/tools/scan-view/CMakeLists.txt clang/utils/hmaptool/CMakeLists.txt compiler-rt/cmake/base-config-ix.cmake libc/CMakeLists.txt libcxx/CMakeLists.txt libcxx/cmake/Modules/HandleLibCXXABI.cmake libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt llvm/cmake/modules/LLVMInstallSymlink.cmake mlir/CMakeLists.txt mlir/cmake/modules/AddMLIR.cmake openmp/CMakeLists.txt openmp/libompd/src/CMakeLists.txt openmp/runtime/src/CMakeLists.txt openmp/tools/multiplex/CMakeLists.txt polly/CMakeLists.txt polly/cmake/CMakeLists.txt polly/lib/External/CMakeLists.txt pstl/CMakeLists.txt Removed: diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt index 7b8274a97336b..2e73b6ba81d2e 100644 --- a/clang-tools-extra/CMakeLists.txt +++ b/clang-tools-extra/CMakeLists.txt @@ -1,5 +1,4 @@ include(CMakeDependentOption) -include(GNUInstallDirs) option(CLANG_TIDY_ENABLE_STATIC_ANALYZER "Include static analyzer checks in clang-tidy" ON) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index fb8317b272932..7e71478869160 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -19,9 +19,9 @@ target_link_libraries(clang-doc ) install(FILES ../assets/clang-doc-default-stylesheet.css - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + DESTINATION share/clang COMPONENT clang-doc) install(FILES ../assets/index.js - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + DESTINATION share/clang COMPONENT clang-doc) diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt index e6926a0d5bd10..8f5509d22e24a 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt @@ -20,5 +20,5 @@ target_link_libraries(find-all-symbols ) install(PROGRAMS run-find-all-symbols.py - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + DESTINATION share/clang COMPONENT find-all-symbols) diff --git a/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt b/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt index 5b9e00ab87cd8..3936ac1e8a5a5 100644 --- a/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt @@ -21,8 +21,8 @@ target_link_libraries(clang-include-fixer ) install(PROGRAMS clang-include-fixer.el - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + DESTINATION share/clang COMPONENT clang-include-fixer) install(PROGRAMS clang-include-fixer.py - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + DESTINATION share/clang COMPONENT clang-include-fixer) diff --git a/clang-tools-extra/clang-tidy/CMakeLists.txt b/clang-tools-extra/clang-tidy/CMakeLists.txt index 075e9f9909d65..455645050d93d 100644 --- a/clang-tools-extra/clang-tidy/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/CMakeLists.txt @@ -113,7 +113,7 @@ add_subdirectory(utils) if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY . -DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/clang-tidy" +DESTINATION include/clang-tidy COMPONENT clang-tidy-headers FILES_MATCHING PATTERN "*.h" diff --git a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt index 4b8c93801501a..ad3255b024fc6 100644 --- a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt +++
[libunwind] da77db5 - Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."
Author: John Ericson Date: 2022-01-16T05:48:30Z New Revision: da77db58d7629a3bfea1a0053aa9c29764b0bc2b URL: https://github.com/llvm/llvm-project/commit/da77db58d7629a3bfea1a0053aa9c29764b0bc2b DIFF: https://github.com/llvm/llvm-project/commit/da77db58d7629a3bfea1a0053aa9c29764b0bc2b.diff LOG: Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs." https://lab.llvm.org/buildbot/#/builders/46/builds/21146 Still have this odd error, not sure how to reproduce, so I will just try breaking up my patch. This reverts commit 4a678f8072004eff9214c1a4e1836a14abb69535. Added: Modified: clang-tools-extra/CMakeLists.txt clang-tools-extra/clang-doc/tool/CMakeLists.txt clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt clang-tools-extra/clang-tidy/CMakeLists.txt clang-tools-extra/clang-tidy/tool/CMakeLists.txt clang-tools-extra/modularize/CMakeLists.txt clang/CMakeLists.txt clang/cmake/modules/AddClang.cmake clang/tools/c-index-test/CMakeLists.txt clang/tools/clang-format/CMakeLists.txt clang/tools/clang-nvlink-wrapper/CMakeLists.txt clang/tools/clang-rename/CMakeLists.txt clang/tools/libclang/CMakeLists.txt clang/tools/scan-build-py/CMakeLists.txt clang/tools/scan-build/CMakeLists.txt clang/tools/scan-view/CMakeLists.txt clang/utils/hmaptool/CMakeLists.txt compiler-rt/cmake/base-config-ix.cmake libc/CMakeLists.txt libcxx/CMakeLists.txt libcxx/cmake/Modules/HandleLibCXXABI.cmake libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt llvm/cmake/modules/LLVMInstallSymlink.cmake mlir/CMakeLists.txt mlir/cmake/modules/AddMLIR.cmake openmp/CMakeLists.txt openmp/libompd/src/CMakeLists.txt openmp/runtime/cmake/LibompCheckLinkerFlag.cmake openmp/runtime/src/CMakeLists.txt openmp/tools/multiplex/CMakeLists.txt polly/CMakeLists.txt polly/cmake/CMakeLists.txt polly/lib/External/CMakeLists.txt pstl/CMakeLists.txt Removed: diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt index 7b8274a97336b..2e73b6ba81d2e 100644 --- a/clang-tools-extra/CMakeLists.txt +++ b/clang-tools-extra/CMakeLists.txt @@ -1,5 +1,4 @@ include(CMakeDependentOption) -include(GNUInstallDirs) option(CLANG_TIDY_ENABLE_STATIC_ANALYZER "Include static analyzer checks in clang-tidy" ON) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index fb8317b272932..7e71478869160 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -19,9 +19,9 @@ target_link_libraries(clang-doc ) install(FILES ../assets/clang-doc-default-stylesheet.css - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + DESTINATION share/clang COMPONENT clang-doc) install(FILES ../assets/index.js - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + DESTINATION share/clang COMPONENT clang-doc) diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt index e6926a0d5bd10..8f5509d22e24a 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt @@ -20,5 +20,5 @@ target_link_libraries(find-all-symbols ) install(PROGRAMS run-find-all-symbols.py - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + DESTINATION share/clang COMPONENT find-all-symbols) diff --git a/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt b/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt index 5b9e00ab87cd8..3936ac1e8a5a5 100644 --- a/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt @@ -21,8 +21,8 @@ target_link_libraries(clang-include-fixer ) install(PROGRAMS clang-include-fixer.el - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + DESTINATION share/clang COMPONENT clang-include-fixer) install(PROGRAMS clang-include-fixer.py - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + DESTINATION share/clang COMPONENT clang-include-fixer) diff --git a/clang-tools-extra/clang-tidy/CMakeLists.txt b/clang-tools-extra/clang-tidy/CMakeLists.txt index 075e9f9909d65..455645050d93d 100644 --- a/clang-tools-extra/clang-tidy/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/CMakeLists.txt @@ -113,7 +113,7 @@ add_subdirectory(utils) if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY . -DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/clang-tidy" +DESTINATION include/clang-tidy COMPONENT clang-tidy-headers FILES_MATCHING PATTERN "*.h" diff --git
[libunwind] 4a678f8 - [cmake] Use `GNUInstallDirs` to support custom installation dirs.
Author: John Ericson Date: 2022-01-16T05:33:07Z New Revision: 4a678f8072004eff9214c1a4e1836a14abb69535 URL: https://github.com/llvm/llvm-project/commit/4a678f8072004eff9214c1a4e1836a14abb69535 DIFF: https://github.com/llvm/llvm-project/commit/4a678f8072004eff9214c1a4e1836a14abb69535.diff LOG: [cmake] Use `GNUInstallDirs` to support custom installation dirs. This is the original patch in my GNUInstallDirs series, now last to merge as the final piece! It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up - Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested. - Converting all the packages, not just LLVM, effecting many more projects than LLVM itself. I figured it was time to make a new revision. I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful. --- As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`. These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder. Reviewed By: #libunwind, #libc, #libc_abi, compnerd Differential Revision: https://reviews.llvm.org/D99484 Added: Modified: clang-tools-extra/CMakeLists.txt clang-tools-extra/clang-doc/tool/CMakeLists.txt clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt clang-tools-extra/clang-tidy/CMakeLists.txt clang-tools-extra/clang-tidy/tool/CMakeLists.txt clang-tools-extra/modularize/CMakeLists.txt clang/CMakeLists.txt clang/cmake/modules/AddClang.cmake clang/tools/c-index-test/CMakeLists.txt clang/tools/clang-format/CMakeLists.txt clang/tools/clang-nvlink-wrapper/CMakeLists.txt clang/tools/clang-rename/CMakeLists.txt clang/tools/libclang/CMakeLists.txt clang/tools/scan-build-py/CMakeLists.txt clang/tools/scan-build/CMakeLists.txt clang/tools/scan-view/CMakeLists.txt clang/utils/hmaptool/CMakeLists.txt compiler-rt/cmake/base-config-ix.cmake libc/CMakeLists.txt libcxx/CMakeLists.txt libcxx/cmake/Modules/HandleLibCXXABI.cmake libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt llvm/cmake/modules/LLVMInstallSymlink.cmake mlir/CMakeLists.txt mlir/cmake/modules/AddMLIR.cmake openmp/CMakeLists.txt openmp/libompd/src/CMakeLists.txt openmp/runtime/cmake/LibompCheckLinkerFlag.cmake openmp/runtime/src/CMakeLists.txt openmp/tools/multiplex/CMakeLists.txt polly/CMakeLists.txt polly/cmake/CMakeLists.txt polly/lib/External/CMakeLists.txt pstl/CMakeLists.txt Removed: diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt index 2e73b6ba81d2..7b8274a97336 100644 --- a/clang-tools-extra/CMakeLists.txt +++ b/clang-tools-extra/CMakeLists.txt @@ -1,4 +1,5 @@ include(CMakeDependentOption) +include(GNUInstallDirs) option(CLANG_TIDY_ENABLE_STATIC_ANALYZER "Include static analyzer checks in clang-tidy" ON) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index 7e7147886916..fb8317b27293 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -19,9 +19,9 @@ target_link_libraries(clang-doc ) install(FILES ../assets/clang-doc-default-stylesheet.css - DESTINATION share/clang + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" COMPONENT clang-doc) install(FILES ../assets/index.js - DESTINATION share/clang + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" COMPONENT clang-doc) diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt index 8f5509d22e24..e6926a0d5bd1 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt @@ -20,5 +20,5 @@ target_link_libraries(find-all-symbols ) install(PROGRAMS run-find-all-symbols.py - DESTINATION share/clang + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" COMPONENT find-all-symbols) diff --git
[clang] e0eeae9 - [lld][clang][cmake] Clean up a few things
Author: John Ericson Date: 2022-02-03T20:01:28Z New Revision: e0eeae9a447004cc346d9bf36c0d02f45e276a7c URL: https://github.com/llvm/llvm-project/commit/e0eeae9a447004cc346d9bf36c0d02f45e276a7c DIFF: https://github.com/llvm/llvm-project/commit/e0eeae9a447004cc346d9bf36c0d02f45e276a7c.diff LOG: [lld][clang][cmake] Clean up a few things - If not using `llvm-config`, `LLVM_MAIN_SRC_DIR` now has a sane default - `LLVM_CONFIG_PATH` will continue to work for LLD for back compat. - More quoting of paths in an abundance of caution. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D118792 Added: Modified: clang/CMakeLists.txt lld/CMakeLists.txt Removed: diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 2bb395ffece53..1cc9bacf4e5eb 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -71,24 +71,26 @@ if(CLANG_BUILT_STANDALONE) endif() find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") - list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR}) + list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}") # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets # LLVM_CONFIG. if (NOT LLVM_CONFIG_FOUND) # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config # path is removed. -set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR}) -set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR}) -set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR}) -set(LIBRARY_DIR ${LLVM_LIBRARY_DIR}) - endif() - - set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include") - set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") - set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") - set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") - set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib") +set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}") +set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") +# N.B. this is just a default value, the CACHE PATHs below can be overriden. +set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") +set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") +set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}") + endif() + + set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to llvm/include") + set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") + set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") + set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin") + set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib") find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt index 1a53c5bf47a8d..9bcc135665d02 100644 --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -15,6 +15,10 @@ if(LLD_BUILT_STANDALONE) # Rely on llvm-config. set(LLVM_CONFIG_OUTPUT) + if(NOT LLVM_CONFIG) + # back compat + set(LLVM_CONFIG "${LLVM_CONFIG_PATH}") + endif() if(LLVM_CONFIG) set (LLVM_CONFIG_FOUND 1) message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") @@ -55,20 +59,22 @@ if(LLD_BUILT_STANDALONE) endif() find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") - list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR}) + list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}") # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets # LLVM_CONFIG. if (NOT LLVM_CONFIG_FOUND) # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config # path is removed. -set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR}) -set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR}) +set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}") +set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") +# N.B. this is just a default value, the CACHE PATHs below can be overriden. +set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") endif() - set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include") - set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") - set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") + set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to llvm/include") + set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") + set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] f16a4a0 - [libcxx][libcxxabi][libunwind][cmake] Use `GNUInstallDirs` to support custom installation dirs
Author: John Ericson Date: 2022-01-18T06:44:57Z New Revision: f16a4a034a279f52c33f41cafb7d9751ee8a01dd URL: https://github.com/llvm/llvm-project/commit/f16a4a034a279f52c33f41cafb7d9751ee8a01dd DIFF: https://github.com/llvm/llvm-project/commit/f16a4a034a279f52c33f41cafb7d9751ee8a01dd.diff LOG: [libcxx][libcxxabi][libunwind][cmake] Use `GNUInstallDirs` to support custom installation dirs I am breaking apart D99484 so the cause of build failures is easier to understand. Differential Revision: https://reviews.llvm.org/D117417 Added: Modified: libcxx/CMakeLists.txt libcxx/cmake/Modules/HandleLibCXXABI.cmake libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt Removed: diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index f78fb77ceb378..b44b16088effe 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -10,6 +10,8 @@ endif() #=== cmake_minimum_required(VERSION 3.13.4) +include(GNUInstallDirs) + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") # Add path for custom modules @@ -412,9 +414,9 @@ endif () # TODO: Projects that depend on libc++ should use LIBCXX_GENERATED_INCLUDE_DIR # instead of hard-coding include/c++/v1. -set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH +set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH "Path where target-agnostic libc++ headers should be installed.") -set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH +set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Path where built libc++ runtime libraries should be installed.") if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) @@ -423,7 +425,7 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH "Path where built libc++ libraries should be installed.") - set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH "Path where target-specific libc++ headers should be installed.") if(LIBCXX_LIBDIR_SUBDIR) string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) diff --git a/libcxx/cmake/Modules/HandleLibCXXABI.cmake b/libcxx/cmake/Modules/HandleLibCXXABI.cmake index 5a8a4a270a1a1..d69405ddeeacf 100644 --- a/libcxx/cmake/Modules/HandleLibCXXABI.cmake +++ b/libcxx/cmake/Modules/HandleLibCXXABI.cmake @@ -1,8 +1,9 @@ - #=== # Add an ABI library if appropriate #=== +include(GNUInstallDirs) + # # _setup_abi: Set up the build to use an ABI library # @@ -63,7 +64,7 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs) if (LIBCXX_INSTALL_HEADERS) install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}" -DESTINATION include/c++/v1/${dstdir} +DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}" COMPONENT cxx-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index b73804390ba20..6b3bcef2851da 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -10,6 +10,8 @@ endif() cmake_minimum_required(VERSION 3.13.4) +include(GNUInstallDirs) + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") # Add path for custom modules @@ -210,7 +212,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ) -set(LIBCXXABI_INSTALL_RUNTIME_DIR bin CACHE PATH +set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Path where built libc++abi runtime libraries should be installed.") if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 33741aea8f77a..340a103a4abe8 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -8,6 +8,8 @@ endif() cmake_minimum_required(VERSION 3.13.4) +include(GNUInstallDirs) + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") # Add path for custom modules @@ -137,9 +139,9 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) -set(LIBUNWIND_INSTALL_INCLUDE_DIR include CACHE PATH +set(LIBUNWIND_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH "Path where built libunwind headers should be installed.") -set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH
[libunwind] df31ff1 - [cmake] Make include(GNUInstallDirs) always below project(..)
Author: John Ericson Date: 2022-01-20T18:59:17Z New Revision: df31ff1b29bc4c2308ec5df8a7ff0ec2ab0942d4 URL: https://github.com/llvm/llvm-project/commit/df31ff1b29bc4c2308ec5df8a7ff0ec2ab0942d4 DIFF: https://github.com/llvm/llvm-project/commit/df31ff1b29bc4c2308ec5df8a7ff0ec2ab0942d4.diff LOG: [cmake] Make include(GNUInstallDirs) always below project(..) Its defaulting logic must go after `project(..)` to work correctly, but `project(..)` is often in a standalone condition making this awkward, since the rest of the condition code may also need GNUInstallDirs. The good thing is there are the various standalone booleans, which I had missed before. This makes splitting the conditional blocks less awkward. Reviewed By: arichardson, phosek, beanz, ldionne, #libunwind, #libc, #libc_abi Differential Revision: https://reviews.llvm.org/D117639 Added: Modified: flang/CMakeLists.txt libcxx/CMakeLists.txt libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt lld/CMakeLists.txt lldb/CMakeLists.txt lldb/cmake/modules/LLDBStandalone.cmake lldb/tools/debugserver/CMakeLists.txt llvm/CMakeLists.txt mlir/CMakeLists.txt polly/CMakeLists.txt pstl/CMakeLists.txt Removed: diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index abb9a47d3abb4..5caa79e8da477 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -7,8 +7,6 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_EXTENSIONS OFF) -include(GNUInstallDirs) - set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE) @@ -27,7 +25,14 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) message("Building Flang as a standalone project.") project(Flang) set(FLANG_STANDALONE_BUILD ON) +else() + set(FLANG_STANDALONE_BUILD OFF) +endif() + +# Must go below project(..) +include(GNUInstallDirs) +if (FLANG_STANDALONE_BUILD) set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) if (NOT MSVC_IDE) set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS} @@ -179,7 +184,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif() else() - set(FLANG_STANDALONE_BUILD OFF) option(FLANG_INCLUDE_TESTS "Generate build targets for the Flang unit tests." ${LLVM_INCLUDE_TESTS}) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index b44b16088effe..77df59e4cd755 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -10,8 +10,6 @@ endif() #=== cmake_minimum_required(VERSION 3.13.4) -include(GNUInstallDirs) - set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") # Add path for custom modules @@ -39,14 +37,17 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUIL # In a standalone build, we don't have llvm to automatically generate the # llvm-lit script for us. So we need to provide an explicit directory that # the configurator should write the script into. - set(LIBCXX_STANDALONE_BUILD 1) + set(LIBCXX_STANDALONE_BUILD TRUE) set(LLVM_LIT_OUTPUT_DIR "${LIBCXX_BINARY_DIR}/bin") +endif() + +# Must go below project(..) +include(GNUInstallDirs) +if (LIBCXX_STANDALONE_BUILD) # Find the LLVM sources and simulate LLVM CMake options. include(HandleOutOfTreeLLVM) -endif() -if (LIBCXX_STANDALONE_BUILD) find_package(Python3 COMPONENTS Interpreter) if(NOT Python3_Interpreter_FOUND) message(SEND_ERROR "Python3 not found. Python3 is required") diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index 78f486418af79..ecbc7091864e7 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -10,8 +10,6 @@ endif() cmake_minimum_required(VERSION 3.13.4) -include(GNUInstallDirs) - set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") # Add path for custom modules @@ -37,17 +35,21 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_B set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org") + set(LIBCXXABI_STANDALONE_BUILD TRUE) + # In a standalone build, we don't have llvm to automatically generate the # llvm-lit script for us. So we need to provide an explicit directory that # the configurator should write the script into. - set(LIBCXXABI_STANDALONE_BUILD 1) set(LLVM_LIT_OUTPUT_DIR "${LIBCXXABI_BINARY_DIR}/bin") +endif() +# Must go below project(..) +include(GNUInstallDirs) + +if (LIBCXXABI_STANDALONE_BUILD) # Find the LLVM sources and simulate LLVM CMake options. include(HandleOutOfTreeLLVM) -endif() -if (LIBCXXABI_STANDALONE_BUILD) find_package(Python3 COMPONENTS Interpreter) if(NOT Python3_Interpreter_FOUND) message(WARNING "Python3 not found, using
[libunwind] 4af1127 - [cmake] Duplicate `{llvm,compiler_rt}_check_linker_flag` for runtime libs and llvm
Author: John Ericson Date: 2022-01-20T21:18:42Z New Revision: 4af11272f57a4a6fed2932e9e0857b2c1a707c51 URL: https://github.com/llvm/llvm-project/commit/4af11272f57a4a6fed2932e9e0857b2c1a707c51 DIFF: https://github.com/llvm/llvm-project/commit/4af11272f57a4a6fed2932e9e0857b2c1a707c51.diff LOG: [cmake] Duplicate `{llvm,compiler_rt}_check_linker_flag` for runtime libs and llvm We previously had a few varied definitions of this floating around. I made the one installed with LLVM handle all the cases, and then made the others use it. This issue was reported to me in https://reviews.llvm.org/D116521#3248117 as D116521 made clang and llvm use the common cmake utils. Reviewed By: sebastian-ne, phosek, #libunwind, #libc, #libc_abi, ldionne Differential Revision: https://reviews.llvm.org/D117537 Added: Modified: compiler-rt/cmake/config-ix.cmake libcxx/cmake/config-ix.cmake libunwind/cmake/config-ix.cmake llvm/cmake/modules/LLVMCheckLinkerFlag.cmake runtimes/CMakeLists.txt Removed: cmake/Modules/CheckLinkerFlag.cmake diff --git a/cmake/Modules/CheckLinkerFlag.cmake b/cmake/Modules/CheckLinkerFlag.cmake deleted file mode 100644 index 722fe5b1b8ead..0 --- a/cmake/Modules/CheckLinkerFlag.cmake +++ /dev/null @@ -1,17 +0,0 @@ -include(CMakePushCheckState) -include(CheckCCompilerFlag) - -function(llvm_check_linker_flag flag dest) - # If testing a flag with check_c_compiler_flag, it gets added to the compile - # command only, but not to the linker command in that test. If the flag - # is vital for linking to succeed, the test would fail even if it would - # have succeeded if it was included on both commands. - # - # Therefore, try adding the flag to CMAKE_REQUIRED_FLAGS, which gets - # added to both compiling and linking commands in the tests. - - cmake_push_check_state() - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") - check_c_compiler_flag("" ${dest}) - cmake_pop_check_state() -endfunction() diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 33693ce60321d..596f61e8c82ec 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -1,4 +1,5 @@ include(CMakePushCheckState) +include(LLVMCheckLinkerFlag) # Compat until CMake 3.18 include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) include(CheckIncludeFiles) @@ -6,13 +7,6 @@ include(CheckLibraryExists) include(CheckSymbolExists) include(TestBigEndian) -function(compiler_rt_check_linker_flag flag out_var) - cmake_push_check_state() - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") - check_cxx_compiler_flag("" ${out_var}) - cmake_pop_check_state() -endfunction() - check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC) if (COMPILER_RT_USE_BUILTINS_LIBRARY) include(HandleCompilerRT) @@ -171,12 +165,12 @@ check_library_exists(c++ __cxa_throw "" COMPILER_RT_HAS_LIBCXX) check_library_exists(stdc++ __cxa_throw "" COMPILER_RT_HAS_LIBSTDCXX) # Linker flags. -compiler_rt_check_linker_flag("-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT) -compiler_rt_check_linker_flag("-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG) +llvm_check_linker_flag(CXX "-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT) +llvm_check_linker_flag(CXX "-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG) if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") set(VERS_COMPAT_OPTION "-Wl,-z,gnu-version-script-compat") - compiler_rt_check_linker_flag("${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT) + llvm_check_linker_flag(CXX "${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT) endif() set(DUMMY_VERS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/dummy.vers) @@ -187,10 +181,10 @@ if(COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT) # -z gnu-version-script-compat. string(APPEND VERS_OPTION " ${VERS_COMPAT_OPTION}") endif() -compiler_rt_check_linker_flag("${VERS_OPTION}" COMPILER_RT_HAS_VERSION_SCRIPT) +llvm_check_linker_flag(CXX "${VERS_OPTION}" COMPILER_RT_HAS_VERSION_SCRIPT) if(ANDROID) - compiler_rt_check_linker_flag("-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL) + llvm_check_linker_flag(CXX "-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL) check_library_exists(log __android_log_write "" COMPILER_RT_HAS_LIBLOG) endif() @@ -436,7 +430,7 @@ if(APPLE) -lc++ -lc++abi) - compiler_rt_check_linker_flag("-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION) + llvm_check_linker_flag(CXX "-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION) if(COMPILER_RT_HAS_APP_EXTENSION) list(APPEND DARWIN_COMMON_LINK_FLAGS "-fapplication-extension") endif() diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake index 689a9d09c0179..e114337f081a3 100644 --- a/libcxx/cmake/config-ix.cmake +++ b/libcxx/cmake/config-ix.cmake @@ -1,6 +1,6 @@ include(CMakePushCheckState) include(CheckLibraryExists)
[clang] 10d0d8c - [clang][cmake] Use `GNUInstallDirs` to support custom installation dirs
Author: John Ericson Date: 2022-01-21T23:58:08Z New Revision: 10d0d8c0c1db57b7ff465df7ced78a42a20d592d URL: https://github.com/llvm/llvm-project/commit/10d0d8c0c1db57b7ff465df7ced78a42a20d592d DIFF: https://github.com/llvm/llvm-project/commit/10d0d8c0c1db57b7ff465df7ced78a42a20d592d.diff LOG: [clang][cmake] Use `GNUInstallDirs` to support custom installation dirs I am breaking apart D99484 so the cause of build failures is easier to understand. Differential Revision: https://reviews.llvm.org/D117419 Added: Modified: clang/CMakeLists.txt clang/cmake/modules/AddClang.cmake clang/cmake/modules/CMakeLists.txt clang/tools/c-index-test/CMakeLists.txt clang/tools/clang-format/CMakeLists.txt clang/tools/clang-nvlink-wrapper/CMakeLists.txt clang/tools/clang-rename/CMakeLists.txt clang/tools/libclang/CMakeLists.txt clang/tools/scan-build-py/CMakeLists.txt clang/tools/scan-build/CMakeLists.txt clang/tools/scan-view/CMakeLists.txt clang/utils/hmaptool/CMakeLists.txt Removed: diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 7ea37850ad609..49150fa7c5612 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -4,7 +4,13 @@ cmake_minimum_required(VERSION 3.13.4) # standalone project, using LLVM as an external library: if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(Clang) + set(CLANG_BUILT_STANDALONE TRUE) +endif() + +# Must go below project(..) +include(GNUInstallDirs) +if(CLANG_BUILT_STANDALONE) set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to") set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_CXX_EXTENSIONS NO) @@ -185,8 +191,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif() endif() - set(CLANG_BUILT_STANDALONE TRUE) - set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}") else() set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}") @@ -424,7 +428,7 @@ include_directories(BEFORE if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY include/clang include/clang-c -DESTINATION include +DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT clang-headers FILES_MATCHING PATTERN "*.def" @@ -433,7 +437,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) ) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang -DESTINATION include +DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT clang-headers FILES_MATCHING PATTERN "CMakeFiles" EXCLUDE @@ -453,7 +457,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) add_custom_target(bash-autocomplete DEPENDS utils/bash-autocomplete.sh) install(PROGRAMS utils/bash-autocomplete.sh - DESTINATION share/clang + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" COMPONENT bash-autocomplete) if(NOT LLVM_ENABLE_IDE) add_llvm_install_targets(install-bash-autocomplete diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index 5752f4277444e..9bbbfc032b7df 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -1,3 +1,4 @@ +include(GNUInstallDirs) include(LLVMDistributionSupport) function(clang_tablegen) @@ -120,7 +121,7 @@ macro(add_clang_library name) ${export_to_clangtargets} LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} - RUNTIME DESTINATION bin) + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") if (NOT LLVM_ENABLE_IDE) add_llvm_install_targets(install-${lib} @@ -159,7 +160,7 @@ macro(add_clang_tool name) get_target_export_arg(${name} Clang export_to_clangtargets) install(TARGETS ${name} ${export_to_clangtargets} - RUNTIME DESTINATION bin + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name}) if(NOT LLVM_ENABLE_IDE) diff --git a/clang/cmake/modules/CMakeLists.txt b/clang/cmake/modules/CMakeLists.txt index e9cc1240dafb7..c6f6ce9fe5d69 100644 --- a/clang/cmake/modules/CMakeLists.txt +++ b/clang/cmake/modules/CMakeLists.txt @@ -1,3 +1,4 @@ +include(ExtendPath) include(LLVMDistributionSupport) include(FindPrefixFromConfig) @@ -42,8 +43,9 @@ find_prefix_from_config(CLANG_CONFIG_CODE CLANG_INSTALL_PREFIX "${CLANG_INSTALL_ set(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${CLANG_INSTALL_PACKAGE_DIR}") set(CLANG_CONFIG_LLVM_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") get_config_exports_includes(Clang CLANG_CONFIG_INCLUDE_EXPORTS) +extend_path(base_includedir "\${CLANG_INSTALL_PREFIX}" "${CMAKE_INSTALL_INCLUDEDIR}") set(CLANG_CONFIG_INCLUDE_DIRS - "\${CLANG_INSTALL_PREFIX}/include" + "${base_includedir}" ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt index
[clang] 44e3365 - [CMake] Factor out config prefix finding logic
Author: John Ericson Date: 2022-01-07T20:16:18Z New Revision: 44e3365775101fec3fd355eda339282258d74415 URL: https://github.com/llvm/llvm-project/commit/44e3365775101fec3fd355eda339282258d74415 DIFF: https://github.com/llvm/llvm-project/commit/44e3365775101fec3fd355eda339282258d74415.diff LOG: [CMake] Factor out config prefix finding logic See the docs in the new function for details. I think I found every instance of this copy pasted code. Polly could also use it, but currently does something different, so I will save the behavior change for a future revision. We get the shared, non-installed CMake modules following the pattern established in D116472. It might be good to have LLD and Flang also use this, but that would be a functional change and so I leave it as future work. Reviewed By: beanz, lebedev.ri Differential Revision: https://reviews.llvm.org/D116521 Added: cmake/Modules/FindPrefixFromConfig.cmake Modified: clang/CMakeLists.txt clang/cmake/modules/CMakeLists.txt flang/cmake/modules/CMakeLists.txt lld/cmake/modules/CMakeLists.txt llvm/CMakeLists.txt llvm/cmake/modules/CMakeLists.txt mlir/CMakeLists.txt mlir/cmake/modules/CMakeLists.txt Removed: diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index aa21d05882430..7ea37850ad609 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -192,9 +192,16 @@ else() set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}") endif() # standalone +if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) + set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) +endif() + # Make sure that our source directory is on the current cmake module path so that # we can include cmake files from this directory. -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") +list(INSERT CMAKE_MODULE_PATH 0 + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" + "${LLVM_COMMON_CMAKE_UTILS}/Modules" + ) if(LLVM_ENABLE_LIBXML2) # Don't look for libxml if we're using MSan, since uninstrumented third party diff --git a/clang/cmake/modules/CMakeLists.txt b/clang/cmake/modules/CMakeLists.txt index 561665d58cad9..3890ea14d06c6 100644 --- a/clang/cmake/modules/CMakeLists.txt +++ b/clang/cmake/modules/CMakeLists.txt @@ -1,4 +1,5 @@ include(LLVMDistributionSupport) +include(FindPrefixFromConfig) # Generate a list of CMake library targets so that other CMake projects can # link against them. LLVM calls its version of this file LLVMExports.cmake, but @@ -29,16 +30,7 @@ set(CLANG_CONFIG_CMAKE_DIR) set(CLANG_CONFIG_LLVM_CMAKE_DIR) # Generate ClangConfig.cmake for the install tree. -set(CLANG_CONFIG_CODE " -# Compute the installation prefix from this LLVMConfig.cmake file location. -get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") -# Construct the proper number of get_filename_component(... PATH) -# calls to compute the installation prefix. -string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}") -foreach(p ${_count}) - set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE} -get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" PATH)") -endforeach(p) +find_prefix_from_config(CLANG_CONFIG_CODE CLANG_INSTALL_PREFIX "${CLANG_INSTALL_PACKAGE_DIR}") set(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${CLANG_INSTALL_PACKAGE_DIR}") set(CLANG_CONFIG_LLVM_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") get_config_exports_includes(Clang CLANG_CONFIG_INCLUDE_EXPORTS) diff --git a/cmake/Modules/FindPrefixFromConfig.cmake b/cmake/Modules/FindPrefixFromConfig.cmake new file mode 100644 index 0..aa9fb0d03413d --- /dev/null +++ b/cmake/Modules/FindPrefixFromConfig.cmake @@ -0,0 +1,41 @@ +# Find the prefix from the `*Config.cmake` file being generated. +# +# When generating an installed `*Config.cmake` file, we often want to be able +# to refer to the ancestor directory which contains all the installed files. +# +# We want to do this without baking in an absolute path when the config file is +# generated, in order to allow for a "relocatable" binary distribution that +# doesn't need to know what path it ends up being installed at when it is +# built. +# +# The solution that we know the relative path that the config file will be at +# within that prefix, like `"${prefix_var}/lib/cmake/${project}"`, so we count +# the number of components in that path to figure out how many parent dirs we +# need to traverse from the location of the config file to get to the prefix +# dir. +# +# out_var: +# variable to set the "return value" of the function, which is the code to +# include in the config file under construction. +# +# prefix_var: +# Name of the variable to define in the returned code (not directory for the +# faller!) that will contain the prefix path. +# +# path_to_leave: +# Path from the prefix to the config file, a
[libunwind] 429a717 - [cmake] Move HandleOutOfTreeLLVM to common cmake utils
Author: John Ericson Date: 2022-01-19T22:05:23Z New Revision: 429a717ea5ec141b5c0c93c2c53097dccf67e05a URL: https://github.com/llvm/llvm-project/commit/429a717ea5ec141b5c0c93c2c53097dccf67e05a DIFF: https://github.com/llvm/llvm-project/commit/429a717ea5ec141b5c0c93c2c53097dccf67e05a.diff LOG: [cmake] Move HandleOutOfTreeLLVM to common cmake utils This is better than libunwind and libcxxabi fishing it out of libcxx's module directory. It is done in prepartion for a better version of D117537 which deduplicates CMake logic instead of just renaming to avoid a name clash. Reviewed By: phosek, #libunwind, #libc_abi, Ericson2314 Differential Revision: https://reviews.llvm.org/D117617 Added: cmake/Modules/HandleOutOfTreeLLVM.cmake Modified: libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt Removed: libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake diff --git a/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake b/cmake/Modules/HandleOutOfTreeLLVM.cmake similarity index 97% rename from libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake rename to cmake/Modules/HandleOutOfTreeLLVM.cmake index 588d48efd412b..edffe572e091e 100644 --- a/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake +++ b/cmake/Modules/HandleOutOfTreeLLVM.cmake @@ -1,5 +1,5 @@ if (NOT DEFINED LLVM_PATH) - set(LLVM_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../llvm CACHE PATH "" FORCE) + set(LLVM_PATH ${CMAKE_CURRENT_LIST_DIR}/../../llvm CACHE PATH "" FORCE) endif() if(NOT IS_DIRECTORY ${LLVM_PATH}) diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index 6b3bcef2851da..78f486418af79 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -37,10 +37,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_B set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org") - # Add the CMake module path of libcxx so we can reuse HandleOutOfTreeLLVM.cmake - set(LIBCXXABI_LIBCXX_CMAKE_PATH "${LIBCXXABI_LIBCXX_PATH}/cmake/Modules") - list(APPEND CMAKE_MODULE_PATH "${LIBCXXABI_LIBCXX_CMAKE_PATH}") - # In a standalone build, we don't have llvm to automatically generate the # llvm-lit script for us. So we need to provide an explicit directory that # the configurator should write the script into. diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 340a103a4abe8..03bd316d331cb 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -37,10 +37,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBUNWIND_STANDALONE_B set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org") - # Add the CMake module path of libcxx so we can reuse HandleOutOfTreeLLVM.cmake - set(LIBUNWIND_LIBCXX_CMAKE_PATH "${LIBUNWIND_LIBCXX_PATH}/cmake/Modules") - list(APPEND CMAKE_MODULE_PATH "${LIBUNWIND_LIBCXX_CMAKE_PATH}") - # In a standalone build, we don't have llvm to automatically generate the # llvm-lit script for us. So we need to provide an explicit directory that # the configurator should write the script into. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 7c16647 - [clang-tools-extra][cmake] Use `GNUInstallDirs` to support custom installation dirs.
Author: John Ericson Date: 2022-01-22T20:57:21Z New Revision: 7c16647c3676587391f6bb80ec87d9621ca9472f URL: https://github.com/llvm/llvm-project/commit/7c16647c3676587391f6bb80ec87d9621ca9472f DIFF: https://github.com/llvm/llvm-project/commit/7c16647c3676587391f6bb80ec87d9621ca9472f.diff LOG: [clang-tools-extra][cmake] Use `GNUInstallDirs` to support custom installation dirs. This is the original patch in my GNUInstallDirs series, now last to merge as the final piece! It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up - Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested. - Converting all the packages, not just LLVM, effecting many more projects than LLVM itself. I figured it was time to make a new revision. I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful. --- As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`. These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder. Reviewed By: #libunwind, #libc, #libc_abi, compnerd Differential Revision: https://reviews.llvm.org/D99484 Added: Modified: clang-tools-extra/CMakeLists.txt clang-tools-extra/clang-doc/tool/CMakeLists.txt clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt clang-tools-extra/clang-tidy/CMakeLists.txt clang-tools-extra/clang-tidy/tool/CMakeLists.txt clang-tools-extra/modularize/CMakeLists.txt Removed: diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt index 2e73b6ba81d2e..7b8274a97336b 100644 --- a/clang-tools-extra/CMakeLists.txt +++ b/clang-tools-extra/CMakeLists.txt @@ -1,4 +1,5 @@ include(CMakeDependentOption) +include(GNUInstallDirs) option(CLANG_TIDY_ENABLE_STATIC_ANALYZER "Include static analyzer checks in clang-tidy" ON) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index 7e71478869160..fb8317b272932 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -19,9 +19,9 @@ target_link_libraries(clang-doc ) install(FILES ../assets/clang-doc-default-stylesheet.css - DESTINATION share/clang + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" COMPONENT clang-doc) install(FILES ../assets/index.js - DESTINATION share/clang + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" COMPONENT clang-doc) diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt index 8f5509d22e24a..e6926a0d5bd10 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt @@ -20,5 +20,5 @@ target_link_libraries(find-all-symbols ) install(PROGRAMS run-find-all-symbols.py - DESTINATION share/clang + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" COMPONENT find-all-symbols) diff --git a/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt b/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt index 3936ac1e8a5a5..5b9e00ab87cd8 100644 --- a/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt @@ -21,8 +21,8 @@ target_link_libraries(clang-include-fixer ) install(PROGRAMS clang-include-fixer.el - DESTINATION share/clang + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" COMPONENT clang-include-fixer) install(PROGRAMS clang-include-fixer.py - DESTINATION share/clang + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" COMPONENT clang-include-fixer) diff --git a/clang-tools-extra/clang-tidy/CMakeLists.txt b/clang-tools-extra/clang-tidy/CMakeLists.txt index 455645050d93d..075e9f9909d65 100644 --- a/clang-tools-extra/clang-tidy/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/CMakeLists.txt @@ -113,7 +113,7 @@ add_subdirectory(utils) if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY . -DESTINATION include/clang-tidy +DESTINATION
[clang] d5daa5c - [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore
Author: John Ericson Date: 2022-06-10T14:35:18Z New Revision: d5daa5c5b091cafb9b7ffd19b5dfa2daadef3229 URL: https://github.com/llvm/llvm-project/commit/d5daa5c5b091cafb9b7ffd19b5dfa2daadef3229 DIFF: https://github.com/llvm/llvm-project/commit/d5daa5c5b091cafb9b7ffd19b5dfa2daadef3229.diff LOG: [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore First of all, `LLVM_TOOLS_INSTALL_DIR` put there breaks our NixOS builds, because `LLVM_TOOLS_INSTALL_DIR` defined the same as `CMAKE_INSTALL_BINDIR` becomes an *absolute* path, and then when downstream projects try to install there too this breaks because our builds always install to fresh directories for isolation's sake. Second of all, note that `LLVM_TOOLS_INSTALL_DIR` stands out against the other specially crafted `LLVM_CONFIG_*` variables substituted in `llvm/cmake/modules/LLVMConfig.cmake.in`. @beanz added it in d0e1c2a550ef348aae036d0fe78cab6f038c420c to fix a dangling reference in `AddLLVM`, but I am suspicious of how this variable doesn't follow the pattern. Those other ones are carefully made to be build-time vs install-time variables depending on which `LLVMConfig.cmake` is being generated, are carefully made relative as appropriate, etc. etc. For my NixOS use-case they are also fine because they are never used as downstream install variables, only for reading not writing. To avoid the problems I face, and restore symmetry, I deleted the exported and arranged to have many `${project}_TOOLS_INSTALL_DIR`s. `AddLLVM` now instead expects each project to define its own, and they do so based on `CMAKE_INSTALL_BINDIR`. `LLVMConfig` still exports `LLVM_TOOLS_BINARY_DIR` which is the location for the tools defined in the usual way, matching the other remaining exported variables. For the `AddLLVM` changes, I tried to copy the existing pattern of internal vs non-internal or for LLVM vs for downstream function/macro names, but it would good to confirm I did that correctly. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D117977 Added: Modified: bolt/tools/CMakeLists.txt bolt/tools/driver/CMakeLists.txt bolt/tools/heatmap/CMakeLists.txt bolt/tools/merge-fdata/CMakeLists.txt clang/CMakeLists.txt clang/cmake/modules/AddClang.cmake flang/CMakeLists.txt flang/cmake/modules/AddFlang.cmake lld/CMakeLists.txt lld/cmake/modules/AddLLD.cmake llvm/cmake/modules/AddLLVM.cmake llvm/cmake/modules/CMakeLists.txt llvm/cmake/modules/LLVMConfig.cmake.in llvm/cmake/modules/TableGen.cmake mlir/CMakeLists.txt mlir/cmake/modules/AddMLIR.cmake mlir/tools/mlir-cpu-runner/CMakeLists.txt mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt mlir/tools/mlir-lsp-server/CMakeLists.txt mlir/tools/mlir-opt/CMakeLists.txt mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt mlir/tools/mlir-reduce/CMakeLists.txt mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt mlir/tools/mlir-translate/CMakeLists.txt mlir/tools/mlir-vulkan-runner/CMakeLists.txt mlir/tools/tblgen-lsp-server/CMakeLists.txt openmp/libomptarget/tools/CMakeLists.txt openmp/libomptarget/tools/deviceinfo/CMakeLists.txt Removed: diff --git a/bolt/tools/CMakeLists.txt b/bolt/tools/CMakeLists.txt index 1fe85145d79a1..91b00a5438af3 100644 --- a/bolt/tools/CMakeLists.txt +++ b/bolt/tools/CMakeLists.txt @@ -1,3 +1,17 @@ +set(BOLT_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH +"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") +mark_as_advanced(BOLT_TOOLS_INSTALL_DIR) + +# Move these macros to AddBolt if such a CMake module is ever created. + +macro(add_bolt_tool name) + llvm_add_tool(BOLT ${ARGV}) +endmacro() + +macro(add_bolt_tool_symlink name) + llvm_add_tool_symlink(BOLT ${ARGV}) +endmacro() + add_subdirectory(driver) add_subdirectory(llvm-bolt-fuzzer) add_subdirectory(merge-fdata) diff --git a/bolt/tools/driver/CMakeLists.txt b/bolt/tools/driver/CMakeLists.txt index 2338ccec11d2b..e56be15dbcff6 100644 --- a/bolt/tools/driver/CMakeLists.txt +++ b/bolt/tools/driver/CMakeLists.txt @@ -11,7 +11,7 @@ else() set(BOLT_DRIVER_DEPS "") endif() -add_llvm_tool(llvm-bolt +add_bolt_tool(llvm-bolt llvm-bolt.cpp DEPENDS @@ -25,8 +25,8 @@ target_link_libraries(llvm-bolt LLVMBOLTUtils ) -add_llvm_tool_symlink(perf2bolt llvm-bolt) -add_llvm_tool_symlink(llvm-bolt diff llvm-bolt) +add_bolt_tool_symlink(perf2bolt llvm-bolt) +add_bolt_tool_symlink(llvm-bolt diff llvm-bolt) set(BOLT_DEPENDS llvm-bolt diff --git a/bolt/tools/heatmap/CMakeLists.txt b/bolt/tools/heatmap/CMakeLists.txt index 820b268125e85..cb8e7ee2605c4 100644 --- a/bolt/tools/heatmap/CMakeLists.txt +++ b/bolt/tools/heatmap/CMakeLists.txt @@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS Support ) -add_llvm_tool(llvm-bolt-heatmap +add_bolt_tool(llvm-bolt-heatmap heatmap.cpp ) diff --git
[clang] 0bb317b - Revert "[cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore"
Author: John Ericson Date: 2022-06-10T19:26:12Z New Revision: 0bb317b7bff3d4f70bddd03a1f337c3f2a118943 URL: https://github.com/llvm/llvm-project/commit/0bb317b7bff3d4f70bddd03a1f337c3f2a118943 DIFF: https://github.com/llvm/llvm-project/commit/0bb317b7bff3d4f70bddd03a1f337c3f2a118943.diff LOG: Revert "[cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore" This reverts commit d5daa5c5b091cafb9b7ffd19b5dfa2daadef3229. Added: Modified: bolt/tools/CMakeLists.txt bolt/tools/driver/CMakeLists.txt bolt/tools/heatmap/CMakeLists.txt bolt/tools/merge-fdata/CMakeLists.txt clang/CMakeLists.txt clang/cmake/modules/AddClang.cmake flang/CMakeLists.txt flang/cmake/modules/AddFlang.cmake lld/CMakeLists.txt lld/cmake/modules/AddLLD.cmake llvm/cmake/modules/AddLLVM.cmake llvm/cmake/modules/CMakeLists.txt llvm/cmake/modules/LLVMConfig.cmake.in llvm/cmake/modules/TableGen.cmake mlir/CMakeLists.txt mlir/cmake/modules/AddMLIR.cmake mlir/tools/mlir-cpu-runner/CMakeLists.txt mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt mlir/tools/mlir-lsp-server/CMakeLists.txt mlir/tools/mlir-opt/CMakeLists.txt mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt mlir/tools/mlir-reduce/CMakeLists.txt mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt mlir/tools/mlir-translate/CMakeLists.txt mlir/tools/mlir-vulkan-runner/CMakeLists.txt mlir/tools/tblgen-lsp-server/CMakeLists.txt openmp/libomptarget/tools/CMakeLists.txt openmp/libomptarget/tools/deviceinfo/CMakeLists.txt Removed: diff --git a/bolt/tools/CMakeLists.txt b/bolt/tools/CMakeLists.txt index 91b00a5438af3..1fe85145d79a1 100644 --- a/bolt/tools/CMakeLists.txt +++ b/bolt/tools/CMakeLists.txt @@ -1,17 +1,3 @@ -set(BOLT_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH -"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") -mark_as_advanced(BOLT_TOOLS_INSTALL_DIR) - -# Move these macros to AddBolt if such a CMake module is ever created. - -macro(add_bolt_tool name) - llvm_add_tool(BOLT ${ARGV}) -endmacro() - -macro(add_bolt_tool_symlink name) - llvm_add_tool_symlink(BOLT ${ARGV}) -endmacro() - add_subdirectory(driver) add_subdirectory(llvm-bolt-fuzzer) add_subdirectory(merge-fdata) diff --git a/bolt/tools/driver/CMakeLists.txt b/bolt/tools/driver/CMakeLists.txt index e56be15dbcff6..2338ccec11d2b 100644 --- a/bolt/tools/driver/CMakeLists.txt +++ b/bolt/tools/driver/CMakeLists.txt @@ -11,7 +11,7 @@ else() set(BOLT_DRIVER_DEPS "") endif() -add_bolt_tool(llvm-bolt +add_llvm_tool(llvm-bolt llvm-bolt.cpp DEPENDS @@ -25,8 +25,8 @@ target_link_libraries(llvm-bolt LLVMBOLTUtils ) -add_bolt_tool_symlink(perf2bolt llvm-bolt) -add_bolt_tool_symlink(llvm-bolt diff llvm-bolt) +add_llvm_tool_symlink(perf2bolt llvm-bolt) +add_llvm_tool_symlink(llvm-bolt diff llvm-bolt) set(BOLT_DEPENDS llvm-bolt diff --git a/bolt/tools/heatmap/CMakeLists.txt b/bolt/tools/heatmap/CMakeLists.txt index cb8e7ee2605c4..820b268125e85 100644 --- a/bolt/tools/heatmap/CMakeLists.txt +++ b/bolt/tools/heatmap/CMakeLists.txt @@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS Support ) -add_bolt_tool(llvm-bolt-heatmap +add_llvm_tool(llvm-bolt-heatmap heatmap.cpp ) diff --git a/bolt/tools/merge-fdata/CMakeLists.txt b/bolt/tools/merge-fdata/CMakeLists.txt index 08b2e65b1bce8..2de2ede8f2b5c 100644 --- a/bolt/tools/merge-fdata/CMakeLists.txt +++ b/bolt/tools/merge-fdata/CMakeLists.txt @@ -1,6 +1,6 @@ set(LLVM_LINK_COMPONENTS Support) -add_bolt_tool(merge-fdata +add_llvm_tool(merge-fdata merge-fdata.cpp DEPENDS diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index c27beec313d78..191f4f2af242a 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -366,10 +366,6 @@ endif() # The libdir suffix must exactly match whatever LLVM's configuration used. set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}") -set(CLANG_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH -"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") -mark_as_advanced(CLANG_TOOLS_INSTALL_DIR) - set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index c58af0b26a8e5..299f8ce6e2fb4 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -173,9 +173,9 @@ macro(add_clang_tool name) endmacro() macro(add_clang_symlink name dest) - llvm_add_tool_symlink(CLANG ${name} ${dest} ALWAYS_GENERATE) + add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE) # Always generate install targets - llvm_install_symlink(CLANG name} ${dest} ALWAYS_GENERATE) + llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE) endmacro() function(clang_target_link_libraries target type) diff
[clang] cc56a50 - [clang][lld][cmake] Simplify header dirs
Author: John Ericson Date: 2022-07-28T19:36:40-04:00 New Revision: cc56a5022c94710d8393f1505f925494f7d2cc1c URL: https://github.com/llvm/llvm-project/commit/cc56a5022c94710d8393f1505f925494f7d2cc1c DIFF: https://github.com/llvm/llvm-project/commit/cc56a5022c94710d8393f1505f925494f7d2cc1c.diff LOG: [clang][lld][cmake] Simplify header dirs We don't need to recompute the list LLVMConfig.cmake provides us. When LLVM is being built, the list is two elements long: generated headers and headers from source. When LLVM is already built,the list is one element long: the installed header directory containing both generated and hand-written sources. Reviewed By: sebastian-ne Differential Revision: https://reviews.llvm.org/D130553 Added: Modified: clang/CMakeLists.txt lld/CMakeLists.txt Removed: diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index c27beec313d7..480f13e73c9f 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -78,15 +78,17 @@ if(CLANG_BUILT_STANDALONE) if (NOT LLVM_CONFIG_FOUND) # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config # path is removed. -set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}") +set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") # N.B. this is just a default value, the CACHE PATHs below can be overriden. set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}") + else() +set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") endif() - set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to llvm/include") + set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin") @@ -128,7 +130,7 @@ if(CLANG_BUILT_STANDALONE) set(LLVM_INCLUDE_TESTS ON) endif() - include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}") + include_directories(${LLVM_INCLUDE_DIRS}) link_directories("${LLVM_LIBRARY_DIR}") set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt index dcc649629a4b..58dca54642e4 100644 --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -70,13 +70,15 @@ if(LLD_BUILT_STANDALONE) if (NOT LLVM_CONFIG_FOUND) # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config # path is removed. -set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}") +set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") # N.B. this is just a default value, the CACHE PATHs below can be overridden. set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") + else() +set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") endif() - set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to llvm/include") + set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") @@ -95,7 +97,7 @@ if(LLD_BUILT_STANDALONE) set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") - include_directories("${LLVM_BINARY_DIR}/include" ${LLVM_INCLUDE_DIRS}) + include_directories(${LLVM_INCLUDE_DIRS}) link_directories(${LLVM_LIBRARY_DIRS}) if(LLVM_INCLUDE_TESTS) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 07b7498 - [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore
Author: John Ericson Date: 2022-07-21T19:04:00Z New Revision: 07b749800c5cd4105d49ab46be5f0a2079dd709a URL: https://github.com/llvm/llvm-project/commit/07b749800c5cd4105d49ab46be5f0a2079dd709a DIFF: https://github.com/llvm/llvm-project/commit/07b749800c5cd4105d49ab46be5f0a2079dd709a.diff LOG: [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore First of all, `LLVM_TOOLS_INSTALL_DIR` put there breaks our NixOS builds, because `LLVM_TOOLS_INSTALL_DIR` defined the same as `CMAKE_INSTALL_BINDIR` becomes an *absolute* path, and then when downstream projects try to install there too this breaks because our builds always install to fresh directories for isolation's sake. Second of all, note that `LLVM_TOOLS_INSTALL_DIR` stands out against the other specially crafted `LLVM_CONFIG_*` variables substituted in `llvm/cmake/modules/LLVMConfig.cmake.in`. @beanz added it in d0e1c2a550ef348aae036d0fe78cab6f038c420c to fix a dangling reference in `AddLLVM`, but I am suspicious of how this variable doesn't follow the pattern. Those other ones are carefully made to be build-time vs install-time variables depending on which `LLVMConfig.cmake` is being generated, are carefully made relative as appropriate, etc. etc. For my NixOS use-case they are also fine because they are never used as downstream install variables, only for reading not writing. To avoid the problems I face, and restore symmetry, I deleted the exported and arranged to have many `${project}_TOOLS_INSTALL_DIR`s. `AddLLVM` now instead expects each project to define its own, and they do so based on `CMAKE_INSTALL_BINDIR`. `LLVMConfig` still exports `LLVM_TOOLS_BINARY_DIR` which is the location for the tools defined in the usual way, matching the other remaining exported variables. For the `AddLLVM` changes, I tried to copy the existing pattern of internal vs non-internal or for LLVM vs for downstream function/macro names, but it would good to confirm I did that correctly. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D117977 Added: Modified: bolt/tools/CMakeLists.txt bolt/tools/driver/CMakeLists.txt bolt/tools/heatmap/CMakeLists.txt bolt/tools/merge-fdata/CMakeLists.txt clang/CMakeLists.txt clang/cmake/modules/AddClang.cmake flang/CMakeLists.txt flang/cmake/modules/AddFlang.cmake lld/CMakeLists.txt lld/cmake/modules/AddLLD.cmake llvm/cmake/modules/AddLLVM.cmake llvm/cmake/modules/CMakeLists.txt llvm/cmake/modules/LLVMConfig.cmake.in llvm/cmake/modules/TableGen.cmake mlir/CMakeLists.txt mlir/cmake/modules/AddMLIR.cmake mlir/tools/mlir-cpu-runner/CMakeLists.txt mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt mlir/tools/mlir-lsp-server/CMakeLists.txt mlir/tools/mlir-opt/CMakeLists.txt mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt mlir/tools/mlir-reduce/CMakeLists.txt mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt mlir/tools/mlir-translate/CMakeLists.txt mlir/tools/mlir-vulkan-runner/CMakeLists.txt mlir/tools/tblgen-lsp-server/CMakeLists.txt openmp/libomptarget/tools/CMakeLists.txt openmp/libomptarget/tools/deviceinfo/CMakeLists.txt Removed: diff --git a/bolt/tools/CMakeLists.txt b/bolt/tools/CMakeLists.txt index 1fe85145d79a1..91b00a5438af3 100644 --- a/bolt/tools/CMakeLists.txt +++ b/bolt/tools/CMakeLists.txt @@ -1,3 +1,17 @@ +set(BOLT_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH +"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") +mark_as_advanced(BOLT_TOOLS_INSTALL_DIR) + +# Move these macros to AddBolt if such a CMake module is ever created. + +macro(add_bolt_tool name) + llvm_add_tool(BOLT ${ARGV}) +endmacro() + +macro(add_bolt_tool_symlink name) + llvm_add_tool_symlink(BOLT ${ARGV}) +endmacro() + add_subdirectory(driver) add_subdirectory(llvm-bolt-fuzzer) add_subdirectory(merge-fdata) diff --git a/bolt/tools/driver/CMakeLists.txt b/bolt/tools/driver/CMakeLists.txt index 2338ccec11d2b..e56be15dbcff6 100644 --- a/bolt/tools/driver/CMakeLists.txt +++ b/bolt/tools/driver/CMakeLists.txt @@ -11,7 +11,7 @@ else() set(BOLT_DRIVER_DEPS "") endif() -add_llvm_tool(llvm-bolt +add_bolt_tool(llvm-bolt llvm-bolt.cpp DEPENDS @@ -25,8 +25,8 @@ target_link_libraries(llvm-bolt LLVMBOLTUtils ) -add_llvm_tool_symlink(perf2bolt llvm-bolt) -add_llvm_tool_symlink(llvm-bolt diff llvm-bolt) +add_bolt_tool_symlink(perf2bolt llvm-bolt) +add_bolt_tool_symlink(llvm-bolt diff llvm-bolt) set(BOLT_DEPENDS llvm-bolt diff --git a/bolt/tools/heatmap/CMakeLists.txt b/bolt/tools/heatmap/CMakeLists.txt index 820b268125e85..cb8e7ee2605c4 100644 --- a/bolt/tools/heatmap/CMakeLists.txt +++ b/bolt/tools/heatmap/CMakeLists.txt @@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS Support ) -add_llvm_tool(llvm-bolt-heatmap +add_bolt_tool(llvm-bolt-heatmap heatmap.cpp ) diff --git
[clang] 3256021 - Fix one stray `{LLVM -> CLANG}_TOOLS_INSTALL_DIR`
Author: John Ericson Date: 2022-07-23T16:26:32Z New Revision: 32560211c6206a7c63224a52200f41d17652fb0d URL: https://github.com/llvm/llvm-project/commit/32560211c6206a7c63224a52200f41d17652fb0d DIFF: https://github.com/llvm/llvm-project/commit/32560211c6206a7c63224a52200f41d17652fb0d.diff LOG: Fix one stray `{LLVM -> CLANG}_TOOLS_INSTALL_DIR` Follow up to D117977, where I missed this new usage after one rebase. Thanks @tsteller in https://reviews.llvm.org/D117977#3670919 for noticing. Reviewed By: mstorsjo Differential Revision: https://reviews.llvm.org/D130362 Added: Modified: clang/utils/hmaptool/CMakeLists.txt Removed: diff --git a/clang/utils/hmaptool/CMakeLists.txt b/clang/utils/hmaptool/CMakeLists.txt index 72915ec665044..511268069bd1c 100644 --- a/clang/utils/hmaptool/CMakeLists.txt +++ b/clang/utils/hmaptool/CMakeLists.txt @@ -1,4 +1,4 @@ -install(PROGRAMS hmaptool DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" COMPONENT hmaptool) +install(PROGRAMS hmaptool DESTINATION "${CLANG_TOOLS_INSTALL_DIR}" COMPONENT hmaptool) add_custom_target(hmaptool ALL DEPENDS "hmaptool") set_target_properties(hmaptool PROPERTIES FOLDER "Utils") ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 34fe6dd - Revert "[CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited"
Author: John Ericson Date: 2022-08-25T11:13:46-04:00 New Revision: 34fe6ddce11e4e0e31a96669ab5f200e5fb8a747 URL: https://github.com/llvm/llvm-project/commit/34fe6ddce11e4e0e31a96669ab5f200e5fb8a747 DIFF: https://github.com/llvm/llvm-project/commit/34fe6ddce11e4e0e31a96669ab5f200e5fb8a747.diff LOG: Revert "[CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited" This reverts commit ad8c34bc3089d847a09bb740f7a58c96073e0959. Added: Modified: bolt/lib/Target/AArch64/CMakeLists.txt bolt/lib/Target/X86/CMakeLists.txt bolt/unittests/Core/CMakeLists.txt clang/cmake/modules/CMakeLists.txt clang/lib/Tooling/CMakeLists.txt flang/cmake/modules/CMakeLists.txt lld/cmake/modules/CMakeLists.txt lldb/cmake/modules/LLDBConfig.cmake lldb/test/API/CMakeLists.txt llvm/CMakeLists.txt llvm/cmake/modules/AddLLVM.cmake llvm/cmake/modules/CMakeLists.txt llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt llvm/tools/llvm-exegesis/lib/X86/CMakeLists.txt llvm/tools/llvm-shlib/CMakeLists.txt llvm/unittests/Target/ARM/CMakeLists.txt llvm/unittests/Target/DirectX/CMakeLists.txt llvm/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt llvm/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt llvm/unittests/tools/llvm-exegesis/Mips/CMakeLists.txt llvm/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt llvm/unittests/tools/llvm-exegesis/X86/CMakeLists.txt llvm/unittests/tools/llvm-mca/X86/CMakeLists.txt mlir/cmake/modules/CMakeLists.txt polly/cmake/CMakeLists.txt polly/test/CMakeLists.txt Removed: diff --git a/bolt/lib/Target/AArch64/CMakeLists.txt b/bolt/lib/Target/AArch64/CMakeLists.txt index 1e7ee71f2c30..96c70168196e 100644 --- a/bolt/lib/Target/AArch64/CMakeLists.txt +++ b/bolt/lib/Target/AArch64/CMakeLists.txt @@ -14,5 +14,5 @@ add_llvm_library(LLVMBOLTTargetAArch64 include_directories( ${LLVM_MAIN_SRC_DIR}/lib/Target/AArch64 - ${LLVM_LIBRARY_DIR}/Target/AArch64 + ${LLVM_BINARY_DIR}/lib/Target/AArch64 ) diff --git a/bolt/lib/Target/X86/CMakeLists.txt b/bolt/lib/Target/X86/CMakeLists.txt index a194148adf98..47344fe33111 100644 --- a/bolt/lib/Target/X86/CMakeLists.txt +++ b/bolt/lib/Target/X86/CMakeLists.txt @@ -17,5 +17,5 @@ add_llvm_library(LLVMBOLTTargetX86 include_directories( ${LLVM_MAIN_SRC_DIR}/lib/Target/X86 - ${LLVM_LIBRARY_DIR}/Target/X86 + ${LLVM_BINARY_DIR}/lib/Target/X86 ) diff --git a/bolt/unittests/Core/CMakeLists.txt b/bolt/unittests/Core/CMakeLists.txt index 9e9c1013b21f..0e78d0a2746f 100644 --- a/bolt/unittests/Core/CMakeLists.txt +++ b/bolt/unittests/Core/CMakeLists.txt @@ -20,7 +20,7 @@ target_link_libraries(CoreTests if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD) include_directories( ${LLVM_MAIN_SRC_DIR}/lib/Target/AArch64 -${LLVM_LIBRARY_DIR}/Target/AArch64 +${LLVM_BINARY_DIR}/lib/Target/AArch64 ) target_compile_definitions(CoreTests PRIVATE AARCH64_AVAILABLE) @@ -29,7 +29,7 @@ endif() if ("X86" IN_LIST LLVM_TARGETS_TO_BUILD) include_directories( ${LLVM_MAIN_SRC_DIR}/lib/Target/X86 -${LLVM_LIBRARY_DIR}/Target/X86 +${LLVM_BINARY_DIR}/lib/Target/X86 ) target_compile_definitions(CoreTests PRIVATE X86_AVAILABLE) diff --git a/clang/cmake/modules/CMakeLists.txt b/clang/cmake/modules/CMakeLists.txt index 880d51f5aef7..6a7fa2fa27eb 100644 --- a/clang/cmake/modules/CMakeLists.txt +++ b/clang/cmake/modules/CMakeLists.txt @@ -15,7 +15,7 @@ set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/cla set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm") +set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS) export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake) diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt index e35e7f9be000..403d2dfb45e8 100644 --- a/clang/lib/Tooling/CMakeLists.txt +++ b/clang/lib/Tooling/CMakeLists.txt @@ -60,7 +60,7 @@ else() $ # Skip this in debug mode because parsing AST.h is too slow --skip-processing=${skip_expensive_processing} --I ${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION}/include +-I ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include -I ${CLANG_SOURCE_DIR}/include -I ${LLVM_BINARY_DIR}/tools/clang/include -I ${LLVM_BINARY_DIR}/include diff --git a/flang/cmake/modules/CMakeLists.txt
[clang] 3adda39 - [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro
Author: John Ericson Date: 2022-08-20T12:52:21-04:00 New Revision: 3adda398cef7f56d024924158e7b17d65cbc565d URL: https://github.com/llvm/llvm-project/commit/3adda398cef7f56d024924158e7b17d65cbc565d DIFF: https://github.com/llvm/llvm-project/commit/3adda398cef7f56d024924158e7b17d65cbc565d.diff LOG: [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro Use this instead of `*_LIBDIR_SUFFIX`, from which it is computed. This gets us ready for D130586, in which `*_LIBDIR_SUFFIX` is deprecated. Differential Revision: https://reviews.llvm.org/D132300 Added: Modified: clang/CMakeLists.txt clang/include/clang/Config/config.h.cmake clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Cuda.cpp lldb/cmake/modules/LLDBGenerateConfig.cmake lldb/include/lldb/Host/Config.h.cmake lldb/source/Host/linux/HostInfoLinux.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp lldb/unittests/Expression/ClangParserTest.cpp llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h Removed: diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 60f6c162a2d55..a6782db7b5809 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -871,6 +871,8 @@ if(CLANG_BUILT_STANDALONE) process_llvm_pass_plugins() endif() +set(CLANG_INSTALL_LIBDIR_BASENAME "lib${CLANG_LIBDIR_SUFFIX}") + configure_file( ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake ${CLANG_BINARY_DIR}/include/clang/Config/config.h) diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index dfd2f757a185b..a4083827e43f8 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -53,8 +53,8 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" -/* Multilib suffix for libdir. */ -#define CLANG_LIBDIR_SUFFIX "${CLANG_LIBDIR_SUFFIX}" +/* Multilib basename for libdir. */ +#define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" /* Relative directory for resource files */ #define CLANG_RESOURCE_DIR "${CLANG_RESOURCE_DIR}" diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 05d00a50504c4..d00f08d15ae58 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -180,7 +180,7 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath, // path of the embedding binary, which for LLVM binaries will be in bin/. // ../lib gets us to lib/ in both cases. P = llvm::sys::path::parent_path(Dir); -llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang", +llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang", CLANG_VERSION_STRING); } diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 77ce0395cf3c1..c0aec33b082a5 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -502,7 +502,8 @@ void tools::addLTOOptions(const ToolChain , const ArgList , SmallString<1024> Plugin; llvm::sys::path::native( -Twine(D.Dir) + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" + Suffix, +Twine(D.Dir) + "/../" CLANG_INSTALL_LIBDIR_BASENAME "/LLVMgold" + +Suffix, Plugin); CmdArgs.push_back(Args.MakeArgString(Plugin)); } @@ -658,7 +659,7 @@ void tools::addOpenMPRuntimeSpecificRPath(const ToolChain , // runtime SmallString<256> DefaultLibPath = llvm::sys::path::parent_path(TC.getDriver().Dir); -llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX); +llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME); CmdArgs.push_back("-rpath"); CmdArgs.push_back(Args.MakeArgString(DefaultLibPath)); } @@ -671,7 +672,7 @@ void tools::addOpenMPRuntimeLibraryPath(const ToolChain , // runtime. SmallString<256> DefaultLibPath = llvm::sys::path::parent_path(TC.getDriver().Dir); - llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX); + llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME); CmdArgs.push_back(Args.MakeArgString("-L" + DefaultLibPath)); } @@ -1947,7 +1948,7 @@ void tools::AddStaticDeviceLibs(Compilation *C, const Tool *T, // Add path to lib-debug folders SmallString<256> DefaultLibPath = llvm::sys::path::parent_path(D.Dir); - llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX); + llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME); LibraryPaths.emplace_back(DefaultLibPath.c_str()); // Build
[libunwind] e941b03 - Revert "[cmake] Use `CMAKE_INSTALL_LIBDIR` too"
Author: John Ericson Date: 2022-08-18T22:46:32-04:00 New Revision: e941b031d316f74267350fe2373d30e28b3a2c2e URL: https://github.com/llvm/llvm-project/commit/e941b031d316f74267350fe2373d30e28b3a2c2e DIFF: https://github.com/llvm/llvm-project/commit/e941b031d316f74267350fe2373d30e28b3a2c2e.diff LOG: Revert "[cmake] Use `CMAKE_INSTALL_LIBDIR` too" This reverts commit f7a33090a91015836497c75f173775392ab0304d. Unfortunately this causes a number of failures that didn't show up in my local build. Added: Modified: bolt/runtime/CMakeLists.txt clang/CMakeLists.txt clang/cmake/caches/Android-stage2.cmake clang/cmake/caches/Android.cmake clang/cmake/modules/AddClang.cmake clang/cmake/modules/CMakeLists.txt clang/include/clang/Config/config.h.cmake clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Cuda.cpp clang/lib/Headers/CMakeLists.txt clang/runtime/CMakeLists.txt clang/tools/libclang/CMakeLists.txt clang/tools/scan-build-py/CMakeLists.txt cmake/Modules/GNUInstallPackageDir.cmake compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake compiler-rt/cmake/Modules/CompilerRTUtils.cmake compiler-rt/cmake/base-config-ix.cmake compiler-rt/docs/BuildingCompilerRT.rst flang/CMakeLists.txt flang/cmake/modules/AddFlang.cmake flang/cmake/modules/CMakeLists.txt libc/CMakeLists.txt libc/lib/CMakeLists.txt libcxx/CMakeLists.txt libcxx/docs/BuildingLibcxx.rst libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt libunwind/docs/BuildingLibunwind.rst lld/CMakeLists.txt lld/cmake/modules/AddLLD.cmake lld/cmake/modules/CMakeLists.txt lldb/cmake/modules/AddLLDB.cmake lldb/cmake/modules/LLDBConfig.cmake lldb/cmake/modules/LLDBGenerateConfig.cmake lldb/cmake/modules/LLDBStandalone.cmake lldb/include/lldb/Host/Config.h.cmake lldb/source/API/CMakeLists.txt lldb/source/Host/linux/HostInfoLinux.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp lldb/tools/intel-features/CMakeLists.txt lldb/unittests/Expression/ClangParserTest.cpp llvm/CMakeLists.txt llvm/cmake/modules/AddLLVM.cmake llvm/cmake/modules/AddOCaml.cmake llvm/cmake/modules/CMakeLists.txt llvm/cmake/modules/LLVMConfig.cmake.in llvm/docs/CMake.rst llvm/tools/llvm-config/BuildVariables.inc.in llvm/tools/llvm-config/llvm-config.cpp llvm/tools/llvm-shlib/CMakeLists.txt llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn llvm/utils/gn/secondary/llvm/tools/llvm-config/BUILD.gn mlir/CMakeLists.txt mlir/cmake/modules/AddMLIR.cmake mlir/cmake/modules/AddMLIRPython.cmake mlir/cmake/modules/CMakeLists.txt mlir/test/CMakeLists.txt openmp/CMakeLists.txt openmp/README.rst polly/cmake/CMakeLists.txt polly/cmake/polly_macros.cmake polly/test/CMakeLists.txt pstl/CMakeLists.txt third-party/benchmark/src/CMakeLists.txt utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h Removed: diff --git a/bolt/runtime/CMakeLists.txt b/bolt/runtime/CMakeLists.txt index 72aae2edb7970..ef7ad02c98c77 100644 --- a/bolt/runtime/CMakeLists.txt +++ b/bolt/runtime/CMakeLists.txt @@ -1,6 +1,5 @@ cmake_minimum_required(VERSION 3.13.4) include(CheckIncludeFiles) -include(GNUInstallDirs) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD 17) @@ -33,8 +32,8 @@ target_include_directories(bolt_rt_instr PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_compile_options(bolt_rt_hugify PRIVATE ${BOLT_RT_FLAGS}) target_include_directories(bolt_rt_hugify PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -install(TARGETS bolt_rt_instr DESTINATION "${CMAKE_INSTALL_LIBDIR}") -install(TARGETS bolt_rt_hugify DESTINATION "${CMAKE_INSTALL_LIBDIR}") +install(TARGETS bolt_rt_instr DESTINATION lib) +install(TARGETS bolt_rt_hugify DESTINATION lib) if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*") add_library(bolt_rt_instr_osx STATIC @@ -45,5 +44,5 @@ if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*") target_compile_options(bolt_rt_instr_osx PRIVATE -target x86_64-apple-darwin19.6.0 ${BOLT_RT_FLAGS}) - install(TARGETS bolt_rt_instr_osx DESTINATION "${CMAKE_INSTALL_LIBDIR}") + install(TARGETS bolt_rt_instr_osx DESTINATION lib) endif() diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 9eff5e452c55d..60f6c162a2d55 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -37,7 +37,7 @@ if(CLANG_BUILT_STANDALONE) # They are used as destination of target generators. set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) - set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib) + set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
[clang] 176db3b - [RFC] Remove support for building C++ with `LLVM_ENABLE_PROJECTS`
Author: John Ericson Date: 2022-08-21T08:10:56-04:00 New Revision: 176db3b3ab25ff8a9b2405f50ef5a8bd9304a6d5 URL: https://github.com/llvm/llvm-project/commit/176db3b3ab25ff8a9b2405f50ef5a8bd9304a6d5 DIFF: https://github.com/llvm/llvm-project/commit/176db3b3ab25ff8a9b2405f50ef5a8bd9304a6d5.diff LOG: [RFC] Remove support for building C++ with `LLVM_ENABLE_PROJECTS` This has been officially deprecated since D112724, meaning the deprecation warning is present in released 14 and 15. This makes me think that now, shortly after the 15 release is branched, is a good time to pull the trigger. Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D132324 Added: Modified: clang/lib/Driver/ToolChains/Linux.cpp compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh libcxx/utils/ci/buildkite-pipeline.yml libcxx/utils/ci/oss-fuzz.sh libcxx/utils/ci/run-buildbot llvm/CMakeLists.txt Removed: diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index ceb1a982c3a4c..eedbb12d0dd53 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -307,13 +307,6 @@ Linux::Linux(const Driver , const llvm::Triple , const ArgList ) Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths); - // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs - // libc++.so in D.Dir+"/../lib/". Detect this path. - // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported. - if (StringRef(D.Dir).startswith(SysRoot) && - D.getVFS().exists(D.Dir + "/../lib/libc++.so")) -addPathIfExists(D, D.Dir + "/../lib", Paths); - addPathIfExists(D, concat(SysRoot, "/lib"), Paths); addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths); } diff --git a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh index 0386be5b76e7d..3fe8e45bfcbc8 100755 --- a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh +++ b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh @@ -100,12 +100,12 @@ if [[ ! -d ${LIBCXX_BUILD} ]]; then mkdir -p ${LIBCXX_BUILD} cd ${LIBCXX_BUILD} LIBCXX_FLAGS="${FLAGS} -Wno-macro-redefined" - PROJECTS= + RUNTIMES= if [[ ! -d $LLVM_SRC/projects/libcxxabi ]] ; then -PROJECTS="-DLLVM_ENABLE_PROJECTS='libcxx;libcxxabi'" +RUNTIMES="-DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi'" fi cmake -GNinja \ -${PROJECTS} \ +${RUNTIMES} \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=$CC \ -DCMAKE_CXX_COMPILER=$CXX \ diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml index 8e804552f3591..bf9db29ce7f59 100644 --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -321,20 +321,6 @@ steps: limit: 2 timeout_in_minutes: 120 -- label: "Legacy LLVM_ENABLE_PROJECTS build" - command: "libcxx/utils/ci/run-buildbot legacy-project-build" - artifact_paths: -- "**/test-results.xml" -- "**/*.abilist" - agents: -queue: "libcxx-builders" -os: "linux" - retry: -automatic: - - exit_status: -1 # Agent was lost -limit: 2 - timeout_in_minutes: 120 - # Tests with various build configurations. - label: "Static libraries" command: "libcxx/utils/ci/run-buildbot generic-static" diff --git a/libcxx/utils/ci/oss-fuzz.sh b/libcxx/utils/ci/oss-fuzz.sh index 12149de87ce5b..123ac47fc449b 100755 --- a/libcxx/utils/ci/oss-fuzz.sh +++ b/libcxx/utils/ci/oss-fuzz.sh @@ -13,7 +13,7 @@ INSTALL=cxx_install_dir mkdir ${BUILD} cmake -S ${PWD} -B ${BUILD} \ - -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \ + -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_INSTALL_PREFIX="${INSTALL}" cmake --build ${BUILD} --target install-cxx-headers diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot index 27431f3c2cac8..220082c1209c8 100755 --- a/libcxx/utils/ci/run-buildbot +++ b/libcxx/utils/ci/run-buildbot @@ -510,21 +510,6 @@ legacy-test-config) -DLIBUNWIND_TEST_CONFIG="${MONOREPO_ROOT}/libunwind/test/lit.site.cfg.in" check-runtimes ;; -legacy-project-build) -clean - -echo "--- Generating CMake" -${CMAKE} \ - -S "${MONOREPO_ROOT}/llvm" \ - -B "${BUILD_DIR}" \ - -DLLVM_ENABLE_PROJECTS="libcxx;libunwind;libcxxabi" \ - -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ - -DLLVM_LIT_ARGS="-sv --show-unsupported --xunit-xml-output test-results.xml --timeout=1500" \ -
[clang] 3a1c81e - [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 2
Author: John Ericson Date: 2022-09-14T15:48:58-04:00 New Revision: 3a1c81e327391466f827cafef7156b164cb4c3e6 URL: https://github.com/llvm/llvm-project/commit/3a1c81e327391466f827cafef7156b164cb4c3e6 DIFF: https://github.com/llvm/llvm-project/commit/3a1c81e327391466f827cafef7156b164cb4c3e6.diff LOG: [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 2 A simple sed doing these substitutions: - `${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}\>` -> `${LLVM_LIBRARY_DIR}` - `${LLVM_BINARY_DIR}/bin\>` -> `${LLVM_TOOLS_BINARY_DIR}` where `\>` means "word boundary". The only manual modifications were reverting changes in - `runtimes/CMakeLists.txt` because these were "entry points" where we wanted to tread carefully not not introduce a "loop" which would end with an undefined variable being expanded to nothing. There are some `${LLVM_BINARY_DIR}/lib` without the `${LLVM_LIBDIR_SUFFIX}`, but these refer to the lib subdirectory of the source (`llvm/lib`). That `lib` is automatically appended to make the local `CMAKE_CURRENT_BINARY_DIR` value by `add_subdirectory`; since the directory name in the source tree is fixed without any suffix, the corresponding `CMAKE_CURRENT_BINARY_DIR` will also be. We therefore do not replace it but leave it as-is. This picks up where D133828 left off, getting the occurrences with*out* `CMAKE_CFG_INTDIR`. But this is difficult to do correctly and so not done in the (retroactively) previous diff. This hopefully increases readability overall, and also decreases the usages of `LLVM_LIBDIR_SUFFIX`, preparing us for D130586. Reviewed By: sebastian-ne Differential Revision: https://reviews.llvm.org/D132316 Added: Modified: clang/cmake/modules/CMakeLists.txt flang/cmake/modules/CMakeLists.txt lld/cmake/modules/CMakeLists.txt lldb/cmake/modules/LLDBConfig.cmake llvm/CMakeLists.txt llvm/cmake/modules/AddLLVM.cmake llvm/cmake/modules/CMakeLists.txt mlir/cmake/modules/CMakeLists.txt polly/cmake/CMakeLists.txt polly/test/CMakeLists.txt Removed: diff --git a/clang/cmake/modules/CMakeLists.txt b/clang/cmake/modules/CMakeLists.txt index 6a7fa2fa27ebb..880d51f5aef71 100644 --- a/clang/cmake/modules/CMakeLists.txt +++ b/clang/cmake/modules/CMakeLists.txt @@ -15,7 +15,7 @@ set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/cla set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") +set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm") get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS) export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake) diff --git a/flang/cmake/modules/CMakeLists.txt b/flang/cmake/modules/CMakeLists.txt index 105cc09bf8501..31a6c3c83e48b 100644 --- a/flang/cmake/modules/CMakeLists.txt +++ b/flang/cmake/modules/CMakeLists.txt @@ -14,7 +14,7 @@ set(flang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/fla set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") +set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm") get_property(FLANG_EXPORTS GLOBAL PROPERTY FLANG_EXPORTS) export(TARGETS ${FLANG_EXPORTS} FILE ${flang_cmake_builddir}/FlangTargets.cmake) diff --git a/lld/cmake/modules/CMakeLists.txt b/lld/cmake/modules/CMakeLists.txt index 57195bce45c95..61e7a1fe2752f 100644 --- a/lld/cmake/modules/CMakeLists.txt +++ b/lld/cmake/modules/CMakeLists.txt @@ -14,7 +14,7 @@ set(lld_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/lld") set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") +set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm") get_property(LLD_EXPORTS GLOBAL PROPERTY LLD_EXPORTS) export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}/LLDTargets.cmake) diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 987353517d0d5..2dd14d05a92aa 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -276,7 +276,7 @@ if (NOT TARGET clang-resource-headers) # could be and pick the first that
[clang] d2b158e - clang/cmake: Drop use of llvm-config for LLVM install discovery
Author: Tom Stellard Date: 2022-08-06T16:22:59-04:00 New Revision: d2b158e29eedf4a29bf8d2142f2ed21a52fc80a7 URL: https://github.com/llvm/llvm-project/commit/d2b158e29eedf4a29bf8d2142f2ed21a52fc80a7 DIFF: https://github.com/llvm/llvm-project/commit/d2b158e29eedf4a29bf8d2142f2ed21a52fc80a7.diff LOG: clang/cmake: Drop use of llvm-config for LLVM install discovery This has been deprecated for a while, since D51714 in 2018. Remove it in favor of using CMake's find_package() function. Reviewed By: phosek, mgorny Differential Revision: https://reviews.llvm.org/D128777 Added: Modified: clang/CMakeLists.txt Removed: diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index bf1268c08420..f6e860159435 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -15,54 +15,6 @@ if(CLANG_BUILT_STANDALONE) set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_CXX_EXTENSIONS NO) - # Rely on llvm-config. - set(LLVM_CONFIG_OUTPUT) - if(LLVM_CONFIG) -set (LLVM_CONFIG_FOUND 1) -message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") -message(DEPRECATION "Using llvm-config to detect the LLVM installation is \ - deprecated. The installed cmake files should be used \ - instead. CMake should be able to detect your LLVM install \ - automatically, but you can also use LLVM_DIR to specify \ - the path containing LLVMConfig.cmake.") -set(CONFIG_COMMAND ${LLVM_CONFIG} - "--includedir" - "--prefix" - "--src-root" - "--cmakedir" - "--bindir" - "--libdir" - "--assertion-mode" - ) -execute_process( - COMMAND ${CONFIG_COMMAND} - RESULT_VARIABLE HAD_ERROR - OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT -) -if(NOT HAD_ERROR) - string(REGEX REPLACE -"[ \t]*[\r\n]+[ \t]*" ";" -LLVM_CONFIG_OUTPUT ${LLVM_CONFIG_OUTPUT}) -else() - string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}") - message(STATUS "${CONFIG_COMMAND_STR}") - message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}") -endif() - -list(GET LLVM_CONFIG_OUTPUT 0 MAIN_INCLUDE_DIR) -list(GET LLVM_CONFIG_OUTPUT 1 LLVM_OBJ_ROOT) -list(GET LLVM_CONFIG_OUTPUT 2 MAIN_SRC_DIR) -list(GET LLVM_CONFIG_OUTPUT 3 LLVM_CONFIG_CMAKE_DIR) -list(GET LLVM_CONFIG_OUTPUT 4 TOOLS_BINARY_DIR) -list(GET LLVM_CONFIG_OUTPUT 5 LIBRARY_DIR) -list(GET LLVM_CONFIG_OUTPUT 6 ENABLE_ASSERTIONS) - -# Normalize LLVM_CMAKE_DIR. --cmakedir might contain backslashes. -# CMake assumes slashes as PATH. -file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_DIR} LLVM_CMAKE_DIR) - endif() - - if(NOT MSVC_IDE) set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS} CACHE BOOL "Enable assertions") @@ -73,26 +25,12 @@ if(CLANG_BUILT_STANDALONE) find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}") - # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets - # LLVM_CONFIG. - if (NOT LLVM_CONFIG_FOUND) -# Pull values from LLVMConfig.cmake. We can drop this once the llvm-config -# path is removed. -set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) -set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") -# N.B. this is just a default value, the CACHE PATHs below can be overriden. -set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") -set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") -set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}") - else() -set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") - endif() - - set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") - set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") - set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") - set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin") - set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib") + # Turn into CACHE PATHs for overwritting + set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") + set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree") + set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree") + set(LLVM_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin") + set(LLVM_LIBRARY_DIR "${LLVM_LIBRARY_DIR}" CACHE PATH "Path to llvm/lib") find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) @@ -777,7 +715,6 @@ if (CLANG_ENABLE_BOOTSTRAP) endif() if(BOOTSTRAP_CMAKE_SYSTEM_NAME) -set(${CLANG_STAGE}_CONFIG -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config) set(${CLANG_STAGE}_TABLEGEN -DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen
[clang] [clang] Don't assume location of compiler-rt (PR #92183)
https://github.com/Ericson2314 created https://github.com/llvm/llvm-project/pull/92183 If the `/usr/lib/...` path one expects is not that, fall back to the regular logic. This is a minimal change to allow OpenBSD cross compilation from a toolchain that doesn't adopt all of OpenBSD's monorepo's conventions. >From 635791b1905a471d8bd2f9ee8607b25d4bb10241 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 12 May 2024 01:03:56 -0400 Subject: [PATCH] [clang] Don't assume location of compiler-rt If the `/usr/lib/...` path one expects is not that, fall back to the regular logic. This is a minimal change to allow OpenBSD cross compilation from a toolchain that doesn't adopt all of OpenBSD's monorepo's conventions. --- clang/lib/Driver/ToolChains/OpenBSD.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp b/clang/lib/Driver/ToolChains/OpenBSD.cpp index e20d9fb1cfc41..3770471bae7c0 100644 --- a/clang/lib/Driver/ToolChains/OpenBSD.cpp +++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -375,7 +375,8 @@ std::string OpenBSD::getCompilerRT(const ArgList , StringRef Component, if (Component == "builtins") { SmallString<128> Path(getDriver().SysRoot); llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a"); -return std::string(Path); +if (getVFS().exists(Path)) + return std::string(Path); } SmallString<128> P(getDriver().ResourceDir); std::string CRTBasename = ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Don't assume location of compiler-rt (PR #92183)
Ericson2314 wrote: This is a very simple thing. I am quite sure it is fine from an LLVM perspective; I wanted to make sure it was fine from a BSD perspective, and @epsilon-0 confirmed it (thank you!). Will thus merge shortly. https://github.com/llvm/llvm-project/pull/92183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Don't assume location of compiler-rt (PR #92183)
https://github.com/Ericson2314 edited https://github.com/llvm/llvm-project/pull/92183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Don't assume location of compiler-rt for OpenBSD (PR #92183)
https://github.com/Ericson2314 edited https://github.com/llvm/llvm-project/pull/92183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Don't assume location of compiler-rt for OpenBSD (PR #92183)
https://github.com/Ericson2314 edited https://github.com/llvm/llvm-project/pull/92183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Don't assume location of compiler-rt for OpenBSD (PR #92183)
https://github.com/Ericson2314 closed https://github.com/llvm/llvm-project/pull/92183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Don't assume location of compiler-rt for OpenBSD (PR #92183)
Ericson2314 wrote: /cherry-pick be10746 https://github.com/llvm/llvm-project/pull/92183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Don't assume location of compiler-rt for OpenBSD (PR #92183)
https://github.com/Ericson2314 milestoned https://github.com/llvm/llvm-project/pull/92183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Don't assume location of compiler-rt for OpenBSD (PR #92183)
Ericson2314 wrote: /cherry-pick be10746 https://github.com/llvm/llvm-project/pull/92183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits