@@ -291,6 +291,7 @@ pub struct Config {
291
291
pub rust_lto : RustcLto ,
292
292
pub rust_validate_mir_opts : Option < u32 > ,
293
293
pub rust_std_features : BTreeSet < String > ,
294
+ pub rust_use_protected_symbols : bool ,
294
295
pub llvm_profile_use : Option < String > ,
295
296
pub llvm_profile_generate : bool ,
296
297
pub llvm_libunwind_default : Option < LlvmLibunwind > ,
@@ -1166,6 +1167,7 @@ define_config! {
1166
1167
lto: Option <String > = "lto" ,
1167
1168
validate_mir_opts: Option <u32 > = "validate-mir-opts" ,
1168
1169
std_features: Option <BTreeSet <String >> = "std-features" ,
1170
+ use_protected_symbols: Option <bool > = "use-protected-symbols" ,
1169
1171
}
1170
1172
}
1171
1173
@@ -1223,6 +1225,7 @@ impl Config {
1223
1225
dist_include_mingw_linker : true ,
1224
1226
dist_compression_profile : "fast" . into ( ) ,
1225
1227
rustc_parallel : true ,
1228
+ rust_use_protected_symbols : false ,
1226
1229
1227
1230
stdout_is_tty : std:: io:: stdout ( ) . is_terminal ( ) ,
1228
1231
stderr_is_tty : std:: io:: stderr ( ) . is_terminal ( ) ,
@@ -1725,6 +1728,7 @@ impl Config {
1725
1728
strip,
1726
1729
lld_mode,
1727
1730
std_features : std_features_toml,
1731
+ use_protected_symbols,
1728
1732
} = rust;
1729
1733
1730
1734
is_user_configured_rust_channel = channel. is_some ( ) ;
@@ -1769,6 +1773,12 @@ impl Config {
1769
1773
set ( & mut config. lld_mode , lld_mode) ;
1770
1774
set ( & mut config. llvm_bitcode_linker_enabled , llvm_bitcode_linker) ;
1771
1775
1776
+ // Default to using protected symbols only when linking with LLD.
1777
+ if config. lld_mode != LldMode :: Unused {
1778
+ config. rust_use_protected_symbols = true ;
1779
+ }
1780
+ set ( & mut config. rust_use_protected_symbols , use_protected_symbols) ;
1781
+
1772
1782
config. rust_randomize_layout = randomize_layout. unwrap_or_default ( ) ;
1773
1783
config. llvm_tools_enabled = llvm_tools. unwrap_or ( true ) ;
1774
1784
config. rustc_parallel =
@@ -3102,6 +3112,7 @@ fn check_incompatible_options_for_ci_rustc(
3102
3112
download_rustc : _,
3103
3113
validate_mir_opts : _,
3104
3114
frame_pointers : _,
3115
+ use_protected_symbols : _,
3105
3116
} = ci_rust_config;
3106
3117
3107
3118
// There are two kinds of checks for CI rustc incompatible options:
0 commit comments