diff options
| author | bors <bors@rust-lang.org> | 2023-02-17 14:27:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-17 14:27:28 +0000 |
| commit | f722b24eb9ea35a7cc187a1cb5c50d4d324f5855 (patch) | |
| tree | 821e87562b0d14d209fae8d39ed8fc417d6d459e /src/bootstrap | |
| parent | f4f5fc3e5cc70b7a43bf7b518c455f3d9bada9e3 (diff) | |
| parent | ae5473c9699eaf1998c414e0a8884383bb9ddcc3 (diff) | |
Auto merge of #108159 - matthiaskrgr:rollup-5k2j7cx, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #107592 (Default `repr(C)` enums to `c_int` size) - #107956 (Copy `bin/*` and `lib/*.dylib` files to `stage0-sysroot`) - #108126 (fix a line, and do a consistency fix) - #108144 (Add compiler-errors to a few more triagebot groups) - #108149 (typo) - #108154 (`BasicBlock::new(0)` -> `START_BLOCK` [no functional changes]) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/compile.rs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 07c0d2233ca..97a1102e3c5 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -445,6 +445,72 @@ impl Step for StdLink { let libdir = builder.sysroot_libdir(target_compiler, target); let hostdir = builder.sysroot_libdir(target_compiler, compiler.host); add_to_sysroot(builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target)); + + if compiler.stage == 0 { + // special handling for stage0, to make `rustup toolchain link` and `x dist --stage 0` + // work for stage0-sysroot + let sysroot = builder.out.join(&compiler.host.triple).join("stage0-sysroot"); + + let host_lib_dir = builder.initial_rustc.ancestors().nth(2).unwrap().join("lib"); + let host_bin_dir = builder.out.join(&builder.initial_rustc.parent().unwrap()); + let host_codegen_backends = + host_lib_dir.join("rustlib").join(&compiler.host.triple).join("codegen-backends"); + let sysroot_bin_dir = sysroot.join("bin"); + let sysroot_lib_dir = sysroot.join("lib"); + let sysroot_codegen_backends = builder.sysroot_codegen_backends(compiler); + + // Create the `bin` directory in stage0-sysroot + t!(fs::create_dir_all(&sysroot_bin_dir)); + + // copy bin files from `builder.initial_rustc/./` to `stage0-sysroot/bin` + if let Ok(files) = fs::read_dir(&host_bin_dir) { + for file in files { + let file = t!(file); + if file.file_name() == "rustfmt" { + // This is when `rustc` and `cargo` are set in `config.toml` + if !file.path().starts_with(&builder.out) { + builder.copy( + &file.path().into_boxed_path(), + &sysroot_bin_dir.join(file.file_name()), + ); + } else { + builder.copy( + &builder + .out + .join(&compiler.host.triple) + .join("rustfmt/bin/rustfmt"), + &sysroot_bin_dir.join(file.file_name()), + ); + } + } else { + builder.copy( + &file.path().into_boxed_path(), + &sysroot_bin_dir.join(file.file_name()), + ); + } + } + } + + // copy dylib files from `builder.initial_rustc/../lib/*` while excluding the `rustlib` directory to `stage0-sysroot/lib` + if let Ok(files) = fs::read_dir(&host_lib_dir) { + for file in files { + let file = t!(file); + let path = file.path(); + if path.is_file() + && is_dylib(&file.file_name().into_string().unwrap()) + && !path.starts_with(sysroot_lib_dir.join("rustlib").into_boxed_path()) + { + builder.copy(&path, &sysroot_lib_dir.join(path.file_name().unwrap())); + } + } + } + + t!(fs::create_dir_all(&sysroot_codegen_backends)); + // copy `codegen-backends` from `host_lib_dir/rustlib/codegen_backends` to `stage0-sysroot/lib/rustlib/host-triple/codegen-backends` if it exists. + if host_codegen_backends.exists() { + builder.cp_r(&host_codegen_backends, &sysroot_codegen_backends); + } + } } } |
