]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile
Auto merge of #99181 - lcnr:arenaGTrc, r=wesleywiser
[rust.git] / src / ci / docker / host-x86_64 / dist-x86_64-linux / Dockerfile
1 # We need recent curl, OpenSSL and CA certificates, so we can download further
2 # dependencies in the debian:6 image. We use an ubuntu 20.04 image download
3 # those.
4 FROM ubuntu:20.04
5 RUN apt-get update && \
6     apt-get install -y --no-install-recommends \
7         curl \
8         ca-certificates
9 WORKDIR /tmp
10 COPY host-x86_64/dist-x86_64-linux/download-openssl-curl.sh /tmp/
11 RUN ./download-openssl-curl.sh
12
13 # We use Debian 6 (glibc 2.11, kernel 2.6.32) as a common base for other
14 # distros that still need Rust support: RHEL 6 (glibc 2.12, kernel 2.6.32) and
15 # SLES 11 SP4 (glibc 2.11, kernel 3.0).
16 FROM debian:6
17
18 WORKDIR /build
19
20 # Debian 6 is EOL and no longer available from the usual mirrors,
21 # so we'll need to switch to http://archive.debian.org/
22 RUN sed -i '/updates/d' /etc/apt/sources.list && \
23     sed -i 's/httpredir/archive/' /etc/apt/sources.list
24
25 RUN apt-get update && \
26     apt-get install --allow-unauthenticated -y --no-install-recommends \
27       automake \
28       bzip2 \
29       file \
30       g++ \
31       g++-multilib \
32       gcc \
33       gcc-multilib \
34       git \
35       lib32z1-dev \
36       libedit-dev \
37       libncurses-dev \
38       make \
39       patch \
40       perl \
41       pkg-config \
42       unzip \
43       wget \
44       xz-utils \
45       zlib1g-dev
46
47 ENV PATH=/rustroot/bin:$PATH
48 ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib32:/rustroot/lib
49 ENV PKG_CONFIG_PATH=/rustroot/lib/pkgconfig
50 WORKDIR /tmp
51 RUN mkdir /home/user
52 COPY host-x86_64/dist-x86_64-linux/shared.sh /tmp/
53
54 # We need a build of openssl which supports SNI to download artifacts from
55 # static.rust-lang.org. This'll be used to link into libcurl below (and used
56 # later as well), so build a copy of OpenSSL with dynamic libraries into our
57 # generic root.
58 COPY --from=0 /tmp/openssl.tar.gz /tmp/openssl.tar.gz
59 COPY host-x86_64/dist-x86_64-linux/build-openssl.sh /tmp/
60 RUN ./build-openssl.sh
61
62 # The `curl` binary on Debian 6 doesn't support SNI which is needed for fetching
63 # some https urls we have, so install a new version of libcurl + curl which is
64 # using the openssl we just built previously.
65 #
66 # Note that we also disable a bunch of optional features of curl that we don't
67 # really need.
68 COPY --from=0 /tmp/curl.tar.xz /tmp/curl.tar.xz
69 COPY host-x86_64/dist-x86_64-linux/build-curl.sh /tmp/
70 RUN ./build-curl.sh
71
72 # Use up-to-date curl CA bundle
73 COPY --from=0 /tmp/cacert.pem /tmp/cacert.pem
74 ENV CURL_CA_BUNDLE /tmp/cacert.pem
75
76 # binutils < 2.22 has a bug where the 32-bit executables it generates
77 # immediately segfault in Rust, so we need to install our own binutils.
78 #
79 # See https://github.com/rust-lang/rust/issues/20440 for more info
80 COPY host-x86_64/dist-x86_64-linux/build-binutils.sh /tmp/
81 RUN ./build-binutils.sh
82
83 # Need at least GCC 5.1 to compile LLVM nowadays
84 COPY host-x86_64/dist-x86_64-linux/build-gcc.sh /tmp/
85 RUN ./build-gcc.sh && apt-get remove -y gcc g++
86
87 COPY host-x86_64/dist-x86_64-linux/build-python.sh /tmp/
88 # Build Python 3 needed for LLVM 12.
89 RUN ./build-python.sh 3.9.1
90
91 # LLVM needs cmake 3.13.4 or higher.
92 COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/
93 RUN ./build-cmake.sh
94
95 # Now build LLVM+Clang, afterwards configuring further compilations to use the
96 # clang/clang++ compilers.
97 COPY host-x86_64/dist-x86_64-linux/build-clang.sh /tmp/
98 RUN ./build-clang.sh
99 ENV CC=clang CXX=clang++
100
101 # rustc-perf version from 2022-05-18
102 ENV PERF_COMMIT f66cc8f3e04392b0e2fd811f21fd1ece6ebaded3
103 RUN curl -LS -o perf.zip https://github.com/rust-lang/rustc-perf/archive/$PERF_COMMIT.zip && \
104     unzip perf.zip && \
105     mv rustc-perf-$PERF_COMMIT rustc-perf && \
106     rm perf.zip
107
108 COPY scripts/sccache.sh /scripts/
109 RUN sh /scripts/sccache.sh
110
111 ENV PGO_HOST=x86_64-unknown-linux-gnu
112
113 ENV HOSTS=x86_64-unknown-linux-gnu
114
115 ENV RUST_CONFIGURE_ARGS \
116       --enable-full-tools \
117       --enable-sanitizers \
118       --enable-profiler \
119       --enable-compiler-docs \
120       --set target.x86_64-unknown-linux-gnu.linker=clang \
121       --set target.x86_64-unknown-linux-gnu.ar=/rustroot/bin/llvm-ar \
122       --set target.x86_64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \
123       --set llvm.thin-lto=true \
124       --set llvm.ninja=false \
125       --set rust.jemalloc \
126       --set rust.use-lld=true
127 ENV SCRIPT ../src/ci/pgo.sh python3 ../x.py dist \
128     --host $HOSTS --target $HOSTS \
129     --include-default-paths \
130     build-manifest
131 ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang
132
133 # This is the only builder which will create source tarballs
134 ENV DIST_SRC 1
135
136 # When we build cargo in this container, we don't want it to use the system
137 # libcurl, instead it should compile its own.
138 ENV LIBCURL_NO_PKG_CONFIG 1
139
140 ENV DIST_REQUIRE_ALL_TOOLS 1