File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -642,6 +642,7 @@ mod snapshot {
642642 } ;
643643 use crate :: core:: builder:: { Builder , Kind , StepDescription , StepMetadata } ;
644644 use crate :: core:: config:: TargetSelection ;
645+ use crate :: core:: config:: toml:: rust:: with_lld_opt_in_targets;
645646 use crate :: utils:: cache:: Cache ;
646647 use crate :: utils:: helpers:: get_host_target;
647648 use crate :: utils:: tests:: { ConfigBuilder , TestCtx } ;
@@ -1644,6 +1645,28 @@ mod snapshot {
16441645 " ) ;
16451646 }
16461647
1648+ #[ test]
1649+ fn test_lld_opt_in ( ) {
1650+ let target: & ' static str = Box :: leak ( Box :: new ( host_target ( ) ) ) ;
1651+ let slice: & ' static [ & ' static str ] = Box :: leak ( Box :: new ( [ target] ) ) ;
1652+
1653+ with_lld_opt_in_targets ( slice, || {
1654+ let ctx = TestCtx :: new ( ) ;
1655+
1656+ insta:: assert_snapshot!(
1657+ ctx. config( "doc" )
1658+ . path( "core" )
1659+ . override_target_no_std( & host_target( ) )
1660+ . render_steps( ) , @r"
1661+ [build] llvm <host>
1662+ [build] rustc 0 <host> -> rustc 1 <host>
1663+ [build] rustc 0 <host> -> LldWrapper 1 <host>
1664+ [build] rustdoc 0 <host>
1665+ [doc] std 1 <host> crates=[core]
1666+ " ) ;
1667+ } ) ;
1668+ }
1669+
16471670 #[ test]
16481671 fn doc_library_no_std_target ( ) {
16491672 let ctx = TestCtx :: new ( ) ;
Original file line number Diff line number Diff line change @@ -413,9 +413,25 @@ pub(crate) fn validate_codegen_backends(backends: Vec<String>, section: &str) ->
413413fn default_lld_opt_in_targets ( ) -> & ' static [ & ' static str ] {
414414 & [ "x86_64-unknown-linux-gnu" ]
415415}
416+
417+ #[ cfg( test) ]
418+ thread_local ! {
419+ static TEST_LLD_OPT_IN_TARGETS : std:: cell:: RefCell <Option <& ' static [ & ' static str ] >> = std:: cell:: RefCell :: new( None ) ;
420+ }
421+
416422#[ cfg( test) ]
417423fn default_lld_opt_in_targets ( ) -> & ' static [ & ' static str ] {
418- & [ ]
424+ TEST_LLD_OPT_IN_TARGETS . with ( |cell| cell. borrow ( ) . unwrap_or ( & [ ] ) )
425+ }
426+
427+ #[ cfg( test) ]
428+ pub fn with_lld_opt_in_targets < R > ( targets : & ' static [ & ' static str ] , f : impl FnOnce ( ) -> R ) -> R {
429+ TEST_LLD_OPT_IN_TARGETS . with ( |cell| {
430+ let prev = cell. replace ( Some ( targets) ) ;
431+ let result = f ( ) ;
432+ cell. replace ( prev) ;
433+ result
434+ } )
419435}
420436
421437impl Config {
You can’t perform that action at this time.
0 commit comments