Skip to content

rust: workaround --print file-names emitting staticlibs / dylibs. #658

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

Merged
merged 1 commit into from
Feb 3, 2020
Merged
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
35 changes: 29 additions & 6 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,26 @@ where
&env_vars,
)
.map(move |mut outputs| {
// metadata / dep-info don't ever generate binaries, but
// rustc still makes them appear in the --print
// file-names output (see
// https://github.com/rust-lang/rust/pull/68799).
//
// So if we see a binary in the rustc output and figure
// out that we're not _actually_ generating it, then we
// can avoid generating everything that isn't an rlib /
// rmeta.
//
// This can go away once the above rustc PR makes it in.
let emit_generates_only_metadata =
!emit.is_empty() && emit.iter().all(|e| e == "metadata" || e == "dep-info");

if emit_generates_only_metadata {
outputs.retain(|o| {
o.ends_with(".rlib") || o.ends_with(".rmeta")
});
}

if emit.contains("metadata") {
// rustc currently does not report rmeta outputs with --print file-names
// --emit metadata the rlib is printed, and with --emit metadata,link
Expand All @@ -1186,8 +1206,11 @@ where
}
}
}

let output_dir = PathBuf::from(output_dir);
// Convert output files into a map of basename -> full path.
// Convert output files into a map of basename -> full
// path, and remove some unneeded / non-existing ones,
// see https://github.com/rust-lang/rust/pull/68799.
let mut outputs = outputs
.into_iter()
.map(|o| {
Expand Down Expand Up @@ -1223,10 +1246,10 @@ where
compilation: Box::new(RustCompilation {
executable: executable,
host,
sysroot: sysroot,
arguments: arguments,
inputs: inputs,
outputs: outputs,
sysroot,
arguments,
inputs,
outputs,
crate_link_paths,
crate_name,
crate_types,
Expand Down Expand Up @@ -2673,7 +2696,7 @@ c:/foo/bar.rs:
staticlib: false,
},
dep_info: None,
emit: emit,
emit,
color_mode: ColorMode::Auto,
has_json: false,
},
Expand Down