diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2024-09-04 11:22:43 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2024-10-03 09:43:55 +0200 |
| commit | 2cf155924fb6f7d4f85f49c0642b2d40b22a13b1 (patch) | |
| tree | 0f6ef5b9555f56f50e99f4ebd48eb17986615bca | |
| parent | fd1f8aa05d690138815fefb0066543a9087889bb (diff) | |
| download | rust-2cf155924fb6f7d4f85f49c0642b2d40b22a13b1.tar.gz rust-2cf155924fb6f7d4f85f49c0642b2d40b22a13b1.zip | |
Do not include `libstd.so` in sysroot when we statically link to libstd
| -rw-r--r-- | src/bootstrap/src/bin/rustc.rs | 1 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/compile.rs | 18 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index d04e2fbeb78..780979ed981 100644 --- a/src/bootstrap/src/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -95,7 +95,6 @@ fn main() { // When statically linking `std` into `rustc_driver`, remove `-C prefer-dynamic` if env::var("RUSTC_LINK_STD_INTO_RUSTC_DRIVER").unwrap() == "1" && crate_name == Some("rustc_driver") - && stage != "0" { if let Some(pos) = args.iter().enumerate().position(|(i, a)| { a == "-C" && args.get(i + 1).map(|a| a == "prefer-dynamic").unwrap_or(false) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index eaa982d4e2b..c274bcc2df7 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1923,8 +1923,24 @@ impl Step for Assemble { let src_libdir = builder.sysroot_libdir(build_compiler, host); for f in builder.read_dir(&src_libdir) { let filename = f.file_name().into_string().unwrap(); - if (is_dylib(&filename) || is_debug_info(&filename)) && !proc_macros.contains(&filename) + + let is_proc_macro = proc_macros.contains(&filename); + let is_dylib_or_debug = is_dylib(&filename) || is_debug_info(&filename); + + // If we link statically to stdlib, do not copy the libstd dynamic library file + // Currently, we do not avoid the copy on Windows, as it seems to be causing issues in + // post-optimization stage0 tests. + let can_be_rustc_dynamic_dep = if builder + .link_std_into_rustc_driver(target_compiler.host) + && !target_compiler.host.is_windows() { + let is_std = filename.starts_with("std-") || filename.starts_with("libstd-"); + !is_std + } else { + true + }; + + if is_dylib_or_debug && can_be_rustc_dynamic_dep && !is_proc_macro { builder.copy_link(&f.path(), &rustc_libdir.join(&filename)); } } |
