Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
require -Z unstable-options to use the new flag values
only the stable values for `-Clinker-flavor` and `-Clink-self-contained`
can be used on stable until we have more feedback on the interface
  • Loading branch information
lqd committed Apr 27, 2022
commit 0a8bc98b490099bb4616785ef6c7fab980620fc3
34 changes: 32 additions & 2 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2580,9 +2580,19 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
);
}

// Until the unstable flag is removed, ensure `-Zgcc-ld=lld` and `-Clinker-flavor=gcc:lld` have
// a matching linker choice.
if let Some(LinkerFlavorCli::Gcc { use_ld }) = &cg.linker_flavor {
// For testing purposes, until we have more feedback about these options: ensure `-Z
// unstable-options` enabled when using the `gcc` linker flavor enrichments.
if !debugging_opts.unstable_options {
early_error(
error_format,
"the `gcc:*` linker flavor is unstable, the `-Z unstable-options` \
flag must also be passed to use it",
);
}

// Until the unstable flag is removed, ensure `-Zgcc-ld=lld` and `-Clinker-flavor=gcc:lld`
// have a matching linker choice.
if use_ld != "lld" && debugging_opts.gcc_ld == Some(LdImpl::Lld) {
early_error(
error_format,
Expand All @@ -2592,6 +2602,26 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
}
}

// For testing purposes, until we have more feedback about these options: ensure `-Z
// unstable-options` is enabled when using the unstable `-C link-self-contained` options.
if !debugging_opts.unstable_options {
let uses_unstable_self_contained_option =
matches.opt_strs("C").iter().any(|option| match option.as_str() {
"link-self-contained=crt"
| "link-self-contained=auto"
| "link-self-contained=linker"
| "link-self-contained=all" => true,
_ => false,
});
if uses_unstable_self_contained_option {
early_error(
error_format,
"only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off` are stable, \
the `-Z unstable-options` flag must also be passed to use the unstable values",
);
}
}

let prints = collect_print_requests(&mut cg, &mut debugging_opts, matches, error_format);

let cg = cg;
Expand Down