Add LTO support to clang in CI · rust-lang/rust@9e57593 (original) (raw)

File tree

4 files changed

lines changed

4 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@ COPY host-x86_64/dist-x86_64-linux/shared.sh /tmp/
50 50
51 51 # Need at least GCC 5.1 to compile LLVM nowadays
52 52 COPY host-x86_64/dist-x86_64-linux/build-gcc.sh /tmp/
53 +ENV GCC_VERSION=9.5.0
53 54 RUN ./build-gcc.sh && yum remove -y gcc gcc-c++
54 55
55 56 COPY scripts/cmake.sh /tmp/
Original file line number Diff line number Diff line change
@@ -44,12 +44,14 @@ RUN mkdir -p /rustroot/bin
44 44 ENV PATH=/rustroot/bin:$PATH
45 45 ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib32:/rustroot/lib
46 46 ENV PKG_CONFIG_PATH=/rustroot/lib/pkgconfig
47 +# Clang needs to access GCC headers to enable linker plugin LTO
47 48 WORKDIR /tmp
48 49 RUN mkdir /home/user
49 50 COPY host-x86_64/dist-x86_64-linux/shared.sh /tmp/
50 51
51 52 # Need at least GCC 5.1 to compile LLVM nowadays
52 53 COPY host-x86_64/dist-x86_64-linux/build-gcc.sh /tmp/
54 +ENV GCC_VERSION=9.5.0
53 55 RUN ./build-gcc.sh && yum remove -y gcc gcc-c++
54 56
55 57 # LLVM 17 needs cmake 3.20 or higher.
@@ -104,3 +106,7 @@ ENV DIST_SRC 1
104 106 ENV LIBCURL_NO_PKG_CONFIG 1
105 107
106 108 ENV DIST_REQUIRE_ALL_TOOLS 1
109 +
110 +# FIXME: Without this, LLVMgold.so incorrectly resolves to the system
111 +# libstdc++, instead of the one we build.
112 +ENV LD_PRELOAD=/rustroot/lib64/libstdc++.so.6
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ hide_output \
39 39 -DLLVM_INCLUDE_TESTS=OFF \
40 40 -DLLVM_INCLUDE_EXAMPLES=OFF \
41 41 -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;bolt" \
42 + -DLLVM_BINUTILS_INCDIR="/rustroot/lib/gcc/x86_64-pc-linux-gnu/$GCC_VERSION/plugin/include/" \
42 43 -DC_INCLUDE_DIRS="$INC"
43 44
44 45 hide_output make -j$(nproc)
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
1 1 #!/usr/bin/env bash
2 -set -ex
2 +set -eux
3 3
4 4 source shared.sh
5 5
6 6 # Note: in the future when bumping to version 10.1.0, also take care of the sed block below.
7 -GCC=9.5.0
7 +# This version is specified in the Dockerfile
8 +GCC=$GCC_VERSION
8 9
9 10 curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.xz | xzcat tar xf -
10 11 cd gcc-$GCC