feat: use rustembedded/cross images and use static relocation model to fix cross-compile
This commit is contained in:
parent
a021680591
commit
cd9902637d
7 changed files with 112 additions and 27 deletions
|
@ -21,33 +21,46 @@ variables:
|
|||
- if: '$CI_COMMIT_BRANCH == "next"'
|
||||
- if: "$CI_COMMIT_TAG"
|
||||
interruptible: true
|
||||
image: "rust:1.56"
|
||||
image: "rust:1.58"
|
||||
tags: ["docker"]
|
||||
services: ["docker:dind"]
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2375/
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_DRIVER: overlay2
|
||||
SHARED_PATH: $CI_PROJECT_DIR/shared/
|
||||
CARGO_PROFILE_RELEASE_LTO: "true"
|
||||
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "1"
|
||||
CARGO_INCREMENTAL: "false" # https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
|
||||
before_script:
|
||||
- 'echo "Building for target $TARGET"'
|
||||
- "rustc --version && cargo --version && rustup show" # Print version info for debugging
|
||||
- "rustup target add $TARGET"
|
||||
- "rustup show && rustc --version && cargo --version" # Print version info for debugging
|
||||
# If provided, bring in caching through sccache, which uses an external S3 endpoint to store compilation results:
|
||||
- if [ -n "${SCCACHE_BIN_URL}" ]; then curl $SCCACHE_BIN_URL --output /sccache && chmod +x /sccache && export RUSTC_WRAPPER=/sccache; fi
|
||||
# Make sure that cc-rs links the correct libraries statically when cross-compiling
|
||||
# See https://github.com/alexcrichton/cc-rs#external-configuration-via-environment-variables for more information
|
||||
- 'export CARGO_BUILD_RUSTFLAGS="-L$TARGET_HOME/lib -latomic" CXXSTDLIB="static=stdc++"'
|
||||
# Make sure that rust-bindgen uses the correct include path when cross-compiling
|
||||
# See https://github.com/rust-lang/rust-bindgen#environment-variables for more information
|
||||
- 'export BINDGEN_EXTRA_CLANG_ARGS="-I$TARGET_C_INCLUDE_PATH"'
|
||||
script:
|
||||
- time cargo build --target $TARGET --release
|
||||
# install cross-compiling prerequisites
|
||||
- 'apt-get update && apt-get install -y docker.io && docker version' # install docker
|
||||
- 'cargo install cross && cross --version' # install cross
|
||||
# fix cargo and rustup mounts from this container (https://gitlab.com/gitlab-org/gitlab-foss/-/issues/41227)
|
||||
- 'mkdir -p $SHARED_PATH/cargo'
|
||||
- 'cp -r $CARGO_HOME/bin $SHARED_PATH/cargo'
|
||||
- 'cp -r $RUSTUP_HOME $SHARED_PATH'
|
||||
- 'export CARGO_HOME=$SHARED_PATH/cargo RUSTUP_HOME=$SHARED_PATH/rustup'
|
||||
# cross-compile conduit for target
|
||||
- 'time ./cross/build.sh --locked --release'
|
||||
- 'cp "target/$TARGET/release/conduit" "conduit-$TARGET"'
|
||||
cache:
|
||||
# https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
|
||||
- key: 'cargo-cache-$TARGET'
|
||||
paths:
|
||||
- $SHARED_PATH/cargo/registry/index
|
||||
- $SHARED_PATH/cargo/registry/cache
|
||||
- $SHARED_PATH/cargo/git/db
|
||||
artifacts:
|
||||
expire_in: never
|
||||
|
||||
build:release:cargo:x86_64-unknown-linux-musl-with-debug:
|
||||
extends: .build-cargo-shared-settings
|
||||
image: messense/rust-musl-cross:x86_64-musl
|
||||
variables:
|
||||
CARGO_PROFILE_RELEASE_DEBUG: 2 # Enable debug info for flamegraph profiling
|
||||
TARGET: "x86_64-unknown-linux-musl"
|
||||
|
@ -61,7 +74,6 @@ build:release:cargo:x86_64-unknown-linux-musl-with-debug:
|
|||
|
||||
build:release:cargo:x86_64-unknown-linux-musl:
|
||||
extends: .build-cargo-shared-settings
|
||||
image: messense/rust-musl-cross:x86_64-musl
|
||||
variables:
|
||||
TARGET: "x86_64-unknown-linux-musl"
|
||||
artifacts:
|
||||
|
@ -72,7 +84,6 @@ build:release:cargo:x86_64-unknown-linux-musl:
|
|||
|
||||
build:release:cargo:arm-unknown-linux-musleabihf:
|
||||
extends: .build-cargo-shared-settings
|
||||
image: messense/rust-musl-cross:arm-musleabihf
|
||||
variables:
|
||||
TARGET: "arm-unknown-linux-musleabihf"
|
||||
artifacts:
|
||||
|
@ -83,7 +94,6 @@ build:release:cargo:arm-unknown-linux-musleabihf:
|
|||
|
||||
build:release:cargo:armv7-unknown-linux-musleabihf:
|
||||
extends: .build-cargo-shared-settings
|
||||
image: messense/rust-musl-cross:armv7-musleabihf
|
||||
variables:
|
||||
TARGET: "armv7-unknown-linux-musleabihf"
|
||||
artifacts:
|
||||
|
@ -94,7 +104,6 @@ build:release:cargo:armv7-unknown-linux-musleabihf:
|
|||
|
||||
build:release:cargo:aarch64-unknown-linux-musl:
|
||||
extends: .build-cargo-shared-settings
|
||||
image: messense/rust-musl-cross:aarch64-musl
|
||||
variables:
|
||||
TARGET: "aarch64-unknown-linux-musl"
|
||||
artifacts:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue