@@ -1776,93 +1776,16 @@ impl<'test> TestCx<'test> {
1776
1776
create_dir_all ( & aux_dir) . unwrap ( ) ;
1777
1777
}
1778
1778
1779
- // Use a Vec instead of a HashMap to preserve original order
1780
- let mut extern_priv = self . props . extern_private . clone ( ) ;
1781
-
1782
- let mut add_extern_priv = |priv_dep : & str , dylib : bool | {
1783
- let lib_name = get_lib_name ( priv_dep, dylib) ;
1784
- rustc
1785
- . arg ( "--extern" )
1786
- . arg ( format ! ( "priv:{}={}" , priv_dep, aux_dir. join( lib_name) . to_str( ) . unwrap( ) ) ) ;
1787
- } ;
1788
-
1789
1779
for rel_ab in & self . props . aux_builds {
1790
- let aux_testpaths = self . compute_aux_test_paths ( rel_ab) ;
1791
- let aux_props =
1792
- self . props
1793
- . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
1794
- let aux_output = TargetLocation :: ThisDirectory ( self . aux_output_dir_name ( ) ) ;
1795
- let aux_cx = TestCx {
1796
- config : self . config ,
1797
- props : & aux_props,
1798
- testpaths : & aux_testpaths,
1799
- revision : self . revision ,
1800
- } ;
1801
- // Create the directory for the stdout/stderr files.
1802
- create_dir_all ( aux_cx. output_base_dir ( ) ) . unwrap ( ) ;
1803
- let mut aux_rustc = aux_cx. make_compile_args ( & aux_testpaths. file , aux_output) ;
1804
-
1805
- let ( dylib, crate_type) = if aux_props. no_prefer_dynamic {
1806
- ( true , None )
1807
- } else if self . config . target . contains ( "cloudabi" )
1808
- || self . config . target . contains ( "emscripten" )
1809
- || ( self . config . target . contains ( "musl" )
1810
- && !aux_props. force_host
1811
- && !self . config . host . contains ( "musl" ) )
1812
- || self . config . target . contains ( "wasm32" )
1813
- || self . config . target . contains ( "nvptx" )
1814
- || self . is_vxworks_pure_static ( )
1815
- {
1816
- // We primarily compile all auxiliary libraries as dynamic libraries
1817
- // to avoid code size bloat and large binaries as much as possible
1818
- // for the test suite (otherwise including libstd statically in all
1819
- // executables takes up quite a bit of space).
1820
- //
1821
- // For targets like MUSL or Emscripten, however, there is no support for
1822
- // dynamic libraries so we just go back to building a normal library. Note,
1823
- // however, that for MUSL if the library is built with `force_host` then
1824
- // it's ok to be a dylib as the host should always support dylibs.
1825
- ( false , Some ( "lib" ) )
1826
- } else {
1827
- ( true , Some ( "dylib" ) )
1828
- } ;
1829
-
1830
- let trimmed = rel_ab. trim_end_matches ( ".rs" ) . to_string ( ) ;
1831
-
1832
- // Normally, every 'extern-private' has a corresponding 'aux-build'
1833
- // entry. If so, we remove it from our list of private crates,
1834
- // and add an '--extern priv:NAME=PATH' flag to rustc
1835
- if extern_priv. remove_item ( & trimmed) . is_some ( ) {
1836
- add_extern_priv ( & trimmed, dylib) ;
1837
- }
1838
-
1839
- if let Some ( crate_type) = crate_type {
1840
- aux_rustc. args ( & [ "--crate-type" , crate_type] ) ;
1841
- }
1842
-
1843
- aux_rustc. arg ( "-L" ) . arg ( & aux_dir) ;
1844
-
1845
- let auxres = aux_cx. compose_and_run (
1846
- aux_rustc,
1847
- aux_cx. config . compile_lib_path . to_str ( ) . unwrap ( ) ,
1848
- Some ( aux_dir. to_str ( ) . unwrap ( ) ) ,
1849
- None ,
1850
- ) ;
1851
- if !auxres. status . success ( ) {
1852
- self . fatal_proc_rec (
1853
- & format ! (
1854
- "auxiliary build of {:?} failed to compile: " ,
1855
- aux_testpaths. file. display( )
1856
- ) ,
1857
- & auxres,
1858
- ) ;
1859
- }
1780
+ self . build_auxiliary ( rel_ab, & aux_dir) ;
1860
1781
}
1861
1782
1862
- // Add any '--extern' private entries without a matching
1863
- // 'aux-build'
1864
- for private_lib in extern_priv {
1865
- add_extern_priv ( & private_lib, true ) ;
1783
+ for ( aux_name, aux_path) in & self . props . aux_crates {
1784
+ let is_dylib = self . build_auxiliary ( & aux_path, & aux_dir) ;
1785
+ let lib_name = get_lib_name ( & aux_path. trim_end_matches ( ".rs" ) . replace ( '-' , "_" ) ,
1786
+ is_dylib) ;
1787
+ rustc. arg ( "--extern" )
1788
+ . arg ( format ! ( "{}={}/{}" , aux_name, aux_dir. display( ) , lib_name) ) ;
1866
1789
}
1867
1790
1868
1791
self . props . unset_rustc_env . clone ( )
@@ -1877,6 +1800,74 @@ impl<'test> TestCx<'test> {
1877
1800
)
1878
1801
}
1879
1802
1803
+ /// Builds an aux dependency.
1804
+ ///
1805
+ /// Returns whether or not it is a dylib.
1806
+ fn build_auxiliary ( & self , source_path : & str , aux_dir : & Path ) -> bool {
1807
+ let aux_testpaths = self . compute_aux_test_paths ( source_path) ;
1808
+ let aux_props =
1809
+ self . props
1810
+ . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
1811
+ let aux_output = TargetLocation :: ThisDirectory ( self . aux_output_dir_name ( ) ) ;
1812
+ let aux_cx = TestCx {
1813
+ config : self . config ,
1814
+ props : & aux_props,
1815
+ testpaths : & aux_testpaths,
1816
+ revision : self . revision ,
1817
+ } ;
1818
+ // Create the directory for the stdout/stderr files.
1819
+ create_dir_all ( aux_cx. output_base_dir ( ) ) . unwrap ( ) ;
1820
+ let mut aux_rustc = aux_cx. make_compile_args ( & aux_testpaths. file , aux_output) ;
1821
+
1822
+ let ( dylib, crate_type) = if aux_props. no_prefer_dynamic {
1823
+ ( true , None )
1824
+ } else if self . config . target . contains ( "cloudabi" )
1825
+ || self . config . target . contains ( "emscripten" )
1826
+ || ( self . config . target . contains ( "musl" )
1827
+ && !aux_props. force_host
1828
+ && !self . config . host . contains ( "musl" ) )
1829
+ || self . config . target . contains ( "wasm32" )
1830
+ || self . config . target . contains ( "nvptx" )
1831
+ || self . is_vxworks_pure_static ( )
1832
+ {
1833
+ // We primarily compile all auxiliary libraries as dynamic libraries
1834
+ // to avoid code size bloat and large binaries as much as possible
1835
+ // for the test suite (otherwise including libstd statically in all
1836
+ // executables takes up quite a bit of space).
1837
+ //
1838
+ // For targets like MUSL or Emscripten, however, there is no support for
1839
+ // dynamic libraries so we just go back to building a normal library. Note,
1840
+ // however, that for MUSL if the library is built with `force_host` then
1841
+ // it's ok to be a dylib as the host should always support dylibs.
1842
+ ( false , Some ( "lib" ) )
1843
+ } else {
1844
+ ( true , Some ( "dylib" ) )
1845
+ } ;
1846
+
1847
+ if let Some ( crate_type) = crate_type {
1848
+ aux_rustc. args ( & [ "--crate-type" , crate_type] ) ;
1849
+ }
1850
+
1851
+ aux_rustc. arg ( "-L" ) . arg ( & aux_dir) ;
1852
+
1853
+ let auxres = aux_cx. compose_and_run (
1854
+ aux_rustc,
1855
+ aux_cx. config . compile_lib_path . to_str ( ) . unwrap ( ) ,
1856
+ Some ( aux_dir. to_str ( ) . unwrap ( ) ) ,
1857
+ None ,
1858
+ ) ;
1859
+ if !auxres. status . success ( ) {
1860
+ self . fatal_proc_rec (
1861
+ & format ! (
1862
+ "auxiliary build of {:?} failed to compile: " ,
1863
+ aux_testpaths. file. display( )
1864
+ ) ,
1865
+ & auxres,
1866
+ ) ;
1867
+ }
1868
+ dylib
1869
+ }
1870
+
1880
1871
fn compose_and_run (
1881
1872
& self ,
1882
1873
mut command : Command ,
0 commit comments