@@ -2580,9 +2580,19 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
25802580 ) ;
25812581 }
25822582
2583- // Until the unstable flag is removed, ensure `-Zgcc-ld=lld` and `-Clinker-flavor=gcc:lld` have
2584- // a matching linker choice.
25852583 if let Some ( LinkerFlavorCli :: Gcc { use_ld } ) = & cg. linker_flavor {
2584+ // For testing purposes, until we have more feedback about these options: ensure `-Z
2585+ // unstable-options` enabled when using the `gcc` linker flavor enrichments.
2586+ if !debugging_opts. unstable_options {
2587+ early_error (
2588+ error_format,
2589+ "the `gcc:*` linker flavor is unstable, the `-Z unstable-options` \
2590+ flag must also be passed to use it",
2591+ ) ;
2592+ }
2593+
2594+ // Until the unstable flag is removed, ensure `-Zgcc-ld=lld` and `-Clinker-flavor=gcc:lld`
2595+ // have a matching linker choice.
25862596 if use_ld != "lld" && debugging_opts. gcc_ld == Some ( LdImpl :: Lld ) {
25872597 early_error (
25882598 error_format,
@@ -2592,6 +2602,26 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
25922602 }
25932603 }
25942604
2605+ // For testing purposes, until we have more feedback about these options: ensure `-Z
2606+ // unstable-options` is enabled when using the unstable `-C link-self-contained` options.
2607+ if !debugging_opts. unstable_options {
2608+ let uses_unstable_self_contained_option =
2609+ matches. opt_strs ( "C" ) . iter ( ) . any ( |option| match option. as_str ( ) {
2610+ "link-self-contained=crt"
2611+ | "link-self-contained=auto"
2612+ | "link-self-contained=linker"
2613+ | "link-self-contained=all" => true ,
2614+ _ => false ,
2615+ } ) ;
2616+ if uses_unstable_self_contained_option {
2617+ early_error (
2618+ error_format,
2619+ "only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off` are stable, \
2620+ the `-Z unstable-options` flag must also be passed to use the unstable values",
2621+ ) ;
2622+ }
2623+ }
2624+
25952625 let prints = collect_print_requests ( & mut cg, & mut debugging_opts, matches, error_format) ;
25962626
25972627 let cg = cg;
0 commit comments