Hi! I'm working on a language called CO2, which is C with some Rust interop features. CO2 uses cargo as its build system (with a wrapper co2cargo) and I use RUSTC=co2rustc to compile Rust code to make them ABI compatible with CO2 crates that use Rust code.
I would like to return my version in addition to rustc version in the output of co2rustc. Something like:
~/oss/co2> co2rustc --version
rustc 1.98.0-dev
co2rustc xxx
But it breaks crates that use this crate:
error: failed to run custom build command for `rustversion v1.0.22`
Caused by:
process didn't exit successfully: `/home/hamid/co2-ratatui/target/debug/build/rustversion-78cc9fef8ab69167/build-script-build` (exit status: 1)
--- stdout
cargo:rerun-if-changed=build/build.rs
--- stderr
Error: unexpected output from `rustc --version`: "rustc 1.98.0-dev\nco2rustc xxx\n"
Please file an issue in https://github.com/dtolnay/rustversion
warning: build failed, waiting for other jobs to finish...
So I gave up and now just return the rustc version for now.
Then why I filed this issue? I suggest making this crate nicer to custom rust compilers with two changes:
- Provide an env var
RUSTVERSION_CHECKING=1 when running rustc. In this way, custom compilers like co2rustc and gccrs and ... can detect it and provide a version that makes rustversion happy.
- Make the version parser more robust. For example, detect the line starting with
rustc 1. and only use that line. In this way, rustc can update its version string without breaking the world, and other compilers may not even need that env flag. I still think the flag is useful even with this change.
I wouldn't block my co2 work on this, and just return the rustc version there. But I think the sooner this issue get addressed, the sooner the ecosystem becomes ready for custom rust compilers.
Hi! I'm working on a language called CO2, which is C with some Rust interop features. CO2 uses cargo as its build system (with a wrapper co2cargo) and I use
RUSTC=co2rustcto compile Rust code to make them ABI compatible with CO2 crates that use Rust code.I would like to return my version in addition to rustc version in the output of co2rustc. Something like:
But it breaks crates that use this crate:
So I gave up and now just return the rustc version for now.
Then why I filed this issue? I suggest making this crate nicer to custom rust compilers with two changes:
RUSTVERSION_CHECKING=1when running rustc. In this way, custom compilers like co2rustc and gccrs and ... can detect it and provide a version that makes rustversion happy.rustc 1.and only use that line. In this way, rustc can update its version string without breaking the world, and other compilers may not even need that env flag. I still think the flag is useful even with this change.I wouldn't block my co2 work on this, and just return the rustc version there. But I think the sooner this issue get addressed, the sooner the ecosystem becomes ready for custom rust compilers.