@@ -19,11 +19,11 @@ use crate::config::TargetSelection;
19
19
use crate :: dist;
20
20
use crate :: doc:: DocumentationFormat ;
21
21
use crate :: flags:: Subcommand ;
22
- use crate :: native ;
22
+ use crate :: llvm ;
23
23
use crate :: render_tests:: add_flags_and_try_run_tests;
24
24
use crate :: tool:: { self , SourceType , Tool } ;
25
25
use crate :: toolstate:: ToolState ;
26
- use crate :: util:: { self , add_link_lib_path, dylib_path, dylib_path_var, output, t} ;
26
+ use crate :: util:: { self , add_link_lib_path, dylib_path, dylib_path_var, output, t, up_to_date } ;
27
27
use crate :: { envify, CLang , DocTests , GitRepo , Mode } ;
28
28
29
29
const ADB_TEST_DIR : & str = "/data/local/tmp/work" ;
@@ -1434,11 +1434,11 @@ note: if you're sure you want to do this, please open an issue as to why. In the
1434
1434
builder. ensure ( compile:: Std :: new ( compiler, compiler. host ) ) ;
1435
1435
1436
1436
// Also provide `rust_test_helpers` for the host.
1437
- builder. ensure ( native :: TestHelpers { target : compiler. host } ) ;
1437
+ builder. ensure ( TestHelpers { target : compiler. host } ) ;
1438
1438
1439
1439
// As well as the target, except for plain wasm32, which can't build it
1440
1440
if !target. contains ( "wasm" ) || target. contains ( "emscripten" ) {
1441
- builder. ensure ( native :: TestHelpers { target } ) ;
1441
+ builder. ensure ( TestHelpers { target } ) ;
1442
1442
}
1443
1443
1444
1444
builder. ensure ( RemoteCopyLibs { compiler, target } ) ;
@@ -1625,8 +1625,8 @@ note: if you're sure you want to do this, please open an issue as to why. In the
1625
1625
let mut llvm_components_passed = false ;
1626
1626
let mut copts_passed = false ;
1627
1627
if builder. config . llvm_enabled ( ) {
1628
- let native :: LlvmResult { llvm_config, .. } =
1629
- builder. ensure ( native :: Llvm { target : builder. config . build } ) ;
1628
+ let llvm :: LlvmResult { llvm_config, .. } =
1629
+ builder. ensure ( llvm :: Llvm { target : builder. config . build } ) ;
1630
1630
if !builder. config . dry_run ( ) {
1631
1631
let llvm_version = output ( Command :: new ( & llvm_config) . arg ( "--version" ) ) ;
1632
1632
let llvm_components = output ( Command :: new ( & llvm_config) . arg ( "--components" ) ) ;
@@ -1664,7 +1664,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
1664
1664
// If LLD is available, add it to the PATH
1665
1665
if builder. config . lld_enabled {
1666
1666
let lld_install_root =
1667
- builder. ensure ( native :: Lld { target : builder. config . build } ) ;
1667
+ builder. ensure ( llvm :: Lld { target : builder. config . build } ) ;
1668
1668
1669
1669
let lld_bin_path = lld_install_root. join ( "bin" ) ;
1670
1670
@@ -2747,3 +2747,68 @@ impl Step for RustInstaller {
2747
2747
run. builder . ensure ( Self ) ;
2748
2748
}
2749
2749
}
2750
+
2751
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
2752
+ pub struct TestHelpers {
2753
+ pub target : TargetSelection ,
2754
+ }
2755
+
2756
+ impl Step for TestHelpers {
2757
+ type Output = ( ) ;
2758
+
2759
+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
2760
+ run. path ( "tests/auxiliary/rust_test_helpers.c" )
2761
+ }
2762
+
2763
+ fn make_run ( run : RunConfig < ' _ > ) {
2764
+ run. builder . ensure ( TestHelpers { target : run. target } )
2765
+ }
2766
+
2767
+ /// Compiles the `rust_test_helpers.c` library which we used in various
2768
+ /// `run-pass` tests for ABI testing.
2769
+ fn run ( self , builder : & Builder < ' _ > ) {
2770
+ if builder. config . dry_run ( ) {
2771
+ return ;
2772
+ }
2773
+ // The x86_64-fortanix-unknown-sgx target doesn't have a working C
2774
+ // toolchain. However, some x86_64 ELF objects can be linked
2775
+ // without issues. Use this hack to compile the test helpers.
2776
+ let target = if self . target == "x86_64-fortanix-unknown-sgx" {
2777
+ TargetSelection :: from_user ( "x86_64-unknown-linux-gnu" )
2778
+ } else {
2779
+ self . target
2780
+ } ;
2781
+ let dst = builder. test_helpers_out ( target) ;
2782
+ let src = builder. src . join ( "tests/auxiliary/rust_test_helpers.c" ) ;
2783
+ if up_to_date ( & src, & dst. join ( "librust_test_helpers.a" ) ) {
2784
+ return ;
2785
+ }
2786
+
2787
+ builder. info ( "Building test helpers" ) ;
2788
+ t ! ( fs:: create_dir_all( & dst) ) ;
2789
+ let mut cfg = cc:: Build :: new ( ) ;
2790
+ // FIXME: Workaround for https://github.com/emscripten-core/emscripten/issues/9013
2791
+ if target. contains ( "emscripten" ) {
2792
+ cfg. pic ( false ) ;
2793
+ }
2794
+
2795
+ // We may have found various cross-compilers a little differently due to our
2796
+ // extra configuration, so inform cc of these compilers. Note, though, that
2797
+ // on MSVC we still need cc's detection of env vars (ugh).
2798
+ if !target. contains ( "msvc" ) {
2799
+ if let Some ( ar) = builder. ar ( target) {
2800
+ cfg. archiver ( ar) ;
2801
+ }
2802
+ cfg. compiler ( builder. cc ( target) ) ;
2803
+ }
2804
+ cfg. cargo_metadata ( false )
2805
+ . out_dir ( & dst)
2806
+ . target ( & target. triple )
2807
+ . host ( & builder. config . build . triple )
2808
+ . opt_level ( 0 )
2809
+ . warnings ( false )
2810
+ . debug ( false )
2811
+ . file ( builder. src . join ( "tests/auxiliary/rust_test_helpers.c" ) )
2812
+ . compile ( "rust_test_helpers" ) ;
2813
+ }
2814
+ }
0 commit comments