Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: Don't name things copy that are not copies #122590

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl Step for Std {
let target_sysroot_bin =
builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
t!(fs::create_dir_all(&target_sysroot_bin));
builder.cp_r(&src_sysroot_bin, &target_sysroot_bin);
builder.cp_link_r(&src_sysroot_bin, &target_sysroot_bin);
}
}

Expand Down Expand Up @@ -307,7 +307,7 @@ fn copy_and_stamp(
dependency_type: DependencyType,
) {
let target = libdir.join(name);
builder.copy(&sourcedir.join(name), &target);
builder.copy_link(&sourcedir.join(name), &target);

target_deps.push((target, dependency_type));
}
Expand All @@ -316,7 +316,7 @@ fn copy_llvm_libunwind(builder: &Builder<'_>, target: TargetSelection, libdir: &
let libunwind_path = builder.ensure(llvm::Libunwind { target });
let libunwind_source = libunwind_path.join("libunwind.a");
let libunwind_target = libdir.join("libunwind.a");
builder.copy(&libunwind_source, &libunwind_target);
builder.copy_link(&libunwind_source, &libunwind_target);
libunwind_target
}

Expand Down Expand Up @@ -385,7 +385,7 @@ fn copy_self_contained_objects(
for &obj in &["crtbegin.o", "crtbeginS.o", "crtend.o", "crtendS.o"] {
let src = crt_path.join(obj);
let target = libdir_self_contained.join(obj);
builder.copy(&src, &target);
builder.copy_link(&src, &target);
target_deps.push((target, DependencyType::TargetSelfContained));
}

Expand Down Expand Up @@ -418,7 +418,7 @@ fn copy_self_contained_objects(
for obj in ["crt2.o", "dllcrt2.o"].iter() {
let src = compiler_file(builder, &builder.cc(target), target, CLang::C, obj);
let target = libdir_self_contained.join(obj);
builder.copy(&src, &target);
builder.copy_link(&src, &target);
target_deps.push((target, DependencyType::TargetSelfContained));
}
}
Expand Down Expand Up @@ -637,7 +637,7 @@ impl Step for StdLink {
let stage0_bin_dir = builder.out.join(host).join("stage0/bin");
let sysroot_bin_dir = sysroot.join("bin");
t!(fs::create_dir_all(&sysroot_bin_dir));
builder.cp_r(&stage0_bin_dir, &sysroot_bin_dir);
builder.cp_link_r(&stage0_bin_dir, &sysroot_bin_dir);

// Copy all *.so files from stage0/lib to stage0-sysroot/lib
let stage0_lib_dir = builder.out.join(host).join("stage0/lib");
Expand All @@ -646,7 +646,8 @@ impl Step for StdLink {
let file = t!(file);
let path = file.path();
if path.is_file() && is_dylib(&file.file_name().into_string().unwrap()) {
builder.copy(&path, &sysroot.join("lib").join(path.file_name().unwrap()));
builder
.copy_link(&path, &sysroot.join("lib").join(path.file_name().unwrap()));
}
}
}
Expand All @@ -661,7 +662,7 @@ impl Step for StdLink {
.join(host)
.join("codegen-backends");
if stage0_codegen_backends.exists() {
builder.cp_r(&stage0_codegen_backends, &sysroot_codegen_backends);
builder.cp_link_r(&stage0_codegen_backends, &sysroot_codegen_backends);
}
}
}
Expand All @@ -684,7 +685,7 @@ fn copy_sanitizers(

for runtime in &runtimes {
let dst = libdir.join(&runtime.name);
builder.copy(&runtime.path, &dst);
builder.copy_link(&runtime.path, &dst);

// The `aarch64-apple-ios-macabi` and `x86_64-apple-ios-macabi` are also supported for
// sanitizers, but they share a sanitizer runtime with `${arch}-apple-darwin`, so we do
Expand Down Expand Up @@ -790,7 +791,7 @@ impl Step for StartupObjects {
}

let target = sysroot_dir.join((*file).to_string() + ".o");
builder.copy(dst_file, &target);
builder.copy_link(dst_file, &target);
target_deps.push((target, DependencyType::Target));
}

Expand All @@ -812,7 +813,7 @@ fn cp_rustc_component_to_ci_sysroot(
if src.is_dir() {
t!(fs::create_dir_all(dst));
} else {
builder.copy(&src, &dst);
builder.copy_link(&src, &dst);
}
}
}
Expand Down Expand Up @@ -1443,7 +1444,7 @@ fn copy_codegen_backends_to_sysroot(
let dot = filename.find('.').unwrap();
format!("{}-{}{}", &filename[..dash], builder.rust_release(), &filename[dot..])
};
builder.copy(file, &dst.join(target_filename));
builder.copy_link(file, &dst.join(target_filename));
}
}

Expand Down Expand Up @@ -1599,7 +1600,7 @@ impl Step for Sysroot {
OsStr::new(std::env::consts::DLL_EXTENSION),
];
let ci_rustc_dir = builder.config.ci_rustc_dir();
builder.cp_filtered(&ci_rustc_dir, &sysroot, &|path| {
builder.cp_link_filtered(&ci_rustc_dir, &sysroot, &|path| {
if path.extension().map_or(true, |ext| !filtered_extensions.contains(&ext)) {
return true;
}
Expand Down Expand Up @@ -1791,7 +1792,7 @@ impl Step for Assemble {
let filename = f.file_name().into_string().unwrap();
if (is_dylib(&filename) || is_debug_info(&filename)) && !proc_macros.contains(&filename)
{
builder.copy(&f.path(), &rustc_libdir.join(&filename));
builder.copy_link(&f.path(), &rustc_libdir.join(&filename));
}
}

Expand All @@ -1805,15 +1806,15 @@ impl Step for Assemble {
if let Some(lld_install) = lld_install {
let src_exe = exe("lld", target_compiler.host);
let dst_exe = exe("rust-lld", target_compiler.host);
builder.copy(&lld_install.join("bin").join(src_exe), &libdir_bin.join(dst_exe));
builder.copy_link(&lld_install.join("bin").join(src_exe), &libdir_bin.join(dst_exe));
let self_contained_lld_dir = libdir_bin.join("gcc-ld");
t!(fs::create_dir_all(&self_contained_lld_dir));
let lld_wrapper_exe = builder.ensure(crate::core::build_steps::tool::LldWrapper {
compiler: build_compiler,
target: target_compiler.host,
});
for name in crate::LLD_FILE_NAMES {
builder.copy(
builder.copy_link(
&lld_wrapper_exe,
&self_contained_lld_dir.join(exe(name, target_compiler.host)),
);
Expand All @@ -1838,7 +1839,7 @@ impl Step for Assemble {
// When using `download-ci-llvm`, some of the tools
// may not exist, so skip trying to copy them.
if src_path.exists() {
builder.copy(&src_path, &libdir_bin.join(&tool_exe));
builder.copy_link(&src_path, &libdir_bin.join(&tool_exe));
}
}
}
Expand All @@ -1851,7 +1852,7 @@ impl Step for Assemble {
extra_features: vec![],
});
let tool_exe = exe("llvm-bitcode-linker", target_compiler.host);
builder.copy(&src_path, &libdir_bin.join(&tool_exe));
builder.copy_link(&src_path, &libdir_bin.join(&tool_exe));
}

// Ensure that `libLLVM.so` ends up in the newly build compiler directory,
Expand All @@ -1865,7 +1866,7 @@ impl Step for Assemble {
let bindir = sysroot.join("bin");
t!(fs::create_dir_all(bindir));
let compiler = builder.rustc(target_compiler);
builder.copy(&rustc, &compiler);
builder.copy_link(&rustc, &compiler);

target_compiler
}
Expand All @@ -1891,7 +1892,7 @@ pub fn add_to_sysroot(
DependencyType::Target => sysroot_dst,
DependencyType::TargetSelfContained => self_contained_dst,
};
builder.copy(&path, &dst.join(path.file_name().unwrap()));
builder.copy_link(&path, &dst.join(path.file_name().unwrap()));
}
}

Expand Down
29 changes: 15 additions & 14 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn make_win_dist(
let dist_bin_dir = rust_root.join("bin/");
fs::create_dir_all(&dist_bin_dir).expect("creating dist_bin_dir failed");
for src in rustc_dlls {
builder.copy_to_folder(&src, &dist_bin_dir);
builder.copy_link_to_folder(&src, &dist_bin_dir);
}

//Copy platform tools to platform-specific bin directory
Expand All @@ -284,7 +284,7 @@ fn make_win_dist(
.join("self-contained");
fs::create_dir_all(&target_bin_dir).expect("creating target_bin_dir failed");
for src in target_tools {
builder.copy_to_folder(&src, &target_bin_dir);
builder.copy_link_to_folder(&src, &target_bin_dir);
}

// Warn windows-gnu users that the bundled GCC cannot compile C files
Expand All @@ -304,7 +304,7 @@ fn make_win_dist(
.join("self-contained");
fs::create_dir_all(&target_lib_dir).expect("creating target_lib_dir failed");
for src in target_libs {
builder.copy_to_folder(&src, &target_lib_dir);
builder.copy_link_to_folder(&src, &target_lib_dir);
}
}

Expand Down Expand Up @@ -400,7 +400,7 @@ impl Step for Rustc {

// Copy rustc binary
t!(fs::create_dir_all(image.join("bin")));
builder.cp_r(&src.join("bin"), &image.join("bin"));
builder.cp_link_r(&src.join("bin"), &image.join("bin"));

// If enabled, copy rustdoc binary
if builder
Expand Down Expand Up @@ -458,13 +458,13 @@ impl Step for Rustc {
if builder.config.lld_enabled {
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
let rust_lld = exe("rust-lld", compiler.host);
builder.copy(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
builder.copy_link(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
let self_contained_lld_src_dir = src_dir.join("gcc-ld");
let self_contained_lld_dst_dir = dst_dir.join("gcc-ld");
t!(fs::create_dir(&self_contained_lld_dst_dir));
for name in crate::LLD_FILE_NAMES {
let exe_name = exe(name, compiler.host);
builder.copy(
builder.copy_link(
&self_contained_lld_src_dir.join(&exe_name),
&self_contained_lld_dst_dir.join(&exe_name),
);
Expand Down Expand Up @@ -609,9 +609,9 @@ fn copy_target_libs(builder: &Builder<'_>, target: TargetSelection, image: &Path
t!(fs::create_dir_all(&self_contained_dst));
for (path, dependency_type) in builder.read_stamp_file(stamp) {
if dependency_type == DependencyType::TargetSelfContained {
builder.copy(&path, &self_contained_dst.join(path.file_name().unwrap()));
builder.copy_link(&path, &self_contained_dst.join(path.file_name().unwrap()));
} else if dependency_type == DependencyType::Target || builder.config.build == target {
builder.copy(&path, &dst.join(path.file_name().unwrap()));
builder.copy_link(&path, &dst.join(path.file_name().unwrap()));
}
}
}
Expand Down Expand Up @@ -865,7 +865,8 @@ fn copy_src_dirs(
for item in src_dirs {
let dst = &dst_dir.join(item);
t!(fs::create_dir_all(dst));
builder.cp_filtered(&base.join(item), dst, &|path| filter_fn(exclude_dirs, item, path));
builder
.cp_link_filtered(&base.join(item), dst, &|path| filter_fn(exclude_dirs, item, path));
}
}

Expand Down Expand Up @@ -923,7 +924,7 @@ impl Step for Src {
&dst_src,
);
for file in src_files.iter() {
builder.copy(&builder.src.join(file), &dst_src.join(file));
builder.copy_link(&builder.src.join(file), &dst_src.join(file));
}

tarball.generate()
Expand Down Expand Up @@ -979,7 +980,7 @@ impl Step for PlainSourceTarball {

// Copy the files normally
for item in &src_files {
builder.copy(&builder.src.join(item), &plain_dst_src.join(item));
builder.copy_link(&builder.src.join(item), &plain_dst_src.join(item));
}

// Create the version file
Expand Down Expand Up @@ -1608,7 +1609,7 @@ impl Step for Extended {

let prepare = |name: &str| {
builder.create_dir(&pkg.join(name));
builder.cp_r(
builder.cp_link_r(
&work.join(format!("{}-{}", pkgname(builder, name), target.triple)),
&pkg.join(name),
);
Expand Down Expand Up @@ -1672,7 +1673,7 @@ impl Step for Extended {
} else {
name.to_string()
};
builder.cp_r(
builder.cp_link_r(
&work.join(format!("{}-{}", pkgname(builder, name), target.triple)).join(dir),
&exe.join(name),
);
Expand Down Expand Up @@ -2040,7 +2041,7 @@ fn install_llvm_file(
if install_symlink {
// For download-ci-llvm, also install the symlink, to match what LLVM does. Using a
// symlink is fine here, as this is not a rustup component.
builder.copy(&source, &full_dest);
builder.copy_link(&source, &full_dest);
} else {
// Otherwise, replace the symlink with an equivalent linker script. This is used when
// projects like miri link against librustc_driver.so. We don't use a symlink, as
Expand Down
9 changes: 6 additions & 3 deletions src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,10 @@ impl Step for SharedAssets {
t!(fs::write(&version_info, info));
}

builder.copy(&builder.src.join("src").join("doc").join("rust.css"), &out.join("rust.css"));
builder.copy_link(
&builder.src.join("src").join("doc").join("rust.css"),
&out.join("rust.css"),
);

SharedAssetsPaths { version_info }
}
Expand Down Expand Up @@ -718,7 +721,7 @@ fn doc_std(
let _guard = builder.msg_doc(compiler, description, target);

builder.run(&mut cargo.into());
builder.cp_r(&out_dir, out);
builder.cp_link_r(&out_dir, out);
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
Expand Down Expand Up @@ -1151,7 +1154,7 @@ impl Step for RustcBook {
let out_base = builder.md_doc_out(self.target).join("rustc");
t!(fs::create_dir_all(&out_base));
let out_listing = out_base.join("src/lints");
builder.cp_r(&builder.src.join("src/doc/rustc"), &out_base);
builder.cp_link_r(&builder.src.join("src/doc/rustc"), &out_base);
builder.info(&format!("Generating lint docs ({})", self.target));

let rustc = builder.rustc(self.compiler);
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ impl Step for RunMakeSupport {

let cargo_out =
builder.cargo_out(self.compiler, Mode::ToolStd, self.target).join(&lib_name);
builder.copy(&cargo_out, &lib);
builder.copy_link(&cargo_out, &lib);
lib
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl Step for ToolBuild {
}
let cargo_out = builder.cargo_out(compiler, self.mode, target).join(exe(tool, target));
let bin = builder.tools_dir(compiler).join(exe(tool, target));
builder.copy(&cargo_out, &bin);
builder.copy_link(&cargo_out, &bin);
bin
}
}
Expand Down Expand Up @@ -507,7 +507,7 @@ impl Step for Rustdoc {
t!(fs::create_dir_all(&bindir));
let bin_rustdoc = bindir.join(exe("rustdoc", target_compiler.host));
let _ = fs::remove_file(&bin_rustdoc);
builder.copy(&tool_rustdoc, &bin_rustdoc);
builder.copy_link(&tool_rustdoc, &bin_rustdoc);
bin_rustdoc
} else {
tool_rustdoc
Expand Down Expand Up @@ -686,7 +686,7 @@ impl Step for RustAnalyzerProcMacroSrv {
// so that r-a can use it.
let libexec_path = builder.sysroot(self.compiler).join("libexec");
t!(fs::create_dir_all(&libexec_path));
builder.copy(&path, &libexec_path.join("rust-analyzer-proc-macro-srv"));
builder.copy_link(&path, &libexec_path.join("rust-analyzer-proc-macro-srv"));

Some(path)
}
Expand Down Expand Up @@ -765,7 +765,7 @@ macro_rules! tool_extended {
$(for add_bin in $add_bins_to_sysroot {
let bin_source = tools_out.join(exe(add_bin, $sel.target));
let bin_destination = bindir.join(exe(add_bin, $sel.compiler.host));
$builder.copy(&bin_source, &bin_destination);
$builder.copy_link(&bin_source, &bin_destination);
})?

let tool = bindir.join(exe($tool_name, $sel.compiler.host));
Expand Down
Loading
Loading