-
Notifications
You must be signed in to change notification settings - Fork 479
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
Change flag ordering #1403
base: main
Are you sure you want to change the base?
Change flag ordering #1403
Conversation
To allow flags set on the builder to override other flags, and to allow CFLAGS to override _all_ other flags.
ad73f8b
to
7a651f7
Compare
// Specify various flags that are not considered part of the default flags above. | ||
// FIXME(madsmtm): Should these be considered part of the defaults? If no, why not? | ||
if let Some(ref std) = self.std { | ||
let separator = match cmd.family { | ||
ToolFamily::Msvc { .. } => ':', | ||
ToolFamily::Gnu | ToolFamily::Clang { .. } => '=', | ||
}; | ||
cmd.push_cc_arg(format!("-std{}{}", separator, std).into()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is Builder flags, std version is specified in Builder
// FIXME(madsmtm): Re-enable once `is_flag_supported` works in CI regardless of `target`. | ||
// unsafe { std::env::set_var("CARGO_ENCODED_RUSTFLAGS", "-Cdwarf-version=5") }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there another issue/PR for this?
.must_have_in_order("-static", "-Lbuilder-flag1") | ||
.must_have_in_order("-Lbuilder-flag1", "-Lbuilder-flag2") | ||
.must_have_in_order("-Lbuilder-flag2", "-Larbitrary1") | ||
.must_have_in_order("-Larbitrary1", "-Larbitrary2") | ||
.must_have_in_order("-Larbitrary1", "-Larbitrary2") | ||
.must_have_in_order("-Larbitrary2", "-Larbitrary3") | ||
.must_have_in_order("-Larbitrary3", "-Larbitrary4"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: maybe we could access .args
directly?
Line 20 in 0dd683c
pub args: Vec<String>, |
.must_have_in_order("-static", "-Lbuilder-flag1") | |
.must_have_in_order("-Lbuilder-flag1", "-Lbuilder-flag2") | |
.must_have_in_order("-Lbuilder-flag2", "-Larbitrary1") | |
.must_have_in_order("-Larbitrary1", "-Larbitrary2") | |
.must_have_in_order("-Larbitrary1", "-Larbitrary2") | |
.must_have_in_order("-Larbitrary2", "-Larbitrary3") | |
.must_have_in_order("-Larbitrary3", "-Larbitrary4"); | |
.args == [ | |
"-static", | |
"-Lbuilder-flag1", | |
"-Lbuilder-flag2", | |
"-Larbitrary1", | |
"-Larbitrary2", | |
"-Larbitrary3", | |
"-Larbitrary4", | |
] |
To allow flags set on the builder with
Build::flag
/Build::flag_if_supported
to override other flags, and to allowCFLAGS
to override all other flags.Found while doing #1401.
Now the order of flags are as follows, with later flags overriding previous ones. I've also here shown who "controls" which flag, to make it clear why we want the ordering to be like this.
cc-rs
.rustc
-inherited flagsrustc
.cc-rs
in e.g. theirbuild.rs
.