rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.81k stars 434 forks source link

fix targets with zig toolchain #986

Closed QuentinPerez closed 5 months ago

QuentinPerez commented 6 months ago

When you use bazel + zig to cross compile a rust codebase, you got an 'invalid target error' To fix the issue, a check has been added to know if it's a zig toolchain, not sure it's the right way to do it. Feel free to take over the PR.

QuentinPerez commented 6 months ago

It would be great if you could setup CI for testing zig-cc, to verify it indeed works as intended.

I tried it, but I am not sure how to achieve it correctly. Do you have any ideas or guidance on how I could do it?

NobodyXu commented 6 months ago

Simply install pip3 install zig in job test of .github/workflows/main.yml.

You would also need to add a tests/zig-test.rs and write all the testing for zig-cc in it.

NobodyXu commented 5 months ago

@QuentinPerez #1000 has been merged, can you rebase against main please?

NobodyXu commented 5 months ago

Discussed this with @thomcc on zulip, he mentioned that the zig-cc target triple might be changed in the later version of zig-cc.

We are afraid that after merging this PR, zig-cc might change its target triple and break this, causing more code to require to support both newer version and older version.

We decided to hold off adding more workarounds for zig-cc until it reaches 1.0, when its target triple and cmdline args are stable.