1FROM ubuntu:20.04 2 3RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ 4 g++ \ 5 make \ 6 ninja-build \ 7 file \ 8 wget \ 9 curl \ 10 ca-certificates \ 11 python3 \ 12 git \ 13 cmake \ 14 xz-utils \ 15 sudo \ 16 gdb \ 17 patch \ 18 libssl-dev \ 19 pkg-config \ 20 && rm -rf /var/lib/apt/lists/* 21 22WORKDIR /build/ 23 24# Build cmake before musl toolchain, as we replace the compiler during that step. 25COPY scripts/cmake.sh /scripts/ 26RUN /scripts/cmake.sh 27 28COPY scripts/musl-toolchain.sh /build/ 29# We need to mitigate rust-lang/rust#34978 when compiling musl itself as well 30RUN CFLAGS="-Wa,-mrelax-relocations=no -Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \ 31 CXXFLAGS="-Wa,-mrelax-relocations=no -Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \ 32 REPLACE_CC=1 bash musl-toolchain.sh x86_64 && rm -rf build 33 34COPY scripts/sccache.sh /scripts/ 35RUN sh /scripts/sccache.sh 36 37ENV HOSTS=x86_64-unknown-linux-musl 38 39ENV RUST_CONFIGURE_ARGS \ 40 --musl-root-x86_64=/usr/local/x86_64-linux-musl \ 41 --enable-extended \ 42 --enable-sanitizers \ 43 --enable-profiler \ 44 --enable-lld \ 45 --set target.x86_64-unknown-linux-musl.crt-static=false \ 46 --build $HOSTS 47 48# Newer binutils broke things on some vms/distros (i.e., linking against 49# unknown relocs disabled by the following flag), so we need to go out of our 50# way to produce "super compatible" binaries. 51# 52# See: https://github.com/rust-lang/rust/issues/34978 53# And: https://github.com/rust-lang/rust/issues/59411 54ENV CFLAGS_x86_64_unknown_linux_musl="-Wa,-mrelax-relocations=no -Wa,--compress-debug-sections=none \ 55 -Wl,--compress-debug-sections=none" 56 57# To run native tests replace `dist` below with `test` 58ENV SCRIPT python3 ../x.py dist --build $HOSTS 59