Closed richarddd closed 5 months ago
I don't see how this is related to cargo-zigbuild
.
Well, the whole point of cargo-zigbuild
would be to have a simple way to cross compile. But crates like ring, aws-lc-rs and a lot of other crates won't compile with cargo-zigbuild
due to the issue i mentioned above.
Then you should open an issue with repro steps using cargo-zigbuild.
I'd also like to point out that we have a test for ring (which rustls depends on by default) in CI and it works fine:
https://github.com/rust-cross/cargo-zigbuild/actions/runs/7666563864/job/20894629394#step:19:231
so please open an issue with detailed repro steps if you are having issue with it.
I'd also like to point out that we have a test for ring (which rustls depends on by default) in CI and it works fine:
https://github.com/rust-cross/cargo-zigbuild/actions/runs/7666563864/job/20894629394#step:19:231
so please open an issue with detailed repro steps if you are having issue with it.
~~That test only works because you are installing gcc-aarch64-linux-gnu that ring uses to build. If you have gcc-aarch64-linux-gnu you won’t need zig to compile :)~~
I will create a simple reproducible to illustrate my point. Thanks
I can see now that you're already doing what i proposed. I must have misconfigured something, sorry about that:
"/root/.cache/cargo-zigbuild/0.18.3/zigcc-aarch64-unknown-linux-gnu.sh"
@messense i have now found how to reproduce the issue. This only occurs when targeting another platform than your host. Like i mentioned before, this is not catched in your test as you are installing gcc-aarch64-linux-gnu
when you are installing qemu:
https://github.com/rust-cross/cargo-zigbuild/actions/runs/7666563864/job/20894629394#step:19:50
Here is the repoducer: https://github.com/richarddd/cargo-zigbuild-cc-issue
And the failed step: https://github.com/richarddd/cargo-zigbuild-cc-issue/actions/runs/7712241228/job/21019355357#step:5:218
cargo-zigbuild
isn't a rustup
proxy, so it doesn't work with +nightly
, you need to use cargo +nightly zigbuild ...
instead.
Oh that was it! Thank you so much! Works flawlessly now. QQ: What would be the equivalent of cargo +nightly test
?
What would be the equivalent of
cargo +nightly test
?
I think something like this should work:
export CARGO_TARGET_<TARGET-TRIPLE>_RUNNER=qemu-xxx
RUSTUP_TOOLCHAIN=nightly cargo-zigbuild test
Ring expects host to set CC env. If we don't have the correct cross compiler installed, build will fail.
It's not possible to set this explicitly via env since most build systems wont accept arguments to CC variable.
A possible workaround would be to create a zig cc wrapper file for the target we're building for:
/tmp/zigcc-aarch64-linux-gnu:
Make it executable and set it as CC, CXX, AR, RANLIB etc for the target we're building for.