This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,6 @@ fn main() {
9595 // When statically linking `std` into `rustc_driver`, remove `-C prefer-dynamic`
9696 if env:: var ( "RUSTC_LINK_STD_INTO_RUSTC_DRIVER" ) . unwrap ( ) == "1"
9797 && crate_name == Some ( "rustc_driver" )
98- && stage != "0"
9998 {
10099 if let Some ( pos) = args. iter ( ) . enumerate ( ) . position ( |( i, a) | {
101100 a == "-C" && args. get ( i + 1 ) . map ( |a| a == "prefer-dynamic" ) . unwrap_or ( false )
Original file line number Diff line number Diff line change @@ -1923,8 +1923,24 @@ impl Step for Assemble {
19231923 let src_libdir = builder. sysroot_libdir ( build_compiler, host) ;
19241924 for f in builder. read_dir ( & src_libdir) {
19251925 let filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ;
1926- if ( is_dylib ( & filename) || is_debug_info ( & filename) ) && !proc_macros. contains ( & filename)
1926+
1927+ let is_proc_macro = proc_macros. contains ( & filename) ;
1928+ let is_dylib_or_debug = is_dylib ( & filename) || is_debug_info ( & filename) ;
1929+
1930+ // If we link statically to stdlib, do not copy the libstd dynamic library file
1931+ // FIXME: Also do this for Windows once incremental post-optimization stage0 tests
1932+ // work without std.dll (see https://github.com/rust-lang/rust/pull/131188).
1933+ let can_be_rustc_dynamic_dep = if builder
1934+ . link_std_into_rustc_driver ( target_compiler. host )
1935+ && !target_compiler. host . is_windows ( )
19271936 {
1937+ let is_std = filename. starts_with ( "std-" ) || filename. starts_with ( "libstd-" ) ;
1938+ !is_std
1939+ } else {
1940+ true
1941+ } ;
1942+
1943+ if is_dylib_or_debug && can_be_rustc_dynamic_dep && !is_proc_macro {
19281944 builder. copy_link ( & f. path ( ) , & rustc_libdir. join ( & filename) ) ;
19291945 }
19301946 }
Original file line number Diff line number Diff line change 11//@ run-pass
2+ //@ no-prefer-dynamic We move the binary around, so do not depend dynamically on libstd
23//@ ignore-wasm32 no processes
34//@ ignore-sgx no processes
45//@ ignore-fuchsia Needs directory creation privilege
You can’t perform that action at this time.
0 commit comments