@@ -64,24 +64,21 @@ pub(crate) fn build_sysroot(
6464 fs:: create_dir_all ( & host_rustlib_lib) . unwrap ( ) ;
6565 fs:: create_dir_all ( & target_rustlib_lib) . unwrap ( ) ;
6666
67- if target_triple == "x86_64-pc-windows-gnu" {
68- if !default_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( & target_triple) . join ( "lib" ) . exists ( ) {
69- eprintln ! (
70- "The x86_64-pc-windows-gnu target needs to be installed first before it is possible \
71- to compile a sysroot for it.",
72- ) ;
73- process:: exit ( 1 ) ;
74- }
75- for file in fs:: read_dir (
76- default_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( & target_triple) . join ( "lib" ) ,
77- )
78- . unwrap ( )
79- {
80- let file = file. unwrap ( ) . path ( ) ;
81- if file. extension ( ) . map_or ( true , |ext| ext. to_str ( ) . unwrap ( ) != "o" ) {
82- continue ; // only copy object files
83- }
84- try_hard_link ( & file, target_rustlib_lib. join ( file. file_name ( ) . unwrap ( ) ) ) ;
67+ if target_triple. ends_with ( "windows-gnu" ) {
68+ eprintln ! ( "[BUILD] rtstartup for {target_triple}" ) ;
69+
70+ let rtstartup_src = SYSROOT_SRC . to_path ( dirs) . join ( "library" ) . join ( "rtstartup" ) ;
71+
72+ for file in [ "rsbegin" , "rsend" ] {
73+ let mut build_rtstartup_cmd = Command :: new ( & bootstrap_host_compiler. rustc ) ;
74+ build_rtstartup_cmd
75+ . arg ( "--target" )
76+ . arg ( & target_triple)
77+ . arg ( "--emit=obj" )
78+ . arg ( "-o" )
79+ . arg ( target_rustlib_lib. join ( format ! ( "{file}.o" ) ) )
80+ . arg ( rtstartup_src. join ( format ! ( "{file}.rs" ) ) ) ;
81+ spawn_and_wait ( build_rtstartup_cmd) ;
8582 }
8683 }
8784
@@ -209,6 +206,7 @@ fn build_clif_sysroot_for_triple(
209206 // Build sysroot
210207 let mut rustflags = " -Zforce-unstable-if-unmarked -Cpanic=abort" . to_string ( ) ;
211208 rustflags. push_str ( & format ! ( " -Zcodegen-backend={}" , cg_clif_dylib_path. to_str( ) . unwrap( ) ) ) ;
209+ // Necessary for MinGW to find rsbegin.o and rsend.o
212210 rustflags. push_str ( & format ! ( " --sysroot={}" , DIST_DIR . to_path( dirs) . to_str( ) . unwrap( ) ) ) ;
213211 if channel == "release" {
214212 rustflags. push_str ( " -Zmir-opt-level=3" ) ;
0 commit comments