-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
A-profilesArea: profilesArea: profilesA-rustflagsArea: rustflagsArea: rustflagsC-tracking-issueCategory: A tracking issue for something unstable.Category: A tracking issue for something unstable.S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.S-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.S-waiting-on-feedbackStatus: An implemented feature is waiting on community feedback for bugs or design concerns.Status: An implemented feature is waiting on community feedback for bugs or design concerns.Z-profile-rustflagsNightly: profile-rustflagsNightly: profile-rustflags
Description
Summary
Original issue: #7878
Implementation: #10217
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#profile-rustflags-option
The profile-rustflags
feature allows setting RUSTFLAGS per-profile.
Unresolved Issues
- How should things interact with rustdoc? If there is a flag that is required to correctly build a project, then
cargo test
may fail if they aren't passed to rustdoc. However, rustdoc doesn't accept all of rustc's flags. Adding arustdocflags
option seems to be adding more unwanted complexity, though.This introduces potential backwards-compatibility hazards. For example, when Cargo adds new features or changes the way it invokes rustc, that can interfere with pre-existing flags. Is documenting this sufficient?What should the behavior be with build scripts and proc-macros? Those have historically been a pain point with rustflags. Perhaps there should be a defaultbuild-override.rustflags = []
.Profile rustflags are not considered as part ofTargetInfo
, which impacts feature resolution and other things.Are we ok with rustflags that can be set inCargo.toml
To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Future Extensions
No response
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
cprice404, fmease, recatek, IndigoLily, justhaug and 35 more
Metadata
Metadata
Assignees
Labels
A-profilesArea: profilesArea: profilesA-rustflagsArea: rustflagsArea: rustflagsC-tracking-issueCategory: A tracking issue for something unstable.Category: A tracking issue for something unstable.S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.S-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.S-waiting-on-feedbackStatus: An implemented feature is waiting on community feedback for bugs or design concerns.Status: An implemented feature is waiting on community feedback for bugs or design concerns.Z-profile-rustflagsNightly: profile-rustflagsNightly: profile-rustflags
Type
Projects
Status
Unstable, baking
Milestone
Relationships
Development
Select code repository
Activity
bstrie commentedon Apr 29, 2022
I see something like this as necessary for the usability of RFC 3028 (artifact dependencies): #9096 . Historically Cargo has not supported passing arbitrary flags in profile overrides because many of them made no sense to pass to a dependency (e.g.
-C linker
). However, with binary artifacts, now literally all rustc flags become something that users will have valid reasons to want to specify. Currently this leads to lots of pain and workarounds with trying to use binary dependencies, either by hacking things up with Cargo config files (which don't work in all cases) or build scripts (which don't support all flags) or environment variables (which are difficult to set in all circumstances).That doesn't mean that this feature is the only way to satisfy this need, but I think anything that does satisfy this need would have to be functionally equivalent to profile-rustflags.
Qubasa commentedon Sep 29, 2022
cargo-features = ["per-package-target", "profile-rustflags"] don't work together.
By this I mean the target does not get applied when profile-rustflags get used.
Will fail with
gcc: error: unrecognized command-line option '--image-base=0x200000'
even though target defines ld.lld as linkerrustflags
generate unknown unstable option:build-std
#11275MauriceKayser commentedon Jan 28, 2023
I can not get this to work with a
no_std
crate on Windows with the current nightly. Steps to reproduce the linker issue:Cargo.toml
:src/main.rs
:.cargo/config.toml
:cargo build --release --target x86_64-pc-windows-msvc -Z build-std=core
-> it succeeds..cargo/config.toml
.Cargo.toml
:cargo build --release --target x86_64-pc-windows-msvc -Z build-std=core
-> it succeeds.target
build artifact directory to enforce a complete recompilation.cargo build --release --target x86_64-pc-windows-msvc -Z build-std=core
-> it fails:It seems like it tries to link the things that should be excluded via
no_std
, likemsvcrt
andWinMain
.By the way, is it possible to use something like
cfg(target_env = "msvc")
withprofile-rustflags
?ehuss commentedon Jan 28, 2023
As mentioned in the unresolved section, profile rustflags get applied to build scripts. You can override that with:
Also, I might suggest using the
#[windows_subsystem]
attribute instead of setting it manually.Conditional settings are not supported in profiles, you'll need to use separate profiles.
In the future, please file a new issue if you have a question or problem. See the "About tracking issues" section above.
MauriceKayser commentedon Jan 29, 2023
Sorry, I will read more carefully next time and create a separate issue instead. I did not realize that my example contained a build script, thanks for the hint! The
#![windows_subsystem = "windows"]
seems to be ignored, if applied to the example - it will look formainCRTStartup
, theconsole
subsystem main function, instead ofWinMainCRTStartup
, thewindows
subsystem main function.44 remaining items