Skip to content

Commit e066dea

Browse files
committed
Update Python and Clang on x86 dist images
LLVM 12 no longer builds with Python 2, so install Python 3 in preparatin. However, Clang 10 does not build with Python 3, so we need update to Clang 11 as well, which supports both. Unfortunately, doing so results in errors while linking the libLLVM.so into other binaries: > __morestack: invalid needed version 2 This is fixed by using LLD instead. Possibly this is due to a binutils linker bug, but updating to the latest binutils version does not fix it.
1 parent 7fba12b commit e066dea

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

src/bootstrap/native.rs

+3
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@ impl Step for Lld {
556556
t!(fs::create_dir_all(&out_dir));
557557

558558
let mut cfg = cmake::Config::new(builder.src.join("src/llvm-project/lld"));
559+
if let Some(ref linker) = builder.config.llvm_use_linker {
560+
cfg.define("LLVM_USE_LINKER", linker);
561+
}
559562
configure_cmake(builder, target, &mut cfg, true);
560563

561564
// This is an awful, awful hack. Discovered when we migrated to using

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ RUN ./build-binutils.sh
6868
COPY host-x86_64/dist-x86_64-linux/build-gcc.sh /tmp/
6969
RUN ./build-gcc.sh && apt-get remove -y gcc g++
7070

71-
# Debian 6 has Python 2.6 by default, but LLVM needs 2.7+
71+
# Debian 6 has Python 2.6 by default, but LLVM >= 12 needs Python 3
7272
COPY host-x86_64/dist-x86_64-linux/build-python.sh /tmp/
7373
RUN ./build-python.sh
7474

75-
# LLVM needs cmake 3.4.3 or higher, and is planning to raise to 3.13.4.
75+
# LLVM needs cmake 3.13.4 or higher
7676
COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/
7777
RUN ./build-cmake.sh
7878

@@ -94,8 +94,10 @@ ENV RUST_CONFIGURE_ARGS \
9494
--set target.i686-unknown-linux-gnu.linker=clang \
9595
--build=i686-unknown-linux-gnu \
9696
--set llvm.ninja=false \
97+
--set llvm.use-linker=lld \
98+
--set rust.use-lld=true \
9799
--set rust.jemalloc
98-
ENV SCRIPT python2.7 ../x.py dist --build $HOSTS --host $HOSTS --target $HOSTS
100+
ENV SCRIPT python3 ../x.py dist --build $HOSTS --host $HOSTS --target $HOSTS
99101
ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang
100102

101103
# This was added when we switched from gcc to clang. It's not clear why this is

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ RUN ./build-binutils.sh
6868
COPY host-x86_64/dist-x86_64-linux/build-gcc.sh /tmp/
6969
RUN ./build-gcc.sh && apt-get remove -y gcc g++
7070

71-
# Debian 6 has Python 2.6 by default, but LLVM needs 2.7+
71+
# Debian 6 has Python 2.6 by default, but LLVM >= 12 needs Python 3
7272
COPY host-x86_64/dist-x86_64-linux/build-python.sh /tmp/
7373
RUN ./build-python.sh
7474

75-
# LLVM needs cmake 3.4.3 or higher, and is planning to raise to 3.13.4.
75+
# LLVM needs cmake 3.13.4 or higher
7676
COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/
7777
RUN ./build-cmake.sh
7878

@@ -99,8 +99,10 @@ ENV RUST_CONFIGURE_ARGS \
9999
--set target.x86_64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \
100100
--set llvm.thin-lto=true \
101101
--set llvm.ninja=false \
102+
--set llvm.use-linker=lld \
103+
--set rust.use-lld=true \
102104
--set rust.jemalloc
103-
ENV SCRIPT ../src/ci/pgo.sh python2.7 ../x.py dist \
105+
ENV SCRIPT ../src/ci/pgo.sh python3 ../x.py dist \
104106
--host $HOSTS --target $HOSTS \
105107
--include-default-paths \
106108
src/tools/build-manifest

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -ex
44

55
source shared.sh
66

7-
LLVM=llvmorg-10.0.0
7+
LLVM=llvmorg-11.0.1
88

99
mkdir llvm-project
1010
cd llvm-project

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -ex
44
source shared.sh
55

6-
curl https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz | \
6+
curl https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz | \
77
tar xzf -
88

99
mkdir python-build
@@ -12,10 +12,10 @@ cd python-build
1212
# Gotta do some hackery to tell python about our custom OpenSSL build, but other
1313
# than that fairly normal.
1414
CFLAGS='-I /rustroot/include' LDFLAGS='-L /rustroot/lib -L /rustroot/lib64' \
15-
hide_output ../Python-2.7.12/configure --prefix=/rustroot
15+
hide_output ../Python-3.9.1/configure --prefix=/rustroot
1616
hide_output make -j10
1717
hide_output make install
1818

1919
cd ..
2020
rm -rf python-build
21-
rm -rf Python-2.7.12
21+
rm -rf Python-3.9.1

src/ci/pgo.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euxo pipefail
44

55
rm -rf /tmp/rustc-pgo
66

7-
python2.7 ../x.py build --target=$PGO_HOST --host=$PGO_HOST \
7+
python3 ../x.py build --target=$PGO_HOST --host=$PGO_HOST \
88
--stage 2 library/std --rust-profile-generate=/tmp/rustc-pgo
99

1010
./build/$PGO_HOST/stage2/bin/rustc --edition=2018 \

0 commit comments

Comments
 (0)