Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yuzhy8701
Copy link
Contributor

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 or proc_macro. A third value none is provided as a default for targets outside of the (transitive) scope of any rust crates. The change also adds 3 config_settings, one for each value of the build setting, to provide

Examples of complex scenarios enabled by this change:

  1. Build with a mac-x86_64 toolchain on mac-aarch64 platforms (with 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.

yuzhy8701 and others added 2 commits April 13, 2025 01:35
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.
@yuzhy8701 yuzhy8701 force-pushed the toolchain-platform branch from bb1a108 to a5b8a83 Compare April 14, 2025 21:34
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.
@yuzhy8701 yuzhy8701 force-pushed the toolchain-platform branch from a5b8a83 to a2e2695 Compare April 14, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant