File tree 5 files changed +27
-2
lines changed
bootstrap/src/core/build_steps
5 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -1976,7 +1976,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
1976
1976
}
1977
1977
1978
1978
if builder. config . profiler_enabled ( target) {
1979
- cmd. env ( "RUSTC_PROFILER_SUPPORT" , "1 ") ;
1979
+ cmd. arg ( "--profiler-support ") ;
1980
1980
}
1981
1981
1982
1982
cmd. env ( "RUST_TEST_TMPDIR" , builder. tempdir ( ) ) ;
Original file line number Diff line number Diff line change @@ -387,6 +387,10 @@ pub struct Config {
387
387
// Needed both to construct build_helper::git::GitConfig
388
388
pub git_repository : String ,
389
389
pub nightly_branch : String ,
390
+
391
+ /// True if the profiler runtime is enabled for this target.
392
+ /// Used by the "needs-profiler-support" header in test files.
393
+ pub profiler_support : bool ,
390
394
}
391
395
392
396
impl Config {
Original file line number Diff line number Diff line change @@ -238,7 +238,7 @@ impl CachedNeedsConditions {
238
238
sanitizer_memtag : sanitizers. contains ( & Sanitizer :: Memtag ) ,
239
239
sanitizer_shadow_call_stack : sanitizers. contains ( & Sanitizer :: ShadowCallStack ) ,
240
240
sanitizer_safestack : sanitizers. contains ( & Sanitizer :: Safestack ) ,
241
- profiler_support : std :: env :: var_os ( "RUSTC_PROFILER_SUPPORT" ) . is_some ( ) ,
241
+ profiler_support : config . profiler_support ,
242
242
xray : config. target_cfg ( ) . xray ,
243
243
244
244
// For tests using the `needs-rust-lld` directive (e.g. for `-Clink-self-contained=+linker`),
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ struct ConfigBuilder {
62
62
llvm_version : Option < String > ,
63
63
git_hash : bool ,
64
64
system_llvm : bool ,
65
+ profiler_support : bool ,
65
66
}
66
67
67
68
impl ConfigBuilder {
@@ -100,6 +101,11 @@ impl ConfigBuilder {
100
101
self
101
102
}
102
103
104
+ fn profiler_support ( & mut self , s : bool ) -> & mut Self {
105
+ self . profiler_support = s;
106
+ self
107
+ }
108
+
103
109
fn build ( & mut self ) -> Config {
104
110
let args = & [
105
111
"compiletest" ,
@@ -142,6 +148,9 @@ impl ConfigBuilder {
142
148
if self . system_llvm {
143
149
args. push ( "--system-llvm" . to_owned ( ) ) ;
144
150
}
151
+ if self . profiler_support {
152
+ args. push ( "--profiler-support" . to_owned ( ) ) ;
153
+ }
145
154
146
155
args. push ( "--rustc-path" . to_string ( ) ) ;
147
156
// This is a subtle/fragile thing. On rust-lang CI, there is no global
@@ -340,6 +349,15 @@ fn sanitizers() {
340
349
assert ! ( check_ignore( & config, "// needs-sanitizer-thread" ) ) ;
341
350
}
342
351
352
+ #[ test]
353
+ fn profiler_support ( ) {
354
+ let config: Config = cfg ( ) . profiler_support ( false ) . build ( ) ;
355
+ assert ! ( check_ignore( & config, "// needs-profiler-support" ) ) ;
356
+
357
+ let config: Config = cfg ( ) . profiler_support ( true ) . build ( ) ;
358
+ assert ! ( !check_ignore( & config, "// needs-profiler-support" ) ) ;
359
+ }
360
+
343
361
#[ test]
344
362
fn asm_support ( ) {
345
363
let asms = [
Original file line number Diff line number Diff line change @@ -142,6 +142,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
142
142
. optflag ( "" , "force-rerun" , "rerun tests even if the inputs are unchanged" )
143
143
. optflag ( "" , "only-modified" , "only run tests that result been modified" )
144
144
. optflag ( "" , "nocapture" , "" )
145
+ . optflag ( "" , "profiler-support" , "is the profiler runtime enabled for this target" )
145
146
. optflag ( "h" , "help" , "show this message" )
146
147
. reqopt ( "" , "channel" , "current Rust channel" , "CHANNEL" )
147
148
. optflag ( "" , "git-hash" , "run tests which rely on commit version being compiled into the binaries" )
@@ -315,6 +316,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
315
316
316
317
git_repository : matches. opt_str ( "git-repository" ) . unwrap ( ) ,
317
318
nightly_branch : matches. opt_str ( "nightly-branch" ) . unwrap ( ) ,
319
+
320
+ profiler_support : matches. opt_present ( "profiler-support" ) ,
318
321
}
319
322
}
320
323
You can’t perform that action at this time.
0 commit comments