feat: honor rustflags from cargo's --config CLI option for zig -mcpu - #471
Merged
Conversation
Rustflags passed via cargo's `--config` option (KEY=VALUE in TOML syntax
or a path to an extra config file) were forwarded to the child cargo
process but not reflected in the -mcpu passed to zig cc, silently
reverting to baseline CPU for C/C++ dependencies and linking.
Parse the --config arguments and overlay them onto the
cargo_config2-resolved rustflags following cargo's precedence rules:
RUSTFLAGS/CARGO_ENCODED_RUSTFLAGS env vars shortcut everything, CLI
config beats config env vars and files within a tier, target tier beats
build tier, and arrays join left-to-right with CLI items last.
This makes it possible to scope a target-cpu to a cargo alias without
wrapper scripts or RUSTFLAGS:
[alias]
build-prod = "zigbuild --release --target x86_64-unknown-linux-gnu --config target.x86_64-unknown-linux-gnu.rustflags=['-C','target-cpu=x86-64-v4']"
Most of this can be simplified once cargo-config2 supports --config
overrides natively (taiki-e/cargo-config2#3).
Closes #463
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rustflags passed via cargo's
--configoption (KEY=VALUEin TOML syntax or a path to an extra config file) were forwarded to the child cargo process but not reflected in the-mcpupassed tozig cc, silently reverting to baseline CPU for C/C++ dependencies and linking.Parse the
--configarguments and overlay them onto thecargo_config2-resolved rustflags following cargo's precedence rules:RUSTFLAGS/CARGO_ENCODED_RUSTFLAGSenv vars shortcut everything, CLI config beats config env vars and files within a tier, target tier beats build tier, and arrays join left-to-right with CLI items last.This makes it possible to scope a target-cpu to a cargo alias without wrapper scripts or
RUSTFLAGS:Most of this can be simplified once
cargo-config2supports--configoverrides natively (taiki-e/cargo-config2#3).Closes #463