Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler-rt] Use installed libc++(abi) for tests instead of build tree #115077

Conversation

arichardson
Copy link
Member

Using the build tree is somewhat fragile since the layout is not
guaranteed to be stable and means the tests are tightly coupled to the
libc++/libc++abi build tree layout. Instead update the ExternalProject
to install the library and headers and do not add the build tree to
the include/linker flags.

Created using spr 1.3.6-beta.1
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Alexander Richardson (arichardson)

Changes

Using the build tree is somewhat fragile since the layout is not
guaranteed to be stable and means the tests are tightly coupled to the
libc++/libc++abi build tree layout. Instead update the ExternalProject
to install the library and headers and do not add the build tree to
the include/linker flags.


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

5 Files Affected:

  • (modified) compiler-rt/cmake/Modules/AddCompilerRT.cmake (+7-5)
  • (modified) compiler-rt/lib/fuzzer/CMakeLists.txt (+3-3)
  • (modified) compiler-rt/lib/fuzzer/tests/CMakeLists.txt (+1-1)
  • (modified) compiler-rt/lib/msan/tests/CMakeLists.txt (+4-4)
  • (modified) compiler-rt/lib/tsan/CMakeLists.txt (+1-1)
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index bfa1834229baab..abbeea0c493a75 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -680,15 +680,16 @@ macro(add_custom_libcxx name prefix)
 
   ExternalProject_Add(${name}
     DEPENDS ${name}-clobber ${LIBCXX_DEPS}
-    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/${name}
+    PREFIX ${prefix}
     SOURCE_DIR ${LLVM_MAIN_SRC_DIR}/../runtimes
-    BINARY_DIR ${prefix}
+    BINARY_DIR ${prefix}/build
     CMAKE_ARGS ${CMAKE_PASSTHROUGH_VARIABLES}
                ${compiler_args}
                ${verbose}
                -DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS}
                -DCMAKE_CXX_FLAGS=${LIBCXX_CXX_FLAGS}
                -DCMAKE_BUILD_TYPE=Release
+               -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
                -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
                -DLLVM_ENABLE_RUNTIMES=libcxx|libcxxabi
                -DLIBCXXABI_USE_LLVM_UNWINDER=OFF
@@ -701,16 +702,17 @@ macro(add_custom_libcxx name prefix)
                -DLIBCXX_INCLUDE_BENCHMARKS=OFF
                -DLIBCXX_INCLUDE_TESTS=OFF
                -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
+               -DLLVM_INCLUDE_TESTS=OFF
+               -DLLVM_INCLUDE_DOCS=OFF
                ${LIBCXX_CMAKE_ARGS}
-    INSTALL_COMMAND ""
-    STEP_TARGETS configure build
+    STEP_TARGETS configure build install
     BUILD_ALWAYS 1
     USES_TERMINAL_CONFIGURE 1
     USES_TERMINAL_BUILD 1
     USES_TERMINAL_INSTALL 1
     LIST_SEPARATOR |
     EXCLUDE_FROM_ALL TRUE
-    BUILD_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
+    INSTALL_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
     )
 
   if (CMAKE_GENERATOR MATCHES "Make")
diff --git a/compiler-rt/lib/fuzzer/CMakeLists.txt b/compiler-rt/lib/fuzzer/CMakeLists.txt
index fb5adf1e5c9e69..a6175564e55a20 100644
--- a/compiler-rt/lib/fuzzer/CMakeLists.txt
+++ b/compiler-rt/lib/fuzzer/CMakeLists.txt
@@ -166,11 +166,11 @@ if(OS_NAME MATCHES "Android|Linux|Fuchsia" AND
                  -DLIBCXX_ABI_NAMESPACE=__Fuzzer
                  -DLIBCXX_ENABLE_EXCEPTIONS=OFF)
     target_compile_options(RTfuzzer.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
-    add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-build)
+    add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-install)
     target_compile_options(RTfuzzer_main.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
-    add_dependencies(RTfuzzer_main.${arch} libcxx_fuzzer_${arch}-build)
+    add_dependencies(RTfuzzer_main.${arch} libcxx_fuzzer_${arch}-install)
     target_compile_options(RTfuzzer_interceptors.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
-    add_dependencies(RTfuzzer_interceptors.${arch} libcxx_fuzzer_${arch}-build)
+    add_dependencies(RTfuzzer_interceptors.${arch} libcxx_fuzzer_${arch}-install)
     partially_link_libcxx(fuzzer_no_main ${LIBCXX_${arch}_PREFIX} ${arch})
     partially_link_libcxx(fuzzer_interceptors ${LIBCXX_${arch}_PREFIX} ${arch})
     partially_link_libcxx(fuzzer ${LIBCXX_${arch}_PREFIX} ${arch})
diff --git a/compiler-rt/lib/fuzzer/tests/CMakeLists.txt b/compiler-rt/lib/fuzzer/tests/CMakeLists.txt
index 5086c0334b22be..73ebc135312090 100644
--- a/compiler-rt/lib/fuzzer/tests/CMakeLists.txt
+++ b/compiler-rt/lib/fuzzer/tests/CMakeLists.txt
@@ -64,7 +64,7 @@ if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST FUZZER_SUPPORTED_ARCH)
      COMPILER_RT_LIBCXX_PATH AND
      COMPILER_RT_LIBCXXABI_PATH)
     file(GLOB libfuzzer_headers ../*.h)
-    set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-build ${libfuzzer_headers})
+    set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-install ${libfuzzer_headers})
     set(LIBFUZZER_TEST_RUNTIME_CFLAGS -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
     set(LIBFUZZER_TEST_RUNTIME_LINK_FLAGS ${LIBCXX_${arch}_PREFIX}/lib/libc++.a)
   endif()
diff --git a/compiler-rt/lib/msan/tests/CMakeLists.txt b/compiler-rt/lib/msan/tests/CMakeLists.txt
index e0771dd5a1a7e1..3ddae6d08b7f67 100644
--- a/compiler-rt/lib/msan/tests/CMakeLists.txt
+++ b/compiler-rt/lib/msan/tests/CMakeLists.txt
@@ -69,7 +69,7 @@ macro(msan_compile obj_list source arch kind cflags)
   sanitizer_test_compile(
     ${obj_list} ${source} ${arch}
     KIND ${kind}
-    COMPILE_DEPS ${MSAN_UNITTEST_HEADERS} libcxx_msan_${arch}-build
+    COMPILE_DEPS ${MSAN_UNITTEST_HEADERS} libcxx_msan_${arch}-install
     DEPS msan
     CFLAGS -isystem ${MSAN_LIBCXX_DIR}/../include/c++/v1
            ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${cflags}
@@ -117,10 +117,10 @@ macro(add_msan_tests_for_arch arch kind cflags)
                    DEPS ${MSAN_INST_LOADABLE_OBJECTS})
 
   set(MSAN_TEST_OBJECTS ${MSAN_INST_TEST_OBJECTS} ${MSAN_INST_GTEST})
-  set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-build
+  set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-install
                      ${MSAN_LOADABLE_SO}
-		     "${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a")
-  list(APPEND MSAN_TEST_DEPS msan libcxx_msan_${arch}-build)
+                     "${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a")
+  list(APPEND MSAN_TEST_DEPS msan libcxx_msan_${arch}-install)
   get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
   add_compiler_rt_test(MsanUnitTests "Msan-${arch}${kind}-Test" ${arch}
     OBJECTS ${MSAN_TEST_OBJECTS} "${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a"
diff --git a/compiler-rt/lib/tsan/CMakeLists.txt b/compiler-rt/lib/tsan/CMakeLists.txt
index e192506f0c9358..f7e2b5b6a35631 100644
--- a/compiler-rt/lib/tsan/CMakeLists.txt
+++ b/compiler-rt/lib/tsan/CMakeLists.txt
@@ -31,7 +31,7 @@ if(COMPILER_RT_LIBCXX_PATH AND
       DEPS ${TSAN_RUNTIME_LIBRARIES}
       CFLAGS ${TARGET_CFLAGS} -fsanitize=thread
       USE_TOOLCHAIN)
-    list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-build)
+    list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-install)
   endforeach()
 
   add_custom_target(libcxx_tsan DEPENDS ${libcxx_tsan_deps})

@arichardson
Copy link
Member Author

See also #110171, #96910. I think this should also allow for future cleanup such as not copying the libc++abi headers to another directory during build.

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

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

I'm not very familiar with the compiler-rt build, but I love this in principle.

We shouldn't be making assumptions about the internal state of a project's build outside of that project itself. The "public" interface of libc++ is the installation step so that's the only thing we should be using from compiler-rt.

Thanks for this cleanup!

@arichardson arichardson merged commit e7bad34 into main Nov 6, 2024
13 checks passed
@arichardson arichardson deleted the users/arichardson/spr/compiler-rt-use-installed-libcabi-for-tests-instead-of-build-tree branch November 6, 2024 19:57
arichardson added a commit that referenced this pull request Nov 6, 2024
This was needed before #115077
since the compiler-rt test build made assumptions about the build
layout of libc++ and libc++abi, but now they link against a local
installation of these libraries so we no longer need this workaround.

Reviewed By: ldionne

Pull Request: #115086
SOURCE_DIR ${LLVM_MAIN_SRC_DIR}/../runtimes
BINARY_DIR ${prefix}
BINARY_DIR ${prefix}/build
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this an expected change? If so, doesn't that mean the -isystem path in fuzzer's CMakeLists.txt should include the /build/ prefix?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the install directory is ${prefix}, so it uses the installed headers now instead of the build tree.

Copy link
Contributor

Choose a reason for hiding this comment

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

So adding the /build suffix is intended then? We're seeing issues where certain C++ headers aren't found and it looks like someone else has commented the same as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes this is intentional - and the dependency for RTFuzzer is still there so I am not sure why it is failing for you:

    target_compile_options(RTfuzzer.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
    add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-install)

Copy link
Contributor

@thevinster thevinster Nov 7, 2024

Choose a reason for hiding this comment

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

Yes I saw that. In our case, the headers were defined under ${LIBCXX_${arch}_PREFIX}/build/include/c++/v1, hence my suspicion on /build whether that was intentional. But perhaps, it might a configuration issue on our end. For now, I've disabled building fuzzer since it's not needed for our internal workloads.

@mikaelholmen
Copy link
Collaborator

Any idea if there is a possibility/risk that this patch introduces some race condition so some files might be used before they're installed?

The reason I'm asking is that we now sometimes see errors like
compiler-rt/lib/fuzzer/FuzzerExtraCountersWindows.cpp:12:10: fatal error: 'cstdint' file not found

@arichardson
Copy link
Member Author

Any idea if there is a possibility/risk that this patch introduces some race condition so some files might be used before they're installed?

The reason I'm asking is that we now sometimes see errors like compiler-rt/lib/fuzzer/FuzzerExtraCountersWindows.cpp:12:10: fatal error: 'cstdint' file not found

There shouldn't be, but I'll take a look if there are some missing dependencies.

@arichardson
Copy link
Member Author

Any idea if there is a possibility/risk that this patch introduces some race condition so some files might be used before they're installed?

The reason I'm asking is that we now sometimes see errors like compiler-rt/lib/fuzzer/FuzzerExtraCountersWindows.cpp:12:10: fatal error: 'cstdint' file not found

@mikaelholmen @thevinster Do you have a build log/cmake command that shows this issue? I am unable to reproduce this and CMake appears to have all the required dependencies.

@arichardson
Copy link
Member Author

I just looked at the generated build.ninja and there is definitely a dependency from
compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtraCountersWindows.cpp.o to compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64-install

arichardson added a commit that referenced this pull request Nov 7, 2024
This was needed before #115077
since the compiler-rt test build made assumptions about the build
layout of libc++ and libc++abi, but now they link against a local
installation of these libraries so we no longer need this workaround.

The last attempt at landing this was reverted due to buildbot failures
which should be fixed by llvm/llvm-zorg#299.

Pull Request: #115379
@bjope
Copy link
Collaborator

bjope commented Nov 8, 2024

@mikaelholmen @thevinster Do you have a build log/cmake command that shows this issue? I am unable to reproduce this and CMake appears to have all the required dependencies.

Here is the scenario (from @mikaelholmen):

cmake command: CC='/mygcc/1.9.3.0-1/crosscompiler/bin/gcc' CXX='/mygcc/1.9.3.0-1/crosscompiler/bin/g++' /bin/cmake /repo/llvm --debug-trycompile -G Ninja -DCMAKE_MAKE_PROGRAM=ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=/compiler-clang -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lld' -DLLVM_USE_LINKER=gold -DLLVM_BUILTIN_TARGETS='x86_64-unknown-linux-gnu' -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind;compiler-rt' -DRUNTIMES_x86_64-unknown-linux-gnu_SANITIZER_USE_STATIC_LLVM_UNWINDER=ON -DRUNTIMES_x86_64-unknown-linux-gnu_SANITIZER_USE_STATIC_CXX_ABI=ON -DRUNTIMES_x86_64-unknown-linux-gnu_COMPILER_RT_USE_BUILTINS_LIBRARY=ON  -DRUNTIMES_x86_64-unknown-linux-gnu_CMAKE_CXX_FLAGS='--gcc-toolchain=/mygcc/1.9.3.0-1/crosscompiler' -DRUNTIMES_x86_64-unknown-linux-gnu_SANITIZER_TEST_CXX=libstdc++ -DRUNTIMES_x86_64-unknown-linux-gnu_LIBCXX_USE_COMPILER_RT=ON -DRUNTIMES_x86_64-unknown-linux-gnu_LIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON -DRUNTIMES_x86_64-unknown-linux-gnu_LIBCXXABI_USE_LLVM_UNWINDER=ON -DRUNTIMES_x86_64-unknown-linux-gnu_LIBCXXABI_ENABLE_STATIC_UNWINDER=ON -DRUNTIMES_x86_64-unknown-linux-gnu_LIBCXXABI_USE_COMPILER_RT=ON -DRUNTIMES_x86_64-unknown-linux-gnu_LIBUNWIND_USE_COMPILER_RT=ON -DRUNTIMES_x86_64-unknown-linux-gnu_LIBCXX_TEST_PARAMS='enable_experimental=False' -DRUNTIMES_x86_64-unknown-linux-gnu_LIBCXXABI_TEST_PARAMS='enable_experimental=False' -DRUNTIMES_x86_64-unknown-linux-gnu_COMPILER_RT_CAN_EXECUTE_TESTS=OFF -DLLVM_RUNTIME_TARGETS='x86_64-unknown-linux-gnu' -DLLVM_STATIC_LINK_CXX_STDLIB=ON

...
-- Build files have been written to: /repo/llvm/build-all
cd /repo
DESTDIR=/tmp/tmp.3hBN2EZpSo /ninja/1.10.2/bin/ninja -j56 -C llvm/build-all  -v install-runtimes
ninja: Entering directory `llvm/build-all'
...

[35/60] Performing install step for 'libcxx_fuzzer_x86_64'
[0/1] Install the project...
-- Install configuration: "Release"
...
-- Installing: /tmp/tmp.3hBN2EZpSo/repo/llvm/build-all/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/include/c++/v1/cstdint
...
[37/60] Building CXX object compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtraCountersWindows.cpp.o
FAILED: compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtraCountersWindows.cpp.o 
/repo/llvm/build-all/./bin/clang++ --target=x86_64-unknown-linux-gnu -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/repo/compiler-rt/lib/fuzzer/../../include --gcc-toolchain=/mygcc/1.9.3.0-1/crosscompiler -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wno-unused-parameter -O3 -DNDEBUG -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -ftrivial-auto-var-init=pattern -D_LIBCPP_ABI_VERSION=Fuzzer -nostdinc++ -fno-omit-frame-pointer -isystem /repo/llvm/build-all/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/include/c++/v1 -std=c++17 -MD -MT compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtraCountersWindows.cpp.o -MF compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtraCountersWindows.cpp.o.d -o compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtraCountersWindows.cpp.o -c /repo/compiler-rt/lib/fuzzer/FuzzerExtraCountersWindows.cpp
/repo/compiler-rt/lib/fuzzer/FuzzerExtraCountersWindows.cpp:12:10: fatal error: 'cstdint' file not found
   12 | #include <cstdint>
      |          ^~~~~~~~~
1 error generated.

So the install step is installing cstdint in
/tmp/tmp.3hBN2EZpSo/repo/llvm/build-all/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/include/c++/v1/cstdint
given the DESTDIR setting.

But then when building FuzzerExtraCountersWindows.cpp we find
-isystem /repo/llvm/build-all/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/include/c++/v1
but that path does not exist.

When searching the build dir I find:

> find  build-all/ -name cstdint
build-all/include/c++/v1/cstdint
build-all/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/build/include/c++/v1/cstdint

But I guess the goal was to use a path to the just installed version here (from the DESTDIR)?

@bjope
Copy link
Collaborator

bjope commented Nov 8, 2024

But I guess the goal was to use a path to the just installed version here (from the DESTDIR)?

Or should the isystem paths setup by compiler-rt/lib/fuzzer/CMakeLists.txt use .../build/include/c++/v1 now?

@bjope
Copy link
Collaborator

bjope commented Nov 8, 2024

But I guess the goal was to use a path to the just installed version here (from the DESTDIR)?

Or should the isystem paths setup by compiler-rt/lib/fuzzer/CMakeLists.txt use .../build/include/c++/v1 now?

Btw, it doesn't seem to be enough to change the isystem paths. Then it ends up with
clang++: error: no such file or directory: '/repo/llvm/build-all/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a'
So there are more paths that are wrong if this is the way forward. Maybe something like this:

-    partially_link_libcxx(fuzzer_no_main ${LIBCXX_${arch}_PREFIX} ${arch})
-    partially_link_libcxx(fuzzer_interceptors ${LIBCXX_${arch}_PREFIX} ${arch})
-    partially_link_libcxx(fuzzer ${LIBCXX_${arch}_PREFIX} ${arch})
+   partially_link_libcxx(fuzzer_no_main ${LIBCXX_${arch}_PREFIX}/build ${arch})
+   partially_link_libcxx(fuzzer_interceptors ${LIBCXX_${arch}_PREFIX}/build ${arch})
+   partially_link_libcxx(fuzzer ${LIBCXX_${arch}_PREFIX}/build ${arch})

@bjope
Copy link
Collaborator

bjope commented Nov 8, 2024

But I guess the goal was to use a path to the just installed version here (from the DESTDIR)?

Or should the isystem paths setup by compiler-rt/lib/fuzzer/CMakeLists.txt use .../build/include/c++/v1 now?

Btw, it doesn't seem to be enough to change the isystem paths.

Maybe it is more correct to do:

- set(LIBCXX_${arch}_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libcxx_fuzzer_${arch})
+ set(LIBCXX_${arch}_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libcxx_fuzzer_${arch}/build)

@arichardson
Copy link
Member Author

We should not be using the headers from the build dir, this will be removed in #115380 . It sounds to me that the problem is DESTDIR being set while building since that affects the destination of the local libc++ installation. I'll see if I can make the ExternalProject_add() call ignore DESTDIR.

@arichardson
Copy link
Member Author

As can be seen from your log: /tmp/tmp.3hBN2EZpSo/repo/llvm/build-all/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/include/c++/v1/cstdint
Should not be used, it should be installing to the build directory instead.

@arichardson
Copy link
Member Author

Sounds like I need to override the install command to clear DESTDIR: https://gitlab.kitware.com/cmake/cmake/-/issues/18165

@arichardson
Copy link
Member Author

@bjope this should be fixed by #115525.

arichardson added a commit that referenced this pull request Nov 8, 2024
If DESTDIR is set in the environment during the build/test stage, the
local libc++ installation will be installed under DESTDIR instead of being
in the build directory.

See #115077 (comment)
and https://gitlab.kitware.com/cmake/cmake/-/issues/18165.

Pull Request: #115525
Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
This was needed before llvm#115077
since the compiler-rt test build made assumptions about the build
layout of libc++ and libc++abi, but now they link against a local
installation of these libraries so we no longer need this workaround.

The last attempt at landing this was reverted due to buildbot failures
which should be fixed by llvm/llvm-zorg#299.

Pull Request: llvm#115379
Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
If DESTDIR is set in the environment during the build/test stage, the
local libc++ installation will be installed under DESTDIR instead of being
in the build directory.

See llvm#115077 (comment)
and https://gitlab.kitware.com/cmake/cmake/-/issues/18165.

Pull Request: llvm#115525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants