-
-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for CMAKE_C/CXX_COMPILER_LAUNCHER #474
Add support for CMAKE_C/CXX_COMPILER_LAUNCHER #474
Conversation
I just noticed this is causing issues on our Windows CI, due to issues with spaces... I'll try to fix it. |
9e2053d
to
76f414a
Compare
Ah indeed - that is unfortunate. Thanks for catching it!
I suspect the most robust way would be to add upstream support in cc-rs via a new variable like FYI, if you would just like to enable this in your CI (ingnoring windows for now) without updating corrosion, I would suggest to just force the |
This variable didn't actually store an underscore value but used kebab-style, which couldn't be overwritten.
76f414a
to
880b36c
Compare
Hi @jschwe, For now I've split up the fix for the underscore issue, so that it can be merged already in #475 |
You can also put [build]
rustc-wrapper = "sccache" in ~/.cargo/config.toml to tell Cargo to always use sccache. Though yes it would be nice to have Corrosion pass this along from CMake. |
To clarify: The original issue (as I understand it) is about compiling C/C++ code with (s)ccache. Does setting this flag in the config file really cause C++ code compiled via cc-rs to be wrapped by sccache? Personally I think it is easy enough for the user to set the required rust flag for compiling Rust code with sccache, but pull requests to improve the user experience are always welcome as long as they don't risk regressions in other places. |
Ah, sorry I got confused. CXX-Qt's CI sets the RUSTC_WRAPPER environment variable so rustc's compilations get cached by sccache. cc-rs's compilations getting cached is another matter. It looks like cc-rs already has code to handle this case and even some magic to use sccache for C/C++ when RUSTC_WRAPPER is set and CC is unset (I don't think the latter has an effect when using Corrosion because Corrosion always sets the CC environment variable?). So I don't think there are changes needed upstream in cc-rs; it should already handle CC_{target} being set with a space as this PR does. Looking at the CI failure, the error there is coming from the link-cplusplus crate, not cc-rs. |
Hi @Be-ing, nice to hear from you :) I may not be reading the log correctly, but I think the error is in the build script of link-cplusplus, which in turn does use the So sccache thinks it should invoke the compiler |
Previously, the `rustc_wrapper_fallback` was only called if the tool was **not** a full path. With this patch, the `RUSTC_WRAPPER` is always used, even if the tool provided is an exact path. Providing a wrapper manually is still possible and overrides the `RUSTC_WRAPPER`. If the path to the tool includes spaces it is otherwise impossible to provide a compiler cache like sccache through the CXX or CC environment variables, as the arguments will be split up incorrectly. See also: corrosion-rs/corrosion#474
I've found that If this PR is merged, this one would no longer be necessary, at least for our use-case, as we can just set RUSTC_WRAPPER in our CI. |
I like that solution better. If |
@Be-ing I completely agree. |
* Use RUSTC_WRAPPER if no other wrapper is provided Previously, the `rustc_wrapper_fallback` was only called if the tool was **not** a full path. With this patch, the `RUSTC_WRAPPER` is always used, even if the tool provided is an exact path. Providing a wrapper manually is still possible and overrides the `RUSTC_WRAPPER`. If the path to the tool includes spaces it is otherwise impossible to provide a compiler cache like sccache through the CXX or CC environment variables, as the arguments will be split up incorrectly. See also: corrosion-rs/corrosion#474 * Add #[allow(dead_code)] to ArchSpec::Catalyst This should suppress new warnings generated by the nightly toolchain.
rust-lang/cc-rs#918 is merged now 🥳 That can be used without change to corrosion 👍 |
Also fix
_CORROSION_RUST_CARGO_TARGET_UNDERSCORE
, which didn't actually use underscoresWe found that setting the
CMAKE_C_COMPILER_LAUNCHER
tosccache
orccache
managed to speed up builds of CXX-Qt by ~50% from 116s to 48s.However, Corrosion didn't pass this along to Cargo, so add support for this.