Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
817: Enable usage of other toolchains in images r=Alexhuszagh a=Emilgardis Makes the following work ```toml # Cross.toml [build] default-target = "x86_64-unknown-linux-musl" [target."x86_64-unknown-linux-musl"] image.name = "alpine:edge" image.toolchain = ["x86_64-unknown-linux-musl"] pre-build = ["apk add --no-cache gcc musl-dev"] ``` ```rust // src/main.rs fn main() { println!("Hello, world!"); } ``` ``` > cross run [..snip] Finished dev [unoptimized + debuginfo] target(s) in 0.24s Running `/target/x86_64-unknown-linux-musl/debug/cross-minimal` Hello, world! ``` and also ```toml [target.x86_64-unknown-linux-gnu] pre-build = [ "apt-get update && apt-get install -y libc6 g++-x86-64-linux-gnu libc6-dev-amd64-cross", ] [target.x86_64-unknown-linux-gnu.env] passthrough = [ "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc", "CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc", "CXX_x86_64_unknown_linux_gnu=x86_64-linux-gnu-g++", ] [target.x86_64-unknown-linux-gnu.image] name = "ubuntu:20.04" toolchain = ["aarch64-unknown-linux-gnu"] ``` ``` cross build --target x86_64-unknown-linux-gnu -v + cargo metadata --format-version 1 --filter-platform x86_64-unknown-linux-gnu + rustc --print sysroot + /usr/local/bin/docker + /usr/local/bin/docker version '-f "{{ .Server.Os }},{{ .Server.Arch }}"' + rustup --verbose toolchain list + rustup --verbose target list --toolchain stable-aarch64-unknown-linux-gnu + rustup --verbose component list --toolchain stable-aarch64-unknown-linux-gnu + "/Users/emil/workspace/cross-tests/basic" /usr/local/bin/docker build --platform linux/arm64 --label 'org.cross-rs.for-cross-target=x86_64-unknown-linux-gnu' --label 'org.cross-rs.runs-with=aarch64-unknown-linux-gnu' --label 'org.cross-rs.workspace_root=/Users/emil/workspace/cross-tests/basic' --tag cross-custom-basic:x86_64-unknown-linux-gnu-50dfa-pre-build --build-arg 'CROSS_CMD=apt-get update && apt-get install -y libc6 g++-x86-64-linux-gnu libc6-dev-amd64-cross' --build-arg 'CROSS_DEB_ARCH=amd64' --file /Users/emil/workspace/cross-tests/basic/target/x86_64-unknown-linux-gnu/Dockerfile.x86_64-unknown-linux-gnu-custom . [+] Building 10.0s (6/6) FINISHED => [internal] load build definition from Dockerfile.x86_64-unknown-linux-gnu-custom 0.0s => => transferring dockerfile: 166B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for docker.io/library/ubuntu:20.04 0.6s => CACHED [1/2] FROM docker.io/library/ubuntu:20.04@sha256:fd92c36d3cb9b1d027c4d2a72c6bf0125da82425fc2ca 0.0s => [2/2] RUN eval "apt-get update && apt-get install -y libc6 g++-x86-64-linux-gnu libc6-dev-amd64-cross 8.8s => exporting to image 0.5s => => exporting layers 0.5s => => writing image sha256:92f3cf51cc16c7b176c9bc09ce28ef83c029881e9c5017589eb8372bf6fff8d3 0.0s => => naming to docker.io/library/cross-custom-basic:x86_64-unknown-linux-gnu-50dfa-pre-build 0.0s + /usr/local/bin/docker run --userns host --platform linux/arm64 -e 'CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc' -e 'CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc' -e 'CXX_x86_64_unknown_linux_gnu=x86_64-linux-gnu-g++' -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=emil' --rm --user 501:20 -v /Users/emil/.xargo:/xargo:Z -v /Users/emil/.cargo:/cargo:Z -v /cargo/bin -v /Users/emil/workspace/cross-tests/basic:/project:Z -v /Users/emil/.rustup/toolchains/stable-aarch64-unknown-linux-gnu:/rust:Z,ro -v /Users/emil/workspace/cross-tests/basic/target:/target:Z -w /project -i -t cross-custom-basic:x86_64-unknown-linux-gnu-50dfa-pre-build sh -c 'PATH=$PATH:/rust/bin cargo build --target x86_64-unknown-linux-gnu -v' Fresh basic v0.1.0 (/project) Finished dev [unoptimized + debuginfo] target(s) in 0.47s basic on master [?] is 📦 v0.1.0 via 🦀 v1.61.0 took 12s ❯ file target/x86_64-unknown-linux-gnu/debug/basic target/x86_64-unknown-linux-gnu/debug/basic: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=5716ca6c6514e255e9a29eeeeac3d9cb4fb43c0a, for GNU/Linux 3.2.0, with debug_info, not stripped basic on master [?] is 📦 v0.1.0 via 🦀 v1.61.0 ❯ uname -a Darwin Emils-MacBook-Pro.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64 ``` also makes `cross +nightly-2022-01-01` possible. this is a requirement for #751 Co-authored-by: Emil Gardström <[email protected]>
- Loading branch information