@@ -127,15 +127,15 @@ pub enum MirSpanview {
127
127
Block ,
128
128
}
129
129
130
- /// The different settings that the `-Z instrument-coverage` flag can have.
130
+ /// The different settings that the `-C instrument-coverage` flag can have.
131
131
///
132
- /// Coverage instrumentation now supports combining `-Z instrument-coverage`
132
+ /// Coverage instrumentation now supports combining `-C instrument-coverage`
133
133
/// with compiler and linker optimization (enabled with `-O` or `-C opt-level=1`
134
134
/// and higher). Nevertheless, there are many variables, depending on options
135
135
/// selected, code structure, and enabled attributes. If errors are encountered,
136
136
/// either while compiling or when generating `llvm-cov show` reports, consider
137
137
/// lowering the optimization level, including or excluding `-C link-dead-code`,
138
- /// or using `-Z instrument-coverage=except-unused-functions` or `-Z
138
+ /// or using `-C instrument-coverage=except-unused-functions` or `-C
139
139
/// instrument-coverage=except-unused-generics`.
140
140
///
141
141
/// Note that `ExceptUnusedFunctions` means: When `mapgen.rs` generates the
@@ -148,13 +148,13 @@ pub enum MirSpanview {
148
148
/// unless the function has type parameters.
149
149
#[ derive( Clone , Copy , PartialEq , Hash , Debug ) ]
150
150
pub enum InstrumentCoverage {
151
- /// Default `-Z instrument-coverage` or `-Z instrument-coverage=statement`
151
+ /// Default `-C instrument-coverage` or `-C instrument-coverage=statement`
152
152
All ,
153
- /// `-Z instrument-coverage=except-unused-generics`
153
+ /// `-C instrument-coverage=except-unused-generics`
154
154
ExceptUnusedGenerics ,
155
- /// `-Z instrument-coverage=except-unused-functions`
155
+ /// `-C instrument-coverage=except-unused-functions`
156
156
ExceptUnusedFunctions ,
157
- /// `-Z instrument-coverage=off` (or `no`, etc.)
157
+ /// `-C instrument-coverage=off` (or `no`, etc.)
158
158
Off ,
159
159
}
160
160
@@ -2144,18 +2144,37 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
2144
2144
_ => { }
2145
2145
}
2146
2146
2147
- if debugging_opts. instrument_coverage . is_some ( )
2148
- && debugging_opts. instrument_coverage != Some ( InstrumentCoverage :: Off )
2149
- {
2147
+ // Handle both `-Z instrument-coverage` and `-C instrument-coverage`; the latter takes
2148
+ // precedence.
2149
+ match ( cg. instrument_coverage , debugging_opts. instrument_coverage ) {
2150
+ ( Some ( ic_c) , Some ( ic_z) ) if ic_c != ic_z => {
2151
+ early_error (
2152
+ error_format,
2153
+ "incompatible values passed for `-C instrument-coverage` \
2154
+ and `-Z instrument-coverage`",
2155
+ ) ;
2156
+ }
2157
+ ( None , None ) => { }
2158
+ ( None , ic) => {
2159
+ early_warn (
2160
+ error_format,
2161
+ "`-Z instrument-coverage` is deprecated; use `-C instrument-coverage`" ,
2162
+ ) ;
2163
+ cg. instrument_coverage = ic;
2164
+ }
2165
+ _ => { }
2166
+ }
2167
+
2168
+ if cg. instrument_coverage . is_some ( ) && cg. instrument_coverage != Some ( InstrumentCoverage :: Off ) {
2150
2169
if cg. profile_generate . enabled ( ) || cg. profile_use . is_some ( ) {
2151
2170
early_error (
2152
2171
error_format,
2153
- "option `-Z instrument-coverage` is not compatible with either `-C profile-use` \
2172
+ "option `-C instrument-coverage` is not compatible with either `-C profile-use` \
2154
2173
or `-C profile-generate`",
2155
2174
) ;
2156
2175
}
2157
2176
2158
- // `-Z instrument-coverage` implies `-C symbol-mangling-version=v0` - to ensure consistent
2177
+ // `-C instrument-coverage` implies `-C symbol-mangling-version=v0` - to ensure consistent
2159
2178
// and reversible name mangling. Note, LLVM coverage tools can analyze coverage over
2160
2179
// multiple runs, including some changes to source code; so mangled names must be consistent
2161
2180
// across compilations.
@@ -2164,7 +2183,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
2164
2183
Some ( SymbolManglingVersion :: Legacy ) => {
2165
2184
early_warn (
2166
2185
error_format,
2167
- "-Z instrument-coverage requires symbol mangling version `v0`, \
2186
+ "-C instrument-coverage requires symbol mangling version `v0`, \
2168
2187
but `-C symbol-mangling-version=legacy` was specified",
2169
2188
) ;
2170
2189
}
0 commit comments