File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
compiler/rustc_session/src Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -2168,6 +2168,36 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
2168
2168
}
2169
2169
}
2170
2170
2171
+ if !debugging_opts. unstable_options {
2172
+ // if the user hasn't specified `-Z unstable-options`, then they need to have opted into
2173
+ // certain unstable variants of `-C prefer-dynamic` explicitly
2174
+ if let PreferDynamicSet :: Set ( s) = & cg. prefer_dynamic {
2175
+ if s. len ( ) == 1 && s. iter ( ) . next ( ) . map ( |s| s. as_str ( ) ) == Some ( "std" ) {
2176
+ // as a special case, `-C prefer-dynamic=std` gets its own `-Z` flag (because it is
2177
+ // on a shorter-term stabilization path).
2178
+ if debugging_opts. prefer_dynamic_std {
2179
+ // okay, user opted-into `-C prefer-dynamic=std` via `-Z prefer-dynamic-std`
2180
+ } else if debugging_opts. prefer_dynamic_subset {
2181
+ // okay, user opted-into arbitrary `-C prefer-dynamic=...` via `-Z prefer-dynamic-subset`
2182
+ } else {
2183
+ early_error (
2184
+ error_format,
2185
+ "`-C prefer-dynamic=std` is unstable: set `-Z prefer-dynamic-std`" ,
2186
+ ) ;
2187
+ }
2188
+ } else {
2189
+ if debugging_opts. prefer_dynamic_subset {
2190
+ // okay, user opted-into arbitrary `-C prefer-dynamic=...` via `-Z prefer-dynamic-subset`
2191
+ } else {
2192
+ early_error (
2193
+ error_format,
2194
+ "`-C prefer-dynamic=crate,...` is unstable: set `-Z prefer-dynamic-subset`" ,
2195
+ ) ;
2196
+ }
2197
+ }
2198
+ }
2199
+ }
2200
+
2171
2201
// Try to find a directory containing the Rust `src`, for more details see
2172
2202
// the doc comment on the `real_rust_source_base_dir` field.
2173
2203
let tmp_buf;
Original file line number Diff line number Diff line change @@ -1238,6 +1238,10 @@ options! {
1238
1238
"use a more precise version of drop elaboration for matches on enums (default: yes). \
1239
1239
This results in better codegen, but has caused miscompilations on some tier 2 platforms. \
1240
1240
See #77382 and #74551.") ,
1241
+ prefer_dynamic_std: bool = ( false , parse_bool, [ UNTRACKED ] ,
1242
+ "enable use of unstable `-C prefer-dynamic=std` variant" ) ,
1243
+ prefer_dynamic_subset: bool = ( false , parse_bool, [ UNTRACKED ] ,
1244
+ "enable use of unstable `-C prefer-dynamic=crate1,crate2,...` variant" ) ,
1241
1245
print_fuel: Option <String > = ( None , parse_opt_string, [ TRACKED ] ,
1242
1246
"make rustc print the total optimization fuel used by a crate" ) ,
1243
1247
print_link_args: bool = ( false , parse_bool, [ UNTRACKED ] ,
You can’t perform that action at this time.
0 commit comments