Skip to content

Commit 977730b

Browse files
Use protected symbols when building rustc_driver
1 parent 759e07f commit 977730b

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,10 @@ pub fn rustc_cargo(
10571057
cargo.rustflag("-l").rustflag("Enzyme-19");
10581058
}
10591059

1060+
if builder.build.config.protected_symbol_definitions {
1061+
cargo.rustflag("-Zdefault-visibility=protected");
1062+
}
1063+
10601064
// We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
10611065
// and may just be a time sink.
10621066
if compiler.stage != 0 {

src/bootstrap/src/core/config/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ pub struct Config {
295295
pub llvm_profile_generate: bool,
296296
pub llvm_libunwind_default: Option<LlvmLibunwind>,
297297
pub enable_bolt_settings: bool,
298+
pub protected_symbol_definitions: bool,
298299

299300
pub reproducible_artifacts: Vec<String>,
300301

@@ -1308,6 +1309,7 @@ impl Config {
13081309
config.llvm_profile_generate = flags.llvm_profile_generate;
13091310
config.enable_bolt_settings = flags.enable_bolt_settings;
13101311
config.bypass_bootstrap_lock = flags.bypass_bootstrap_lock;
1312+
config.protected_symbol_definitions = flags.protected_symbol_definitions;
13111313

13121314
// Infer the rest of the configuration.
13131315

src/bootstrap/src/core/config/flags.rs

+3
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ pub struct Flags {
161161
/// Enable BOLT link flags
162162
#[arg(global = true, long)]
163163
pub enable_bolt_settings: bool,
164+
/// Use protected symbol definitions in rustc_driver
165+
#[arg(global = true, long, default_value_t = true)]
166+
pub protected_symbol_definitions: bool,
164167
/// Skip stage0 compiler validation
165168
#[arg(global = true, long)]
166169
pub skip_stage0_validation: bool,

0 commit comments

Comments
 (0)