-
Notifications
You must be signed in to change notification settings - Fork 455
Using nightly channel for builds #1562
-
Hello 👋, so I am trying to cross-compile for a Tier 3 target and need to use a nightly channel because of this. Looking at what cross says to do it's as simple as cross +nightly build -Z build-std...; however, I get the below error when using this syntax:
error: the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
+ rustup component list --toolchain nightly-2023年12月21日-x86_64-unknown-linux-gnu
Running my command with the -v flag shows what I assume the issue is:
> cross +nightly-2023年12月21日 build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --release --target powerpc64le-unknown-linux-gnu -v
+ cargo +nightly-2023年12月21日 metadata --format-version 1 --filter-platform powerpc64le-unknown-linux-gnu --features mips
+ rustc --print sysroot
+ "C:\Program Files\Docker\Docker\resources\bin\docker.exe"
+ "C:\Program Files\Docker\Docker\resources\bin\docker.exe" version -f '{{ .Server.Os }},,,{{ .Server.Arch }}'
+ "C:\Program Files\Docker\Docker\resources\bin\docker.exe" info -f {{.SecurityOptions}}
+ rustup toolchain list
+ rustup target list --toolchain nightly-2023年12月21日-x86_64-unknown-linux-gnu
+ rustup component list --toolchain nightly-2023年12月21日-x86_64-unknown-linux-gnu
+ "C:\Program Files\Docker\Docker\resources\bin\docker.exe" buildx build --progress auto --label 'org.cross-rs.for-cross-target=powerpc64le-unknown-linux-gnu' --label 'org.cross-rs.runs-with=x86_64-unknown-linux-gnu' --label 'org.cross-rs.workspace_root=C:\Users\mid\project' --tag localhost/cross-rs/cross-custom-project:powerpc64le-unknown-linux-gnu-914ae --build-arg 'target=powerpc64le' --build-arg 'CROSS_DEB_ARCH=ppc64el' --build-arg 'CROSS_BASE_IMAGE=ghcr.io/cross-rs/powerpc64le-unknown-linux-gnu:main' --file ./containers/Dockerfile.mussel --output 'type=docker' ./containers/build_context
[+] Building 1.1s (10/10) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile.mussel 0.0s
=> => transferring dockerfile: 4.36kB 0.0s
=> [internal] load metadata for docker.io/library/rust:1.76 0.7s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [1/6] FROM docker.io/library/rust:1.76@sha256:d36f9d8a9a4c76da74c8d983d0d4cb146dd2d19bb9bd60b704cdcf70ef868d3a 0.0s
=> CACHED [2/6] RUN apt-get update && apt-get upgrade -y && apt-get install -y cmake vim qemu-user gcc-powerpc64le-linux-gnu gcc-mips-linux-gnu 0.0s
=> CACHED [3/6] RUN rustup toolchain install nightly-2023年12月21日 && rustup component add rust-src --toolchain nightly-2023年12月21日 && rustup toolchain link 1.76.0-nightly /usr/local/rustup/toolchai 0.0s
=> CACHED [4/6] RUN git clone https://github.com/firasuke/mussel.git && cd /mussel && ./mussel powerpc64le --parallel 0.0s
=> CACHED [5/6] RUN curl https://ziglang.org/builds/zig-linux-x86_64-0.14.0-dev.1632+d83a3f174.tar.xz --output /opt/zig.tar.xz && tar -xvf /opt/zig.tar.xz --directory /opt && cargo install cargo 0.0s
=> CACHED [6/6] WORKDIR /volume 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:10e7ba135c51d25d9e1d23200d124a8d7c87e69307b3aca9cfda9820fe70d018 0.0s
=> => naming to localhost/cross-rs/cross-custom-project:powerpc64le-unknown-linux-gnu-914ae 0.0s
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/fp655mzkdpmy2nlaikc7y6mpg
+ "C:\Program Files\Docker\Docker\resources\bin\docker.exe" run --userns host -e 'RUST_BACKTRACE=1' -e 'XARGO_HOME=/mnt/c/Users/mid/.xargo' -e 'CARGO_HOME=/mnt/c/Users/mid/.cargo' -e 'CROSS_RUST_SYSROOT=/mnt/c/Users/mid/.rustup/toolchains/nightly-2023年12月21日-x86_64-unknown-linux-gnu' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e CROSS_CONTAINER_ENGINE -e 'USER=mid' -e 'CROSS_RUSTC_MAJOR_VERSION=1' -e 'CROSS_RUSTC_MINOR_VERSION=76' -e 'CROSS_RUSTC_PATCH_VERSION=0' --name cross-nightly-2023年12月21日-x86_64-unknown-linux-gnu-c9339-5ac4c8a63-powerpc64le-unknown-linux-gnu-914ae-1727394528325 --rm --user 1000:1000 -v 'C:\Users\mid\.xargo:/mnt/c/Users/mid/.xargo:z' -v 'C:\Users\mid\.cargo:/mnt/c/Users/mid/.cargo:z' -v /mnt/c/Users/mid/.cargo/bin -v 'C:\Users\mid\project:/mnt/c/Users/mid/project:z' -v 'C:\Users\mid\.rustup\toolchains\nightly-2023年12月21日-x86_64-unknown-linux-gnu:/mnt/c/Users/mid/.rustup/toolchains/nightly-2023年12月21日-x86_64-unknown-linux-gnu:z,ro' -v 'C:\Users\mid\project:z' -w /mnt/c/Users/mid/project -t localhost/cross-rs/cross-custom-project:powerpc64le-unknown-linux-gnu-914ae sh -c 'PATH="$PATH":"/mnt/c/Users/mid/.rustup/toolchains/nightly-2023年12月21日-x86_64-unknown-linux-gnu/bin" cargo build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --release --target powerpc64le-unknown-linux-gnu -v'
For whatever reason, cargo is being invoked without the nightly channel I specified:
[...] cargo build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --release --target powerpc64le-unknown-linux-gnu
I imagine I am missing something simple, but have had no luck at finding out how to make cross use a nightly channel. If there is any other info I could provide just let me know and I'll be happy to do so.
Cross version
> cross --version
cross 0.2.5 (085092c 2024年03月08日)
[cross] note: Falling back to `cargo` on the host.
cargo 1.76.0 (c84b36747 2024年01月18日)
Notes
- Not sure if it is relevant, but I tried setting
CROSS_CUSTOM_TOOLCHAIN=1and I get the same issue - The target I am trying to build for is a custom one that is very similar to
powerpc64le-unknown-linux-musl. I used the guide here to create it: https://docs.rust-embedded.org/embedonomicon/custom-target.html - I am using a custom dockerfile for my build by specifying the relevant info in the
Cross.tomlunder[target.powerpc64le-unknown-linux-gnu.dockerfile] - The build will succeed when I run the following command inside the custom container I created (the 1.76.0-nightly is a link to nightly-2023年12月21日 toolchain inside the container):
cargo +1.76.0-nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --release --target powerpc64le-unknown-linux-gnu - I want to use cross for its ease of use and to simplify building for this target among others, so it would be awesome to be able to use it for this target.
- I am using Rust v1.76.0 since Rust9x supports this version now and I do not want to go past this version of Rust (for now) because of this. However, I have also tried
cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --release --target powerpc64le-unknown-linux-gnuto use the most recent nightly build and get the same error.
Beta Was this translation helpful? Give feedback.
All reactions
cross is designed to use toolchains installed on the host machine, not in the image. We add the path to a mounted toolchain into PATH. I suspect that the reason this doesnt work here is because the cargo added by the rust image is prioritized.
What you should do then is not install cargo in the image. I think you could also use RUSTUP_TOOLCHAIN=<toolchain> cross ... and also set it in Cross.toml via build.env.passthrough = ["RUSTUP_TOOLCHAIN=<toolchain>"]
Replies: 1 comment 3 replies
-
cross is designed to use toolchains installed on the host machine, not in the image. We add the path to a mounted toolchain into PATH. I suspect that the reason this doesnt work here is because the cargo added by the rust image is prioritized.
What you should do then is not install cargo in the image. I think you could also use RUSTUP_TOOLCHAIN=<toolchain> cross ... and also set it in Cross.toml via build.env.passthrough = ["RUSTUP_TOOLCHAIN=<toolchain>"]
Beta Was this translation helpful? Give feedback.
All reactions
-
Once again I was failing to see the forest through the trees. Removing cargo/Rust from the custom container was enough to get everything to compile correctly; however the command still shows as cross build... (this is without the RUSTUP_TOOLCHAIN env), which I found interesting. I also needed to do a cargo clean to get past some permission issues. Thanks for the help, @Emilgardis !
Beta Was this translation helpful? Give feedback.
All reactions
-
No problem! The reason it runs cargo build in verbose mode is because the cargo used in the image will always be the version you mounted, so there's no reason to provide +toolchain
Beta Was this translation helpful? Give feedback.
All reactions
-
Sidenote, the RUSTUP_TOOLCHAIN env could be used in the image if you truly want rustup and your own rustc/cargo in the image
Beta Was this translation helpful? Give feedback.