Skip to content

Commit

Permalink
Use protected symbols when building rustc_driver
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlattimore committed Oct 31, 2024
1 parent 759e07f commit 1441a82
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 19 deletions.
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,10 @@ pub fn rustc_cargo(
cargo.rustflag("-l").rustflag("Enzyme-19");
}

if builder.build.config.protected_symbol_definitions {
cargo.rustflag("-Zdefault-visibility=protected");
}

// We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
// and may just be a time sink.
if compiler.stage != 0 {
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ pub struct Config {
pub llvm_profile_generate: bool,
pub llvm_libunwind_default: Option<LlvmLibunwind>,
pub enable_bolt_settings: bool,
pub protected_symbol_definitions: bool,

pub reproducible_artifacts: Vec<String>,

Expand Down Expand Up @@ -1308,6 +1309,7 @@ impl Config {
config.llvm_profile_generate = flags.llvm_profile_generate;
config.enable_bolt_settings = flags.enable_bolt_settings;
config.bypass_bootstrap_lock = flags.bypass_bootstrap_lock;
config.protected_symbol_definitions = flags.protected_symbol_definitions;

// Infer the rest of the configuration.

Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/src/core/config/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ pub struct Flags {
/// Enable BOLT link flags
#[arg(global = true, long)]
pub enable_bolt_settings: bool,
/// Use protected symbol definitions in rustc_driver
#[arg(global = true, long, default_value_t = true)]
pub protected_symbol_definitions: bool,
/// Skip stage0 compiler validation
#[arg(global = true, long)]
pub skip_stage0_validation: bool,
Expand Down
20 changes: 19 additions & 1 deletion src/etc/completions/x.py.fish

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/etc/completions/x.py.ps1

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions src/etc/completions/x.py.sh

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/etc/completions/x.py.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ _x.py() {
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -99,6 +100,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -142,6 +144,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -191,6 +194,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -233,6 +237,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -277,6 +282,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -321,6 +327,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -376,6 +383,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -422,6 +430,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -465,6 +474,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -508,6 +518,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -550,6 +561,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -592,6 +604,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -635,6 +648,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -677,6 +691,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -721,6 +736,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -765,6 +781,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down Expand Up @@ -807,6 +824,7 @@ _arguments "${_arguments_options[@]}" : \
'--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)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--protected-symbol-definitions[Use protected symbol definitions in rustc_driver]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
Expand Down

0 comments on commit 1441a82

Please sign in to comment.