@@ -781,6 +781,10 @@ impl Options {
781781 } ,
782782 }
783783 }
784+
785+ pub fn get_symbol_mangling_version ( & self ) -> SymbolManglingVersion {
786+ self . cg . symbol_mangling_version . unwrap_or ( SymbolManglingVersion :: Legacy )
787+ }
784788}
785789
786790impl DebuggingOptions {
@@ -794,10 +798,6 @@ impl DebuggingOptions {
794798 deduplicate_diagnostics : self . deduplicate_diagnostics ,
795799 }
796800 }
797-
798- pub fn get_symbol_mangling_version ( & self ) -> SymbolManglingVersion {
799- self . symbol_mangling_version . unwrap_or ( SymbolManglingVersion :: Legacy )
800- }
801801}
802802
803803// 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 {
21162116 ) ;
21172117 }
21182118
2119+ // Handle both `-Z symbol-mangling-version` and `-C symbol-mangling-version`; the latter takes
2120+ // precedence.
2121+ match ( cg. symbol_mangling_version , debugging_opts. symbol_mangling_version ) {
2122+ ( Some ( smv_c) , Some ( smv_z) ) if smv_c != smv_z => {
2123+ early_error (
2124+ error_format,
2125+ "incompatible values passed for `-C symbol-mangling-version` \
2126+ and `-Z symbol-mangling-version`",
2127+ ) ;
2128+ }
2129+ ( Some ( SymbolManglingVersion :: V0 ) , _) => { }
2130+ ( Some ( _) , _) if !debugging_opts. unstable_options => {
2131+ early_error (
2132+ error_format,
2133+ "`-C symbol-mangling-version=legacy` requires `-Z unstable-options`" ,
2134+ ) ;
2135+ }
2136+ ( None , None ) => { }
2137+ ( None , smv) => {
2138+ early_warn (
2139+ error_format,
2140+ "`-Z symbol-mangling-version` is deprecated; use `-C symbol-mangling-version`" ,
2141+ ) ;
2142+ cg. symbol_mangling_version = smv;
2143+ }
2144+ _ => { }
2145+ }
2146+
21192147 if debugging_opts. instrument_coverage . is_some ( )
21202148 && debugging_opts. instrument_coverage != Some ( InstrumentCoverage :: Off )
21212149 {
@@ -2127,19 +2155,17 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
21272155 ) ;
21282156 }
21292157
2130- // `-Z instrument-coverage` implies `-Z symbol-mangling-version=v0` - to ensure consistent
2158+ // `-Z instrument-coverage` implies `-C symbol-mangling-version=v0` - to ensure consistent
21312159 // and reversible name mangling. Note, LLVM coverage tools can analyze coverage over
21322160 // multiple runs, including some changes to source code; so mangled names must be consistent
21332161 // across compilations.
2134- match debugging_opts. symbol_mangling_version {
2135- None => {
2136- debugging_opts. symbol_mangling_version = Some ( SymbolManglingVersion :: V0 ) ;
2137- }
2162+ match cg. symbol_mangling_version {
2163+ None => cg. symbol_mangling_version = Some ( SymbolManglingVersion :: V0 ) ,
21382164 Some ( SymbolManglingVersion :: Legacy ) => {
21392165 early_warn (
21402166 error_format,
21412167 "-Z instrument-coverage requires symbol mangling version `v0`, \
2142- but `-Z symbol-mangling-version=legacy` was specified",
2168+ but `-C symbol-mangling-version=legacy` was specified",
21432169 ) ;
21442170 }
21452171 Some ( SymbolManglingVersion :: V0 ) => { }
0 commit comments