-
Notifications
You must be signed in to change notification settings - Fork 486
Add a build setting to announce crate scope #3408
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
Conversation
a5b8a83
to
a2e2695
Compare
This build setting is not used internally, but provides a way for dependencies to be aware that they are being compiled for a rust crate. Examples of complex scenarios allowed by this change: 1. Build with a mac-x86_64 toolchain on mac-aarch64 platforms (rosetta) - everything (including host tools) is compiled for aarch64 while proc_macros must be compiled for x86_64. 2. A `cc_library` linked to both a `cc_binary` and a `rust_binary`, but needs slightly different build flags when used for rust crates.
c90ed00
to
8114917
Compare
The change of bin_dir caused some tests to fail. Now they use a more robust version, havested with an aspect inspecting on the target-under-test.
rustdoc_test fails when its crate dependency and its toolchain dependency are from different configurations, because the stripped roots did not include any toolchain files. This change simplifies the logic by collecting roots from all the inputs.
8114917
to
5229b37
Compare
Could you speak more on this one:
I'd expect this to work today, given that there is a transition to |
@scentini Sure! This is what happens in our build:
Everything works just fine on the x64 builders. But on aarch64 builders proc macros fail to load because they are built for aarch64 while the compiler expects a x64 binary. We tried a few workarounds:
In an ideal world, we can add a toolchain attribute to inform the "native" platform of the rust tools, then transit to that platform when building proc macros (fallback to the |
Hmm.... I can't seem to fix the aspects (Clippy, etc). Those aspects run in a different configuration than the target they are applied to, so they get a different output directory and stuff like I'll seek other ways to resolve our problem. @scentini thanks for your time! |
This build setting is not used internally, but provides a way for (transitive) dependencies to be aware that they are being compiled for a rust crate.
A transition is added to all rust rules, which sets the build setting to one of either:
regular
orproc_macro
. A third valuenone
is provided as a default for targets outside of the (transitive) scope of any rust crates. The change also adds 3config_setting
s, one for each value of the build setting, to provide conditions others canselect()
on.Examples of complex scenarios enabled by this change:
mac-x86_64
toolchain onmac-aarch64
platforms (with Rosetta) - everything (including host tools) is compiled for aarch64 whileproc_macro
s must be compiled for x86_64.cc_library
linked to both acc_binary
and arust_binary
(directly or transitively), but needs slightly different build flags when used for rust crates.windows-gnu
flavor of rust toolchain, while building the rest C++ targets with MSVC toolchain.