@@ -146,7 +146,7 @@ impl Profiler {
146
146
147
147
// What cargo subcommand do we need to run for this profiler? If not
148
148
// `rustc`, must be a subcommand that itself invokes `rustc`.
149
- fn subcommand ( & self ) -> & ' static str {
149
+ fn subcommand ( & self , build_kind : BuildKind ) -> Option < & ' static str > {
150
150
match self {
151
151
Profiler :: PerfStat
152
152
| Profiler :: PerfStatSelfProfile
@@ -158,25 +158,17 @@ impl Profiler {
158
158
| Profiler :: Callgrind
159
159
| Profiler :: DHAT
160
160
| Profiler :: Massif
161
- | Profiler :: Eprintln => "rustc" ,
162
- Profiler :: LlvmLines => "llvm-lines" ,
163
- }
164
- }
165
-
166
- fn is_build_kind_allowed ( & self , build_kind : BuildKind ) -> bool {
167
- match self {
168
- Profiler :: PerfStat
169
- | Profiler :: PerfStatSelfProfile
170
- | Profiler :: SelfProfile
171
- | Profiler :: TimePasses
172
- | Profiler :: PerfRecord
173
- | Profiler :: OProfile
174
- | Profiler :: Cachegrind
175
- | Profiler :: Callgrind
176
- | Profiler :: DHAT
177
- | Profiler :: Massif
178
- | Profiler :: Eprintln => true ,
179
- Profiler :: LlvmLines => build_kind != BuildKind :: Check ,
161
+ | Profiler :: Eprintln => {
162
+ if build_kind == BuildKind :: Doc {
163
+ Some ( "rustdoc" )
164
+ } else {
165
+ Some ( "rustc" )
166
+ }
167
+ }
168
+ Profiler :: LlvmLines => match build_kind {
169
+ BuildKind :: Debug | BuildKind :: Opt => Some ( "rustc" ) ,
170
+ BuildKind :: Check | BuildKind :: Doc => None ,
171
+ } ,
180
172
}
181
173
}
182
174
@@ -242,6 +234,10 @@ impl<'a> CargoProcess<'a> {
242
234
. arg ( subcommand)
243
235
. arg ( "--manifest-path" )
244
236
. arg ( & self . manifest_path ) ;
237
+
238
+ if let Some ( r) = & self . compiler . rustdoc {
239
+ cmd. env ( "RUSTDOC" , & * FAKE_RUSTDOC ) . env ( "RUSTDOC_REAL" , r) ;
240
+ }
245
241
cmd
246
242
}
247
243
@@ -263,20 +259,22 @@ impl<'a> CargoProcess<'a> {
263
259
// machinery works).
264
260
let subcommand = if let Some ( ( ref mut processor, run_kind, ..) ) = self . processor_etc {
265
261
let profiler = processor. profiler ( ) ;
266
- if !profiler. is_build_kind_allowed ( self . build_kind ) {
267
- return Err ( anyhow:: anyhow!(
268
- "this profiler doesn't support {:?} builds" ,
269
- self . build_kind
270
- ) ) ;
271
- }
272
262
if !profiler. is_run_kind_allowed ( run_kind) {
273
263
return Err ( anyhow:: anyhow!(
274
264
"this profiler doesn't support {:?} runs" ,
275
265
run_kind
276
266
) ) ;
277
267
}
278
268
279
- profiler. subcommand ( )
269
+ match profiler. subcommand ( self . build_kind ) {
270
+ None => {
271
+ return Err ( anyhow:: anyhow!(
272
+ "this profiler doesn't support {:?} builds" ,
273
+ self . build_kind
274
+ ) )
275
+ }
276
+ Some ( sub) => sub,
277
+ }
280
278
} else {
281
279
"rustc"
282
280
} ;
@@ -288,6 +286,7 @@ impl<'a> CargoProcess<'a> {
288
286
cmd. arg ( "--profile" ) . arg ( "check" ) ;
289
287
}
290
288
BuildKind :: Debug => { }
289
+ BuildKind :: Doc => { }
291
290
BuildKind :: Opt => {
292
291
cmd. arg ( "--release" ) ;
293
292
}
@@ -301,8 +300,9 @@ impl<'a> CargoProcess<'a> {
301
300
// onto rustc for the final crate, which is exactly the crate for which
302
301
// we want to wrap rustc.
303
302
if let Some ( ( ref mut processor, ..) ) = self . processor_etc {
303
+ let profiler = processor. profiler ( ) . name ( ) ;
304
304
cmd. arg ( "--wrap-rustc-with" ) ;
305
- cmd. arg ( processor . profiler ( ) . name ( ) ) ;
305
+ cmd. arg ( profiler) ;
306
306
cmd. args ( & self . rustc_args ) ;
307
307
}
308
308
@@ -349,6 +349,21 @@ lazy_static::lazy_static! {
349
349
fake_rustc. push( "rustc-fake" ) ;
350
350
fake_rustc
351
351
} ;
352
+ static ref FAKE_RUSTDOC : PathBuf = {
353
+ let mut fake_rustdoc = env:: current_exe( ) . unwrap( ) ;
354
+ fake_rustdoc. pop( ) ;
355
+ fake_rustdoc. push( "rustdoc-fake" ) ;
356
+ // link from rustc-fake to rustdoc-fake
357
+ if !fake_rustdoc. exists( ) {
358
+ #[ cfg( unix) ]
359
+ use std:: os:: unix:: fs:: symlink;
360
+ #[ cfg( windows) ]
361
+ use std:: os:: windows:: fs:: symlink_file as symlink;
362
+
363
+ symlink( & * FAKE_RUSTC , & fake_rustdoc) . expect( "failed to make symbolic link" ) ;
364
+ }
365
+ fake_rustdoc
366
+ } ;
352
367
}
353
368
354
369
/// Used to indicate if we need to retry a run.
@@ -448,6 +463,7 @@ impl<'a> MeasureProcessor<'a> {
448
463
let profile = match build_kind {
449
464
BuildKind :: Check => database:: Profile :: Check ,
450
465
BuildKind :: Debug => database:: Profile :: Debug ,
466
+ BuildKind :: Doc => database:: Profile :: Doc ,
451
467
BuildKind :: Opt => database:: Profile :: Opt ,
452
468
} ;
453
469
let mut buf = FuturesUnordered :: new ( ) ;
0 commit comments