@@ -781,6 +781,10 @@ impl Options {
781
781
} ,
782
782
}
783
783
}
784
+
785
+ pub fn get_symbol_mangling_version ( & self ) -> SymbolManglingVersion {
786
+ self . cg . symbol_mangling_version . unwrap_or ( SymbolManglingVersion :: Legacy )
787
+ }
784
788
}
785
789
786
790
impl DebuggingOptions {
@@ -794,10 +798,6 @@ impl DebuggingOptions {
794
798
deduplicate_diagnostics : self . deduplicate_diagnostics ,
795
799
}
796
800
}
797
-
798
- pub fn get_symbol_mangling_version ( & self ) -> SymbolManglingVersion {
799
- self . symbol_mangling_version . unwrap_or ( SymbolManglingVersion :: Legacy )
800
- }
801
801
}
802
802
803
803
// 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 {
2116
2116
) ;
2117
2117
}
2118
2118
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
+
2119
2147
if debugging_opts. instrument_coverage . is_some ( )
2120
2148
&& debugging_opts. instrument_coverage != Some ( InstrumentCoverage :: Off )
2121
2149
{
@@ -2127,19 +2155,17 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
2127
2155
) ;
2128
2156
}
2129
2157
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
2131
2159
// and reversible name mangling. Note, LLVM coverage tools can analyze coverage over
2132
2160
// multiple runs, including some changes to source code; so mangled names must be consistent
2133
2161
// 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 ) ,
2138
2164
Some ( SymbolManglingVersion :: Legacy ) => {
2139
2165
early_warn (
2140
2166
error_format,
2141
2167
"-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",
2143
2169
) ;
2144
2170
}
2145
2171
Some ( SymbolManglingVersion :: V0 ) => { }
0 commit comments