cargo: Fix handling of relative sysroots#1371
cargo: Fix handling of relative sysroots#1371illicitonion merged 2 commits intobazelbuild:mainfrom kalcutter:cargo-fix-relative-sysroots
Conversation
Currently, `cc_toolchain.sysroot` is appended as an argument to "CC" and "CXX". This argument, however, will typically be overridden by any --sysroot flag already present in "CFLAGS" and "CXXFLAGS". When sysroot is relative, this fails because cargo_build_script_runner is not executed from the execroot. Do not append `--sysroot` to "CC" and "CXX". Instead, modify any --sysroot arguments with relative paths to be absolute.
|
Thanks for the contribution! This definitely looks nicer, and I think should be fine because we now properly populate CFLAGS and CXXFLAGS (as of #1081), which should contain a @sayrer do you still have a handy repro environment from #659 to make sure it's now safe to effectively revert #664, which this PR does? |
|
@illicitonion I would have included a test but I didn't see an easy way. Would you be OK to merge this without a test for 0.6.0 since it fixes real bugs? We can create an issue to improve the testing of cross-compilation? |
illicitonion
left a comment
There was a problem hiding this comment.
Makes sense - let's 🤞 and run with it :) Thanks again!
|
Thanks! 🎉 |
Currently,
cc_toolchain.sysrootis appended as an argument to "CC" and"CXX". This argument, however, will typically be overridden by any
--sysroot flag already present in "CFLAGS" and "CXXFLAGS". When sysroot
is relative, this fails because cargo_build_script_runner is not
executed from the execroot.
Do not append
--sysrootto "CC" and "CXX". Instead, modify any--sysroot arguments with relative paths to be absolute.