Skip to content

Conversation

@tambry
Copy link
Contributor

@tambry tambry commented Sep 16, 2025

This code in principle needs to match the one in libc++ but hasn't been updated to account for LIBCXX_LIBDIR_SUBDIR so tests don't work if LLVM is built with it specified.

This functionality is chiefly used by LLVM_RUNTIME_MULTILIBS support so the library path might end up as /usr/lib/llvm-22/lib/x86_64-unknown-linux-gnu/hwasan/libc++.so.1 instead of /usr/lib/llvm-22/lib/x86_64-unknown-linux-gnu/libc++.so.1.

In my downstream I however (ab)use this same functionality to install the libraries into Debian-style triple directories instead of the quadruples that LLVM nowadays prefers (hence the normalization I added).

Fixes: ed155f3

This code in principle needs to match the one in libc++ but hasn't been updated to account for
LIBCXX_LIBDIR_SUBDIR so tests don't work if LLVM is built with it specified.

Fixes: ed155f3
@tambry tambry self-assigned this Sep 16, 2025
@tambry tambry added the cmake Build system in general and CMake in particular label Sep 16, 2025
@llvmbot llvmbot added the lldb label Sep 16, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 16, 2025

@llvm/pr-subscribers-lldb

Author: Raul Tambre (tambry)

Changes

This code in principle needs to match the one in libc++ but hasn't been updated to account for LIBCXX_LIBDIR_SUBDIR so tests don't work if LLVM is built with it specified.

Fixes: ed155f3


Full diff: https://github.com/llvm/llvm-project/pull/159106.diff

2 Files Affected:

  • (modified) lldb/test/CMakeLists.txt (+7-2)
  • (modified) lldb/utils/lldb-dotest/CMakeLists.txt (+7-2)
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 8116f4c3c823a..513d1ec493ee1 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -164,9 +164,14 @@ if(TARGET clang)
   if (TARGET libcxx OR ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES))
     set(LLDB_HAS_LIBCXX ON)
     if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-      set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
+      set(LIBCXX_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
+      if(LIBCXX_LIBDIR_SUBDIR)
+        string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR})
+      endif()
+      cmake_path(NORMAL_PATH LIBCXX_TARGET_SUBDIR)
+      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_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
+      set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/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")
diff --git a/lldb/utils/lldb-dotest/CMakeLists.txt b/lldb/utils/lldb-dotest/CMakeLists.txt
index 3b8c88b6dc78c..f3f75015637f4 100644
--- a/lldb/utils/lldb-dotest/CMakeLists.txt
+++ b/lldb/utils/lldb-dotest/CMakeLists.txt
@@ -15,9 +15,14 @@ llvm_canonicalize_cmake_booleans(
 if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
   set(LLDB_HAS_LIBCXX ON)
   if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-    set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
+    set(LIBCXX_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
+    if(LIBCXX_LIBDIR_SUBDIR)
+      string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR})
+    endif()
+    cmake_path(NORMAL_PATH LIBCXX_TARGET_SUBDIR)
+    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_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
+    set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/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")

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me. Could you update the PR description with an example of what the paths would look like in the case where LIBCXX_TARGET_SUBDIR is specified?

@tambry
Copy link
Contributor Author

tambry commented Sep 22, 2025

@Michael137 Added an example in the description. In-tree it's used by Fucshia for multilib runtimes but I myself use them in my downstream to install the libraries into Debian-style triple system directories instead of LLVM's own quadruple-based structure.

Ideally this same logic would be included from libc++ itself but LLVM CMake code in general is quite entangled it's hard to tell how this could even be shared. 😕

@tambry tambry merged commit c520531 into llvm:main Sep 24, 2025
12 checks passed
@tambry tambry deleted the lldb_libcxx_target_subdir branch September 24, 2025 11:42
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 24, 2025

LLVM Buildbot has detected a new failure on builder lldb-arm-ubuntu running on linaro-lldb-arm-ubuntu while building lldb at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/21441

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-unit :: Core/./LLDBCoreTests/96/470 (2447 of 3681)
PASS: lldb-unit :: Core/./LLDBCoreTests/99/470 (2448 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/0/76 (2449 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/1/76 (2450 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/12/76 (2451 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/13/76 (2452 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/14/76 (2453 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/15/76 (2454 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/16/76 (2455 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/17/76 (2456 of 3681)
FAIL: lldb-unit :: DAP/./DAPTests/10/76 (2457 of 3681)
******************** TEST 'lldb-unit :: DAP/./DAPTests/10/76' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/unittests/DAP/./DAPTests-lldb-unit-500707-10-76.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=76 GTEST_SHARD_INDEX=10 /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/unittests/DAP/./DAPTests
--

Script:
--
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/unittests/DAP/./DAPTests --gtest_filter=DisconnectRequestHandlerTest.DisconnectTriggersTerminateCommands
--
../llvm-project/lldb/unittests/DAP/Handler/DisconnectTest.cpp:51: Failure
Actual function call count doesn't match EXPECT_CALL(client, Received(Output("1\n")))...
         Expected: to be called once
           Actual: never called - unsatisfied and active

../llvm-project/lldb/unittests/DAP/Handler/DisconnectTest.cpp:52: Failure
Actual function call count doesn't match EXPECT_CALL(client, Received(Output("2\n")))...
         Expected: to be called twice
           Actual: called once - unsatisfied and active


../llvm-project/lldb/unittests/DAP/Handler/DisconnectTest.cpp:51
Actual function call count doesn't match EXPECT_CALL(client, Received(Output("1\n")))...
         Expected: to be called once
           Actual: never called - unsatisfied and active

../llvm-project/lldb/unittests/DAP/Handler/DisconnectTest.cpp:52
Actual function call count doesn't match EXPECT_CALL(client, Received(Output("2\n")))...
         Expected: to be called twice
           Actual: called once - unsatisfied and active



********************
PASS: lldb-unit :: DAP/./DAPTests/18/76 (2458 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/19/76 (2459 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/11/76 (2460 of 3681)
PASS: lldb-unit :: DAP/./DAPTests/20/76 (2461 of 3681)

mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
This code in principle needs to match the one in libc++ but hasn't been updated to account for
LIBCXX_LIBDIR_SUBDIR so tests don't work if LLVM is built with it specified.

Fixes: ed155f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmake Build system in general and CMake in particular lldb

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants