Skip to content

Commit 1441a82

Browse files
Use protected symbols when building rustc_driver
1 parent 759e07f commit 1441a82

File tree

7 files changed

+82
-19
lines changed

7 files changed

+82
-19
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,

src/etc/completions/x.py.fish

+19-1
Large diffs are not rendered by default.

src/etc/completions/x.py.ps1

+18
Large diffs are not rendered by default.

src/etc/completions/x.py.sh

+18-18
Large diffs are not rendered by default.

src/etc/completions/x.py.zsh

+18
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ _x.py() {
4949
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
5050
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
5151
'--enable-bolt-settings[Enable BOLT link flags]' \
52+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
5253
'--skip-stage0-validation[Skip stage0 compiler validation]' \
5354
'-h[Print help (see more with '\''--help'\'')]' \
5455
'--help[Print help (see more with '\''--help'\'')]' \
@@ -99,6 +100,7 @@ _arguments "${_arguments_options[@]}" : \
99100
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
100101
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
101102
'--enable-bolt-settings[Enable BOLT link flags]' \
103+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
102104
'--skip-stage0-validation[Skip stage0 compiler validation]' \
103105
'-h[Print help (see more with '\''--help'\'')]' \
104106
'--help[Print help (see more with '\''--help'\'')]' \
@@ -142,6 +144,7 @@ _arguments "${_arguments_options[@]}" : \
142144
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
143145
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
144146
'--enable-bolt-settings[Enable BOLT link flags]' \
147+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
145148
'--skip-stage0-validation[Skip stage0 compiler validation]' \
146149
'-h[Print help (see more with '\''--help'\'')]' \
147150
'--help[Print help (see more with '\''--help'\'')]' \
@@ -191,6 +194,7 @@ _arguments "${_arguments_options[@]}" : \
191194
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
192195
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
193196
'--enable-bolt-settings[Enable BOLT link flags]' \
197+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
194198
'--skip-stage0-validation[Skip stage0 compiler validation]' \
195199
'-h[Print help (see more with '\''--help'\'')]' \
196200
'--help[Print help (see more with '\''--help'\'')]' \
@@ -233,6 +237,7 @@ _arguments "${_arguments_options[@]}" : \
233237
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
234238
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
235239
'--enable-bolt-settings[Enable BOLT link flags]' \
240+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
236241
'--skip-stage0-validation[Skip stage0 compiler validation]' \
237242
'-h[Print help (see more with '\''--help'\'')]' \
238243
'--help[Print help (see more with '\''--help'\'')]' \
@@ -277,6 +282,7 @@ _arguments "${_arguments_options[@]}" : \
277282
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
278283
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
279284
'--enable-bolt-settings[Enable BOLT link flags]' \
285+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
280286
'--skip-stage0-validation[Skip stage0 compiler validation]' \
281287
'-h[Print help (see more with '\''--help'\'')]' \
282288
'--help[Print help (see more with '\''--help'\'')]' \
@@ -321,6 +327,7 @@ _arguments "${_arguments_options[@]}" : \
321327
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
322328
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
323329
'--enable-bolt-settings[Enable BOLT link flags]' \
330+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
324331
'--skip-stage0-validation[Skip stage0 compiler validation]' \
325332
'-h[Print help (see more with '\''--help'\'')]' \
326333
'--help[Print help (see more with '\''--help'\'')]' \
@@ -376,6 +383,7 @@ _arguments "${_arguments_options[@]}" : \
376383
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
377384
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
378385
'--enable-bolt-settings[Enable BOLT link flags]' \
386+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
379387
'--skip-stage0-validation[Skip stage0 compiler validation]' \
380388
'-h[Print help (see more with '\''--help'\'')]' \
381389
'--help[Print help (see more with '\''--help'\'')]' \
@@ -422,6 +430,7 @@ _arguments "${_arguments_options[@]}" : \
422430
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
423431
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
424432
'--enable-bolt-settings[Enable BOLT link flags]' \
433+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
425434
'--skip-stage0-validation[Skip stage0 compiler validation]' \
426435
'-h[Print help (see more with '\''--help'\'')]' \
427436
'--help[Print help (see more with '\''--help'\'')]' \
@@ -465,6 +474,7 @@ _arguments "${_arguments_options[@]}" : \
465474
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
466475
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
467476
'--enable-bolt-settings[Enable BOLT link flags]' \
477+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
468478
'--skip-stage0-validation[Skip stage0 compiler validation]' \
469479
'-h[Print help (see more with '\''--help'\'')]' \
470480
'--help[Print help (see more with '\''--help'\'')]' \
@@ -508,6 +518,7 @@ _arguments "${_arguments_options[@]}" : \
508518
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
509519
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
510520
'--enable-bolt-settings[Enable BOLT link flags]' \
521+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
511522
'--skip-stage0-validation[Skip stage0 compiler validation]' \
512523
'-h[Print help (see more with '\''--help'\'')]' \
513524
'--help[Print help (see more with '\''--help'\'')]' \
@@ -550,6 +561,7 @@ _arguments "${_arguments_options[@]}" : \
550561
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
551562
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
552563
'--enable-bolt-settings[Enable BOLT link flags]' \
564+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
553565
'--skip-stage0-validation[Skip stage0 compiler validation]' \
554566
'-h[Print help (see more with '\''--help'\'')]' \
555567
'--help[Print help (see more with '\''--help'\'')]' \
@@ -592,6 +604,7 @@ _arguments "${_arguments_options[@]}" : \
592604
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
593605
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
594606
'--enable-bolt-settings[Enable BOLT link flags]' \
607+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
595608
'--skip-stage0-validation[Skip stage0 compiler validation]' \
596609
'-h[Print help (see more with '\''--help'\'')]' \
597610
'--help[Print help (see more with '\''--help'\'')]' \
@@ -635,6 +648,7 @@ _arguments "${_arguments_options[@]}" : \
635648
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
636649
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
637650
'--enable-bolt-settings[Enable BOLT link flags]' \
651+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
638652
'--skip-stage0-validation[Skip stage0 compiler validation]' \
639653
'-h[Print help (see more with '\''--help'\'')]' \
640654
'--help[Print help (see more with '\''--help'\'')]' \
@@ -677,6 +691,7 @@ _arguments "${_arguments_options[@]}" : \
677691
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
678692
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
679693
'--enable-bolt-settings[Enable BOLT link flags]' \
694+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
680695
'--skip-stage0-validation[Skip stage0 compiler validation]' \
681696
'-h[Print help (see more with '\''--help'\'')]' \
682697
'--help[Print help (see more with '\''--help'\'')]' \
@@ -721,6 +736,7 @@ _arguments "${_arguments_options[@]}" : \
721736
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
722737
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
723738
'--enable-bolt-settings[Enable BOLT link flags]' \
739+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
724740
'--skip-stage0-validation[Skip stage0 compiler validation]' \
725741
'-h[Print help (see more with '\''--help'\'')]' \
726742
'--help[Print help (see more with '\''--help'\'')]' \
@@ -765,6 +781,7 @@ _arguments "${_arguments_options[@]}" : \
765781
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
766782
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
767783
'--enable-bolt-settings[Enable BOLT link flags]' \
784+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
768785
'--skip-stage0-validation[Skip stage0 compiler validation]' \
769786
'-h[Print help (see more with '\''--help'\'')]' \
770787
'--help[Print help (see more with '\''--help'\'')]' \
@@ -807,6 +824,7 @@ _arguments "${_arguments_options[@]}" : \
807824
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
808825
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
809826
'--enable-bolt-settings[Enable BOLT link flags]' \
827+
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
810828
'--skip-stage0-validation[Skip stage0 compiler validation]' \
811829
'-h[Print help (see more with '\''--help'\'')]' \
812830
'--help[Print help (see more with '\''--help'\'')]' \

0 commit comments

Comments
 (0)