Stabilize -Z symbol-mangling-version as -C symbol-mangling-version
This allows selecting `v0` symbol-mangling without an unstable option. Selecting `legacy` still requires -Z unstable-options. Continue supporting -Z symbol-mangling-version for compatibility for now, but show a deprecation warning for it.
This commit is contained in:
parent
c145692254
commit
bbf4b6699e
5 changed files with 42 additions and 12 deletions
|
@ -594,6 +594,7 @@ fn test_codegen_options_tracking_hash() {
|
||||||
tracked!(relocation_model, Some(RelocModel::Pic));
|
tracked!(relocation_model, Some(RelocModel::Pic));
|
||||||
tracked!(soft_float, true);
|
tracked!(soft_float, true);
|
||||||
tracked!(split_debuginfo, Some(SplitDebuginfo::Packed));
|
tracked!(split_debuginfo, Some(SplitDebuginfo::Packed));
|
||||||
|
tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
|
||||||
tracked!(target_cpu, Some(String::from("abc")));
|
tracked!(target_cpu, Some(String::from("abc")));
|
||||||
tracked!(target_feature, String::from("all the features, all of them"));
|
tracked!(target_feature, String::from("all the features, all of them"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -721,7 +721,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
no_builtins: tcx.sess.contains_name(&attrs, sym::no_builtins),
|
no_builtins: tcx.sess.contains_name(&attrs, sym::no_builtins),
|
||||||
panic_runtime: tcx.sess.contains_name(&attrs, sym::panic_runtime),
|
panic_runtime: tcx.sess.contains_name(&attrs, sym::panic_runtime),
|
||||||
profiler_runtime: tcx.sess.contains_name(&attrs, sym::profiler_runtime),
|
profiler_runtime: tcx.sess.contains_name(&attrs, sym::profiler_runtime),
|
||||||
symbol_mangling_version: tcx.sess.opts.debugging_opts.get_symbol_mangling_version(),
|
symbol_mangling_version: tcx.sess.opts.get_symbol_mangling_version(),
|
||||||
|
|
||||||
crate_deps,
|
crate_deps,
|
||||||
dylib_dependency_formats,
|
dylib_dependency_formats,
|
||||||
|
|
|
@ -781,6 +781,10 @@ impl Options {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion {
|
||||||
|
self.cg.symbol_mangling_version.unwrap_or(SymbolManglingVersion::Legacy)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DebuggingOptions {
|
impl DebuggingOptions {
|
||||||
|
@ -794,10 +798,6 @@ impl DebuggingOptions {
|
||||||
deduplicate_diagnostics: self.deduplicate_diagnostics,
|
deduplicate_diagnostics: self.deduplicate_diagnostics,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion {
|
|
||||||
self.symbol_mangling_version.unwrap_or(SymbolManglingVersion::Legacy)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The type of entry function, so users can have their own entry functions
|
// The type of entry function, so users can have their own entry functions
|
||||||
|
@ -2116,6 +2116,34 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle both `-Z symbol-mangling-version` and `-C symbol-mangling-version`; the latter takes
|
||||||
|
// precedence.
|
||||||
|
match (cg.symbol_mangling_version, debugging_opts.symbol_mangling_version) {
|
||||||
|
(Some(smv_c), Some(smv_z)) if smv_c != smv_z => {
|
||||||
|
early_error(
|
||||||
|
error_format,
|
||||||
|
"incompatible values passed for `-C symbol-mangling-version` \
|
||||||
|
and `-Z symbol-mangling-version`",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
(Some(SymbolManglingVersion::V0), _) => {}
|
||||||
|
(Some(_), _) if !debugging_opts.unstable_options => {
|
||||||
|
early_error(
|
||||||
|
error_format,
|
||||||
|
"`-C symbol-mangling-version=legacy` requires `-Z unstable-options`",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
(None, None) => {}
|
||||||
|
(None, smv) => {
|
||||||
|
early_warn(
|
||||||
|
error_format,
|
||||||
|
"`-Z symbol-mangling-version` is deprecated; use `-C symbol-mangling-version`",
|
||||||
|
);
|
||||||
|
cg.symbol_mangling_version = smv;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
if debugging_opts.instrument_coverage.is_some()
|
if debugging_opts.instrument_coverage.is_some()
|
||||||
&& debugging_opts.instrument_coverage != Some(InstrumentCoverage::Off)
|
&& debugging_opts.instrument_coverage != Some(InstrumentCoverage::Off)
|
||||||
{
|
{
|
||||||
|
@ -2127,19 +2155,17 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// `-Z instrument-coverage` implies `-Z symbol-mangling-version=v0` - to ensure consistent
|
// `-Z instrument-coverage` implies `-C symbol-mangling-version=v0` - to ensure consistent
|
||||||
// and reversible name mangling. Note, LLVM coverage tools can analyze coverage over
|
// and reversible name mangling. Note, LLVM coverage tools can analyze coverage over
|
||||||
// multiple runs, including some changes to source code; so mangled names must be consistent
|
// multiple runs, including some changes to source code; so mangled names must be consistent
|
||||||
// across compilations.
|
// across compilations.
|
||||||
match debugging_opts.symbol_mangling_version {
|
match cg.symbol_mangling_version {
|
||||||
None => {
|
None => cg.symbol_mangling_version = Some(SymbolManglingVersion::V0),
|
||||||
debugging_opts.symbol_mangling_version = Some(SymbolManglingVersion::V0);
|
|
||||||
}
|
|
||||||
Some(SymbolManglingVersion::Legacy) => {
|
Some(SymbolManglingVersion::Legacy) => {
|
||||||
early_warn(
|
early_warn(
|
||||||
error_format,
|
error_format,
|
||||||
"-Z instrument-coverage requires symbol mangling version `v0`, \
|
"-Z instrument-coverage requires symbol mangling version `v0`, \
|
||||||
but `-Z symbol-mangling-version=legacy` was specified",
|
but `-C symbol-mangling-version=legacy` was specified",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Some(SymbolManglingVersion::V0) => {}
|
Some(SymbolManglingVersion::V0) => {}
|
||||||
|
|
|
@ -1083,6 +1083,9 @@ options! {
|
||||||
"how to handle split-debuginfo, a platform-specific option"),
|
"how to handle split-debuginfo, a platform-specific option"),
|
||||||
strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
|
strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
|
||||||
"tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
|
"tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
|
||||||
|
symbol_mangling_version: Option<SymbolManglingVersion> = (None,
|
||||||
|
parse_symbol_mangling_version, [TRACKED],
|
||||||
|
"which mangling version to use for symbol names ('legacy' (default) or 'v0')"),
|
||||||
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
|
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
|
||||||
"select target processor (`rustc --print target-cpus` for details)"),
|
"select target processor (`rustc --print target-cpus` for details)"),
|
||||||
target_feature: String = (String::new(), parse_target_feature, [TRACKED],
|
target_feature: String = (String::new(), parse_target_feature, [TRACKED],
|
||||||
|
|
|
@ -245,7 +245,7 @@ fn compute_symbol_name<'tcx>(
|
||||||
// 2. we favor `instantiating_crate` where possible (i.e. when `Some`)
|
// 2. we favor `instantiating_crate` where possible (i.e. when `Some`)
|
||||||
let mangling_version_crate = instantiating_crate.unwrap_or(def_id.krate);
|
let mangling_version_crate = instantiating_crate.unwrap_or(def_id.krate);
|
||||||
let mangling_version = if mangling_version_crate == LOCAL_CRATE {
|
let mangling_version = if mangling_version_crate == LOCAL_CRATE {
|
||||||
tcx.sess.opts.debugging_opts.get_symbol_mangling_version()
|
tcx.sess.opts.get_symbol_mangling_version()
|
||||||
} else {
|
} else {
|
||||||
tcx.symbol_mangling_version(mangling_version_crate)
|
tcx.symbol_mangling_version(mangling_version_crate)
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue