Skip to content

Commit 7bd36fb

Browse files
committed
Build system fixes
1 parent a050029 commit 7bd36fb

File tree

3 files changed

+59
-13
lines changed

3 files changed

+59
-13
lines changed

Cargo.lock

+5
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,7 @@ version = "0.0.0"
23682368
dependencies = [
23692369
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
23702370
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
2371+
"serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
23712372
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
23722373
]
23732374

@@ -2433,6 +2434,8 @@ dependencies = [
24332434
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
24342435
"rustc_cratesio_shim 0.0.0",
24352436
"rustc_data_structures 0.0.0",
2437+
"serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
2438+
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
24362439
"serialize 0.0.0",
24372440
"syntax_pos 0.0.0",
24382441
"termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3027,6 +3030,8 @@ dependencies = [
30273030
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
30283031
"rustc_data_structures 0.0.0",
30293032
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
3033+
"serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
3034+
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
30303035
"serialize 0.0.0",
30313036
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
30323037
]

src/bootstrap/check.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Step for Std {
5252
true);
5353

5454
let libdir = builder.sysroot_libdir(compiler, target);
55-
add_to_sysroot(&builder, &libdir, &libstd_stamp(builder, compiler, target));
55+
add_to_sysroot(&builder, &libdir, &libstd_stamp(builder, compiler, target), None);
5656
}
5757
}
5858

@@ -98,8 +98,14 @@ impl Step for Rustc {
9898
&librustc_stamp(builder, compiler, target),
9999
true);
100100

101+
let stage_out = builder.build.stage_out(compiler, Mode::Rustc);
101102
let libdir = builder.sysroot_libdir(compiler, target);
102-
add_to_sysroot(&builder, &libdir, &librustc_stamp(builder, compiler, target));
103+
add_to_sysroot(
104+
&builder,
105+
&libdir,
106+
&librustc_stamp(builder, compiler, target),
107+
Some(&stage_out),
108+
);
103109
}
104110
}
105111

@@ -188,7 +194,7 @@ impl Step for Test {
188194
true);
189195

190196
let libdir = builder.sysroot_libdir(compiler, target);
191-
add_to_sysroot(builder, &libdir, &libtest_stamp(builder, compiler, target));
197+
add_to_sysroot(builder, &libdir, &libtest_stamp(builder, compiler, target), None);
192198
}
193199
}
194200

@@ -236,7 +242,7 @@ impl Step for Rustdoc {
236242
true);
237243

238244
let libdir = builder.sysroot_libdir(compiler, target);
239-
add_to_sysroot(&builder, &libdir, &rustdoc_stamp(builder, compiler, target));
245+
add_to_sysroot(&builder, &libdir, &rustdoc_stamp(builder, compiler, target), None);
240246
builder.cargo(compiler, Mode::ToolRustc, target, "clean");
241247
}
242248
}

src/bootstrap/compile.rs

+44-9
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Step for StdLink {
219219
target_compiler.host,
220220
target));
221221
let libdir = builder.sysroot_libdir(target_compiler, target);
222-
add_to_sysroot(builder, &libdir, &libstd_stamp(builder, compiler, target));
222+
add_to_sysroot(builder, &libdir, &libstd_stamp(builder, compiler, target), None);
223223

224224
if builder.config.sanitizers && compiler.stage != 0 && target == "x86_64-apple-darwin" {
225225
// The sanitizers are only built in stage1 or above, so the dylibs will
@@ -423,7 +423,7 @@ impl Step for TestLink {
423423
target_compiler.host,
424424
target));
425425
add_to_sysroot(builder, &builder.sysroot_libdir(target_compiler, target),
426-
&libtest_stamp(builder, compiler, target));
426+
&libtest_stamp(builder, compiler, target), None);
427427

428428
builder.cargo(target_compiler, Mode::ToolTest, target, "clean");
429429
}
@@ -584,8 +584,13 @@ impl Step for RustcLink {
584584
&compiler.host,
585585
target_compiler.host,
586586
target));
587-
add_to_sysroot(builder, &builder.sysroot_libdir(target_compiler, target),
588-
&librustc_stamp(builder, compiler, target));
587+
let stage_out = builder.build.stage_out(target_compiler, Mode::Rustc);
588+
add_to_sysroot(
589+
builder,
590+
&builder.sysroot_libdir(target_compiler, target),
591+
&librustc_stamp(builder, compiler, target),
592+
Some(&stage_out),
593+
);
589594
builder.cargo(target_compiler, Mode::ToolRustc, target, "clean");
590595
}
591596
}
@@ -1014,10 +1019,26 @@ impl Step for Assemble {
10141019
///
10151020
/// For a particular stage this will link the file listed in `stamp` into the
10161021
/// `sysroot_dst` provided.
1017-
pub fn add_to_sysroot(builder: &Builder, sysroot_dst: &Path, stamp: &Path) {
1022+
pub fn add_to_sysroot(
1023+
builder: &Builder,
1024+
sysroot_dst: &Path,
1025+
stamp: &Path,
1026+
stage_out: Option<&Path>) {
10181027
t!(fs::create_dir_all(&sysroot_dst));
10191028
for path in builder.read_stamp_file(stamp) {
1020-
builder.copy(&path, &sysroot_dst.join(path.file_name().unwrap()));
1029+
let file_dir = path.parent().unwrap() // chop off base name
1030+
.parent().unwrap() // chop off `release`
1031+
.parent().unwrap(); // chop off `release`
1032+
if stage_out == Some(file_dir) {
1033+
// We are copying a build file. We need to add the build triple to it
1034+
let rustlib_dir = sysroot_dst.parent().unwrap() // chop off `lib`
1035+
.parent().unwrap(); // chop off `$target`
1036+
let build_dir = rustlib_dir.join(builder.build.build).join("lib");
1037+
t!(fs::create_dir_all(&build_dir));
1038+
builder.copy(&path, &build_dir.join(path.file_name().unwrap()));
1039+
} else {
1040+
builder.copy(&path, &sysroot_dst.join(path.file_name().unwrap()));
1041+
}
10211042
}
10221043
}
10231044

@@ -1047,8 +1068,12 @@ pub fn run_cargo(builder: &Builder,
10471068
let mut deps = Vec::new();
10481069
let mut toplevel = Vec::new();
10491070
let ok = stream_cargo(builder, cargo, tail_args, &mut |msg| {
1050-
let filenames = match msg {
1051-
CargoMessage::CompilerArtifact { filenames, .. } => filenames,
1071+
let (filenames, package_id) = match msg {
1072+
CargoMessage::CompilerArtifact {
1073+
filenames,
1074+
package_id,
1075+
..
1076+
} => (filenames, package_id),
10521077
_ => return,
10531078
};
10541079
for filename in filenames {
@@ -1062,9 +1087,19 @@ pub fn run_cargo(builder: &Builder,
10621087

10631088
let filename = Path::new(&*filename);
10641089

1090+
// If this was an output file in the "host dir" we don't actually
1091+
// worry about it, it's not relevant for us
1092+
if filename.starts_with(&host_root_dir) {
1093+
// Unless it's a proc macro used in the compiler
1094+
if package_id.starts_with("serde_derive ") {
1095+
deps.push(filename.to_path_buf());
1096+
}
1097+
continue;
1098+
}
1099+
10651100
// If this was output in the `deps` dir then this is a precise file
10661101
// name (hash included) so we start tracking it.
1067-
if filename.starts_with(&host_root_dir) || filename.starts_with(&target_deps_dir) {
1102+
if filename.starts_with(&target_deps_dir) {
10681103
deps.push(filename.to_path_buf());
10691104
continue;
10701105
}

0 commit comments

Comments
 (0)