Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 489bb36

Browse files
committedDec 23, 2024
Auto merge of rust-lang#134690 - clubby789:ci-clang-lto, r=<try>
CI: Add LTO support to clang in dist-x86_64-linux After rust-lang/cc-rs#1279, we attempt to pass `-flto=thin` to clang. In `dist-x86_64-linux`, we don't build clang with the `LLVMgold.so` library so this fails. This attempts to resolve this First, pass the binutils plugin include directory to Clang, [which will build the library](https://github.com/llvm/llvm-project/blob/2d6d723a85c2d007b0359c206d66cd2e5a9f00e1/llvm/docs/GoldPlugin.rst#how-to-build-it) Second, this library depends on the *version of libstdc++ that we built* specifically. However, despite both the RPATH and LD_LIBRARY_PATH pointing to `/rustroot/lib`, we incorrectly resolve to the system libstdc++, which doesn't load. ``` # LD_DEBUG=libs,files 2219: file=libstdc++.so.6 [0]; needed by /rustroot/bin/../lib/LLVMgold.so [0] 2219: find library=libstdc++.so.6 [0]; searching 2219: search path=/rustroot/bin/../lib/../lib (RPATH from file /rustroot/bin/../lib/LLVMgold.so) 2219: trying file=/rustroot/bin/../lib/../lib/libstdc++.so.6 2219: search path=/usr/lib64/tls:/usr/lib64 (system search path) 2219: trying file=/usr/lib64/tls/libstdc++.so.6 2219: trying file=/usr/lib64/libstdc++.so.6 ``` Using `LD_PRELOAD` causes it to correctly load the library I think this is probably not the most maintainable way to do this, so opening to see if this is desired and if there's a better way of doing this
2 parents 904d8f6 + 7f7cd6e commit 489bb36

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
 

‎src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,5 @@ ENV DIST_SRC 1
104104
ENV LIBCURL_NO_PKG_CONFIG 1
105105

106106
ENV DIST_REQUIRE_ALL_TOOLS 1
107+
108+
ENV LD_PRELOAD=/rustroot/lib64/libstdc++.so.6

‎src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ hide_output \
3939
-DLLVM_INCLUDE_TESTS=OFF \
4040
-DLLVM_INCLUDE_EXAMPLES=OFF \
4141
-DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;bolt" \
42+
-DLLVM_BINUTILS_INCDIR="/rustroot/lib/gcc/x86_64-pc-linux-gnu/9.5.0/plugin/include/" \
4243
-DC_INCLUDE_DIRS="$INC"
4344

4445
hide_output make -j$(nproc)

0 commit comments

Comments
 (0)
Failed to load comments.