Move some libs to self-contained directory
This commit is contained in:
@@ -172,7 +172,14 @@ fn copy_self_contained_objects(
|
|||||||
compiler: &Compiler,
|
compiler: &Compiler,
|
||||||
target: Interned<String>,
|
target: Interned<String>,
|
||||||
) -> Vec<(PathBuf, DependencyType)> {
|
) -> Vec<(PathBuf, DependencyType)> {
|
||||||
let libdir = builder.sysroot_libdir(*compiler, target);
|
// cfg(bootstrap)
|
||||||
|
// Remove when upgrading bootstrap compiler.
|
||||||
|
let libdir_self_contained = if compiler.stage == 0 {
|
||||||
|
builder.sysroot_libdir(*compiler, target).to_path_buf()
|
||||||
|
} else {
|
||||||
|
builder.sysroot_libdir(*compiler, target).join("self-contained")
|
||||||
|
};
|
||||||
|
t!(fs::create_dir_all(&libdir_self_contained));
|
||||||
let mut target_deps = vec![];
|
let mut target_deps = vec![];
|
||||||
|
|
||||||
// Copies the CRT objects.
|
// Copies the CRT objects.
|
||||||
@@ -207,7 +214,7 @@ fn copy_self_contained_objects(
|
|||||||
} else if target.contains("windows-gnu") {
|
} else if target.contains("windows-gnu") {
|
||||||
for obj in ["crt2.o", "dllcrt2.o"].iter() {
|
for obj in ["crt2.o", "dllcrt2.o"].iter() {
|
||||||
let src = compiler_file(builder, builder.cc(target), target, obj);
|
let src = compiler_file(builder, builder.cc(target), target, obj);
|
||||||
let target = libdir.join(obj);
|
let target = libdir_self_contained.join(obj);
|
||||||
builder.copy(&src, &target);
|
builder.copy(&src, &target);
|
||||||
target_deps.push((target, DependencyType::TargetSelfContained));
|
target_deps.push((target, DependencyType::TargetSelfContained));
|
||||||
}
|
}
|
||||||
@@ -844,14 +851,17 @@ pub fn add_to_sysroot(
|
|||||||
sysroot_host_dst: &Path,
|
sysroot_host_dst: &Path,
|
||||||
stamp: &Path,
|
stamp: &Path,
|
||||||
) {
|
) {
|
||||||
|
let self_contained_dst = &sysroot_dst.join("self-contained");
|
||||||
t!(fs::create_dir_all(&sysroot_dst));
|
t!(fs::create_dir_all(&sysroot_dst));
|
||||||
t!(fs::create_dir_all(&sysroot_host_dst));
|
t!(fs::create_dir_all(&sysroot_host_dst));
|
||||||
|
t!(fs::create_dir_all(&self_contained_dst));
|
||||||
for (path, dependency_type) in builder.read_stamp_file(stamp) {
|
for (path, dependency_type) in builder.read_stamp_file(stamp) {
|
||||||
if dependency_type == DependencyType::Host {
|
let dst = match dependency_type {
|
||||||
builder.copy(&path, &sysroot_host_dst.join(path.file_name().unwrap()));
|
DependencyType::Host => sysroot_host_dst,
|
||||||
} else {
|
DependencyType::Target => sysroot_dst,
|
||||||
builder.copy(&path, &sysroot_dst.join(path.file_name().unwrap()));
|
DependencyType::TargetSelfContained => self_contained_dst,
|
||||||
}
|
};
|
||||||
|
builder.copy(&path, &dst.join(path.file_name().unwrap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -321,7 +321,12 @@ fn make_win_dist(
|
|||||||
);
|
);
|
||||||
|
|
||||||
//Copy platform libs to platform-specific lib directory
|
//Copy platform libs to platform-specific lib directory
|
||||||
let target_lib_dir = plat_root.join("lib").join("rustlib").join(target_triple).join("lib");
|
let target_lib_dir = plat_root
|
||||||
|
.join("lib")
|
||||||
|
.join("rustlib")
|
||||||
|
.join(target_triple)
|
||||||
|
.join("lib")
|
||||||
|
.join("self-contained");
|
||||||
fs::create_dir_all(&target_lib_dir).expect("creating target_lib_dir failed");
|
fs::create_dir_all(&target_lib_dir).expect("creating target_lib_dir failed");
|
||||||
for src in target_libs {
|
for src in target_libs {
|
||||||
builder.copy_to_folder(&src, &target_lib_dir);
|
builder.copy_to_folder(&src, &target_lib_dir);
|
||||||
@@ -650,9 +655,13 @@ fn skip_host_target_lib(builder: &Builder<'_>, compiler: Compiler) -> bool {
|
|||||||
/// Copy stamped files into an image's `target/lib` directory.
|
/// Copy stamped files into an image's `target/lib` directory.
|
||||||
fn copy_target_libs(builder: &Builder<'_>, target: &str, image: &Path, stamp: &Path) {
|
fn copy_target_libs(builder: &Builder<'_>, target: &str, image: &Path, stamp: &Path) {
|
||||||
let dst = image.join("lib/rustlib").join(target).join("lib");
|
let dst = image.join("lib/rustlib").join(target).join("lib");
|
||||||
|
let self_contained_dst = dst.join("self-contained");
|
||||||
t!(fs::create_dir_all(&dst));
|
t!(fs::create_dir_all(&dst));
|
||||||
|
t!(fs::create_dir_all(&self_contained_dst));
|
||||||
for (path, dependency_type) in builder.read_stamp_file(stamp) {
|
for (path, dependency_type) in builder.read_stamp_file(stamp) {
|
||||||
if dependency_type != DependencyType::Host || builder.config.build == target {
|
if dependency_type == DependencyType::TargetSelfContained {
|
||||||
|
builder.copy(&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(&path, &dst.join(path.file_name().unwrap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1075,6 +1075,10 @@ fn get_object_file_path(sess: &Session, name: &str) -> PathBuf {
|
|||||||
if file_path.exists() {
|
if file_path.exists() {
|
||||||
return file_path;
|
return file_path;
|
||||||
}
|
}
|
||||||
|
let file_path = fs.get_lib_path().join("self-contained").join(name);
|
||||||
|
if file_path.exists() {
|
||||||
|
return file_path;
|
||||||
|
}
|
||||||
for search_path in fs.search_paths() {
|
for search_path in fs.search_paths() {
|
||||||
let file_path = search_path.dir.join(name);
|
let file_path = search_path.dir.join(name);
|
||||||
if file_path.exists() {
|
if file_path.exists() {
|
||||||
@@ -1470,6 +1474,9 @@ fn add_library_search_dirs(cmd: &mut dyn Linker, sess: &Session) {
|
|||||||
// The location of crates will be determined as needed.
|
// The location of crates will be determined as needed.
|
||||||
let lib_path = sess.target_filesearch(PathKind::All).get_lib_path();
|
let lib_path = sess.target_filesearch(PathKind::All).get_lib_path();
|
||||||
cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));
|
cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));
|
||||||
|
|
||||||
|
let lib_path = sess.target_filesearch(PathKind::All).get_lib_path().join("self-contained");
|
||||||
|
cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add options making relocation sections in the produced ELF files read-only
|
/// Add options making relocation sections in the produced ELF files read-only
|
||||||
|
|||||||
Reference in New Issue
Block a user