Skip to content

Commit

Permalink
[WiP] Enable c feature of Rust's compiler-builtins crate
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Nov 28, 2021
1 parent caf21ca commit 1a3f69d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
9 changes: 7 additions & 2 deletions build/lin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
8 changes: 7 additions & 1 deletion linux-arm64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
10 changes: 8 additions & 2 deletions linux-musl-arm64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -51,14 +51,20 @@ 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 \
PKG_CONFIG="/bin/aarch64-linux-musl-pkg-config" \
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"

Expand Down

0 comments on commit 1a3f69d

Please sign in to comment.