Skip to content

Commit

Permalink
Auto merge of rust-lang#90054 - michaelwoerister:v0-mangling-in-compi…
Browse files Browse the repository at this point in the history
…ler, r=Mark-Simulacrum

Make new symbol mangling scheme default for compiler itself.

As suggest in rust-lang#89917 (comment), this PR enables the new symbol mangling scheme for the compiler itself. The standard library is still compiled using the legacy mangling scheme so that the new symbol format does not show up in user code (yet).

r? `@Mark-Simulacrum`
  • Loading branch information
bors committed Oct 23, 2021
2 parents 514b387 + 456283c commit a3f7c4d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 5 additions & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,11 @@ changelog-seen = 2

# Enable symbol-mangling-version v0. This can be helpful when profiling rustc,
# as generics will be preserved in symbols (rather than erased into opaque T).
#new-symbol-mangling = false
# When no setting is given, the new scheme will be used when compiling the
# compiler and its tools and the legacy scheme will be used when compiling the
# standard library.
# If an explicit setting is given, it will be used for all parts of the codebase.
#new-symbol-mangling = true|false (see comment)

# =============================================================================
# Options for specific targets
Expand Down
20 changes: 19 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,26 @@ impl<'a> Builder<'a> {
}
}

if self.config.rust_new_symbol_mangling {
let use_new_symbol_mangling = match self.config.rust_new_symbol_mangling {
Some(setting) => {
// If an explicit setting is given, use that
setting
}
None => {
if mode == Mode::Std {
// The standard library defaults to the legacy scheme
false
} else {
// The compiler and tools default to the new scheme
true
}
}
};

if use_new_symbol_mangling {
rustflags.arg("-Zsymbol-mangling-version=v0");
} else {
rustflags.arg("-Zsymbol-mangling-version=legacy");
}

// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub struct Config {
pub rust_verify_llvm_ir: bool,
pub rust_thin_lto_import_instr_limit: Option<u32>,
pub rust_remap_debuginfo: bool,
pub rust_new_symbol_mangling: bool,
pub rust_new_symbol_mangling: Option<bool>,
pub rust_profile_use: Option<String>,
pub rust_profile_generate: Option<String>,
pub llvm_profile_use: Option<String>,
Expand Down Expand Up @@ -874,7 +874,7 @@ impl Config {
config.rust_run_dsymutil = rust.run_dsymutil.unwrap_or(false);
optimize = rust.optimize;
ignore_git = rust.ignore_git;
set(&mut config.rust_new_symbol_mangling, rust.new_symbol_mangling);
config.rust_new_symbol_mangling = rust.new_symbol_mangling;
set(&mut config.rust_optimize_tests, rust.optimize_tests);
set(&mut config.codegen_tests, rust.codegen_tests);
set(&mut config.rust_rpath, rust.rpath);
Expand Down

0 comments on commit a3f7c4d

Please sign in to comment.