https://github.com/petrhosek updated https://github.com/llvm/llvm-project/pull/93354
>From b7b4e6bf186e798d23d24a506461741e12ac79da Mon Sep 17 00:00:00 2001 From: Petr Hosek <pho...@google.com> Date: Fri, 24 May 2024 23:15:19 +0000 Subject: [PATCH 1/2] [runtimes] Correctly apply libdir subdir for multilib We weren't applying applying the libdir subdir to header directories but this is necessary for corretness when building e.g. ASan variant. This change also updates path construction logic accross all runtimes and ensures they're consistent. --- libcxx/CMakeLists.txt | 17 +++++++++-------- libcxxabi/CMakeLists.txt | 13 +++++++------ libunwind/CMakeLists.txt | 13 +++++++------ llvm-libgcc/CMakeLists.txt | 13 +++++++------ 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index f34cb178e076e..9e0dc159565b1 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -432,18 +432,19 @@ set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared lib set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static libc++ runtime library.") if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) + set(TARGET_DIR ${LLVM_DEFAULT_TARGET_TRIPLE}) + if(LIBCXX_LIBDIR_SUBDIR) + string(APPEND TARGET_DIR /${LIBCXX_LIBDIR_SUBDIR}) + endif() + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${TARGET_DIR}) set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/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 STRING + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${TARGET_DIR}/c++/v1") + set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${TARGET_DIR} CACHE STRING "Path where built libc++ libraries should be installed.") - set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE STRING + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${TARGET_DIR}/c++/v1" CACHE STRING "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() + unset(TARGET_DIR) else() if(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index da998d2221dc4..a799407d04e61 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -182,14 +182,15 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING "Path where built libc++abi runtime libraries should be installed.") if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + set(TARGET_DIR ${LLVM_DEFAULT_TARGET_TRIPLE}) + if(LIBCXXABI_LIBDIR_SUBDIR) + string(APPEND TARGET_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) + endif() set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) - set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) - set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE STRING + set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${TARGET_DIR}) + set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${TARGET_DIR} CACHE STRING "Path where built libc++abi libraries should be installed.") - if(LIBCXX_LIBDIR_SUBDIR) - string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) - string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) - endif() + unset(TARGET_DIR) else() if(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 806d5a783ec39..24acb3fd40d0d 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -129,13 +129,14 @@ set(LIBUNWIND_SHARED_OUTPUT_NAME "unwind" CACHE STRING "Output name for the shar set(LIBUNWIND_STATIC_OUTPUT_NAME "unwind" CACHE STRING "Output name for the static libunwind runtime library.") 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 STRING - "Path where built libunwind 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}) + set(TARGET_DIR ${LLVM_DEFAULT_TARGET_TRIPLE}) + if(LIBUNWIND_LIBDIR_SUBDIR) + string(APPEND TARGET_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) endif() + set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${TARGET_DIR}) + set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${TARGET_DIR} CACHE STRING + "Path where built libunwind libraries should be installed.") + unset(TARGET_DIR) else() if(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) diff --git a/llvm-libgcc/CMakeLists.txt b/llvm-libgcc/CMakeLists.txt index 013c9ca2e3307..76b3e3f6f7ddb 100644 --- a/llvm-libgcc/CMakeLists.txt +++ b/llvm-libgcc/CMakeLists.txt @@ -61,13 +61,14 @@ endif() #=============================================================================== if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(LLVM_LIBGCC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) - set(LLVM_LIBGCC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH - "Path where built llvm-libgcc libraries should be installed.") - if(LIBCXX_LIBDIR_SUBDIR) - string(APPEND LLVM_LIBGCC_LIBRARY_DIR /${LLVM_LIBGCC_LIBDIR_SUBDIR}) - string(APPEND LLVM_LIBGCC_INSTALL_LIBRARY_DIR /${LLVM_LIBGCC_LIBDIR_SUBDIR}) + set(TARGET_DIR ${LLVM_DEFAULT_TARGET_TRIPLE}) + if(LLVM_LIBGCC_LIBDIR_SUBDIR) + string(APPEND TARGET_DIR /${LLVM_LIBGCC_LIBDIR_SUBDIR}) endif() + set(LLVM_LIBGCC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${TARGET_DIR}) + set(LLVM_LIBGCC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${TARGET_DIR} CACHE PATH + "Path where built llvm-libgcc libraries should be installed.") + unset(TARGET_DIR) else() if(LLVM_LIBRARY_OUTPUT_INTDIR) set(LLVM_LIBGCC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) >From 2473ffd470a428a831fb85b30909bf6446a54534 Mon Sep 17 00:00:00 2001 From: Petr Hosek <pho...@google.com> Date: Fri, 24 May 2024 23:28:06 +0000 Subject: [PATCH 2/2] Update variable name --- libcxx/CMakeLists.txt | 14 +++++++------- libcxxabi/CMakeLists.txt | 10 +++++----- libunwind/CMakeLists.txt | 10 +++++----- llvm-libgcc/CMakeLists.txt | 10 +++++----- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 9e0dc159565b1..980baa652dd78 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -432,19 +432,19 @@ set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared lib set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static libc++ runtime library.") if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(TARGET_DIR ${LLVM_DEFAULT_TARGET_TRIPLE}) + set(LIBCXX_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE}) if(LIBCXX_LIBDIR_SUBDIR) - string(APPEND TARGET_DIR /${LIBCXX_LIBDIR_SUBDIR}) + string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR}) endif() - set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${TARGET_DIR}) + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBCXX_TARGET_SUBDIR}) set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1") - set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${TARGET_DIR}/c++/v1") - set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${TARGET_DIR} CACHE STRING + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1") + set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBCXX_TARGET_SUBDIR} CACHE STRING "Path where built libc++ libraries should be installed.") - set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${TARGET_DIR}/c++/v1" CACHE STRING + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LIBCXX_TARGET_SUBDIR}/c++/v1" CACHE STRING "Path where target-specific libc++ headers should be installed.") - unset(TARGET_DIR) + unset(LIBCXX_TARGET_SUBDIR) else() if(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index a799407d04e61..c39b4f432da1b 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -182,15 +182,15 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING "Path where built libc++abi runtime libraries should be installed.") if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(TARGET_DIR ${LLVM_DEFAULT_TARGET_TRIPLE}) + set(LIBCXXABI_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE}) if(LIBCXXABI_LIBDIR_SUBDIR) - string(APPEND TARGET_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) + string(APPEND LIBCXXABI_TARGET_SUBDIR /${LIBCXXABI_LIBDIR_SUBDIR}) endif() set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) - set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${TARGET_DIR}) - set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${TARGET_DIR} CACHE STRING + set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBCXXABI_TARGET_SUBDIR}) + set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBCXXABI_TARGET_SUBDIR} CACHE STRING "Path where built libc++abi libraries should be installed.") - unset(TARGET_DIR) + unset(LIBCXXABI_TARGET_SUBDIR) else() if(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 24acb3fd40d0d..23b567d5c8161 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -129,14 +129,14 @@ set(LIBUNWIND_SHARED_OUTPUT_NAME "unwind" CACHE STRING "Output name for the shar set(LIBUNWIND_STATIC_OUTPUT_NAME "unwind" CACHE STRING "Output name for the static libunwind runtime library.") if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(TARGET_DIR ${LLVM_DEFAULT_TARGET_TRIPLE}) + set(LIBUNWIND_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE}) if(LIBUNWIND_LIBDIR_SUBDIR) - string(APPEND TARGET_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) + string(APPEND LIBUNWIND_TARGET_SUBDIR /${LIBUNWIND_LIBDIR_SUBDIR}) endif() - set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${TARGET_DIR}) - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${TARGET_DIR} CACHE STRING + set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBUNWIND_TARGET_SUBDIR}) + set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBUNWIND_TARGET_SUBDIR} CACHE STRING "Path where built libunwind libraries should be installed.") - unset(TARGET_DIR) + unset(LIBUNWIND_TARGET_SUBDIR) else() if(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) diff --git a/llvm-libgcc/CMakeLists.txt b/llvm-libgcc/CMakeLists.txt index 76b3e3f6f7ddb..8e9685fab9feb 100644 --- a/llvm-libgcc/CMakeLists.txt +++ b/llvm-libgcc/CMakeLists.txt @@ -61,14 +61,14 @@ endif() #=============================================================================== if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(TARGET_DIR ${LLVM_DEFAULT_TARGET_TRIPLE}) + set(TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE}) if(LLVM_LIBGCC_LIBDIR_SUBDIR) - string(APPEND TARGET_DIR /${LLVM_LIBGCC_LIBDIR_SUBDIR}) + string(APPEND TARGET_SUBDIR /${LLVM_LIBGCC_LIBDIR_SUBDIR}) endif() - set(LLVM_LIBGCC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${TARGET_DIR}) - set(LLVM_LIBGCC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${TARGET_DIR} CACHE PATH + set(LLVM_LIBGCC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${TARGET_SUBDIR}) + set(LLVM_LIBGCC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${TARGET_SUBDIR} CACHE PATH "Path where built llvm-libgcc libraries should be installed.") - unset(TARGET_DIR) + unset(TARGET_SUBDIR) else() if(LLVM_LIBRARY_OUTPUT_INTDIR) set(LLVM_LIBGCC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits