From 1a3f69d3b852ce06117d7dbeb36a58ef3e4ade35 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sun, 28 Nov 2021 16:43:18 +0100 Subject: [PATCH] [WiP] Enable c feature of Rust's compiler-builtins crate --- build/lin.sh | 9 +++++++-- linux-arm64/Dockerfile | 8 +++++++- linux-musl-arm64/Dockerfile | 10 ++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/build/lin.sh b/build/lin.sh index 635732b0..0275d3f4 100755 --- a/build/lin.sh +++ b/build/lin.sh @@ -188,7 +188,7 @@ if [ "$ALL_AT_VERSION_LATEST" = "false" ]; then exit 1; fi # Download and build dependencies from source if [ "$DARWIN" = true ]; then - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ + $CURL --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ | sh -s -- -y --no-modify-path --profile minimal ${DARWIN_ARM:+--default-toolchain nightly} if [ "$DARWIN_ARM" = true ]; then ${CARGO_HOME}/bin/rustup component add rust-src @@ -198,7 +198,12 @@ if [ "$DARWIN" = true ]; then # See: https://github.com/lovell/sharp-libvips/issues/109 printf "[unstable]\n\ build-std = [\"std\", \"panic_abort\"]\n\ -build-std-features = [\"panic_immediate_abort\"]" > ${CARGO_HOME}/config.toml +build-std-features = [\"panic_immediate_abort\", \"compiler-builtins-c\"]" > ${CARGO_HOME}/config.toml + + # `c` feature of the `compiler-builtins` crate needs the compiler-rt sources from LLVM + $CURL https://github.com/rust-lang/llvm-project/archive/rustc/13.0-2021-09-30.tar.gz | \ + tar -xzC ${ROOT} --strip-components 1 llvm-project-rustc-13.0-2021-09-30/compiler-rt + export RUST_COMPILER_RT_ROOT="${ROOT}/compiler-rt" fi fi diff --git a/linux-arm64/Dockerfile b/linux-arm64/Dockerfile index bd055167..187c62f7 100644 --- a/linux-arm64/Dockerfile +++ b/linux-arm64/Dockerfile @@ -42,12 +42,18 @@ RUN \ RUN \ printf "[unstable]\n\ build-std = [\"std\", \"panic_abort\"]\n\ -build-std-features = [\"panic_immediate_abort\"]" > $CARGO_HOME/config.toml +build-std-features = [\"panic_immediate_abort\", \"compiler-builtins-c\"]" > $CARGO_HOME/config.toml + +# `c` feature of the `compiler-builtins` crate needs the compiler-rt sources from LLVM +RUN \ + curl -Ls https://github.com/rust-lang/llvm-project/archive/rustc/13.0-2021-09-30.tar.gz | \ + tar -xzC /root --strip-components 1 llvm-project-rustc-13.0-2021-09-30/compiler-rt # Compiler settings ENV \ PLATFORM="linux-arm64" \ CARGO_BUILD_TARGET="aarch64-unknown-linux-gnu" \ + RUST_COMPILER_RT_ROOT="/root/compiler-rt" \ FLAGS="-march=armv8-a" \ MESON="--cross-file=/root/meson.ini" diff --git a/linux-musl-arm64/Dockerfile b/linux-musl-arm64/Dockerfile index 4c27c44e..c6283e31 100644 --- a/linux-musl-arm64/Dockerfile +++ b/linux-musl-arm64/Dockerfile @@ -36,7 +36,7 @@ RUN \ shared-mime-info \ texinfo && \ apk --update --no-cache --repository https://alpine.global.ssl.fastly.net/alpine/edge/community/ add advancecomp && \ - curl -Ls https://github.com/lovell/aarch64-linux-musl-crosstools/archive/main.tar.gz | tar -hxzC / --strip-components=2 && \ + curl -Ls https://github.com/lovell/aarch64-linux-musl-crosstools/archive/main.tar.gz | tar -hxzC / --strip-components 2 && \ ln -s /usr/bin/pkg-config /bin/aarch64-linux-musl-pkg-config && \ curl https://sh.rustup.rs -sSf | sh -s -- -y \ --no-modify-path \ @@ -51,7 +51,12 @@ RUN \ RUN \ printf "[unstable]\n\ build-std = [\"std\", \"panic_abort\"]\n\ -build-std-features = [\"panic_immediate_abort\"]" > $CARGO_HOME/config.toml +build-std-features = [\"panic_immediate_abort\", \"compiler-builtins-c\"]" > $CARGO_HOME/config.toml + +# `c` feature of the `compiler-builtins` crate needs the compiler-rt sources from LLVM +RUN \ + curl -Ls https://github.com/rust-lang/llvm-project/archive/rustc/13.0-2021-09-30.tar.gz | \ + tar -xzC /root --strip-components 1 llvm-project-rustc-13.0-2021-09-30/compiler-rt # Compiler settings ENV \ @@ -59,6 +64,7 @@ ENV \ PLATFORM="linux-musl-arm64" \ CHOST="aarch64-linux-musl" \ RUST_TARGET="aarch64-unknown-linux-musl" \ + RUST_COMPILER_RT_ROOT="/root/compiler-rt" \ FLAGS="-march=armv8-a" \ MESON="--cross-file=/root/meson.ini"