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

librustc_driver: Make --print file-names do a minor accounting of --emit #68799

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 6 additions & 2 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,13 @@ impl RustcDefaultCalls {
continue;
}
let crate_types = rustc_interface::util::collect_crate_types(sess, attrs);
for &style in &crate_types {
let should_codegen = sess.opts.output_types.should_codegen();
for &crate_type in &crate_types {
if !should_codegen && crate_type.requires_codegen() {
continue;
}
let fname = rustc_codegen_utils::link::filename_for_input(
sess, style, &id, &t_outputs,
sess, crate_type, &id, &t_outputs,
);
println!("{}", fname.file_name().unwrap().to_string_lossy());
}
Expand Down
15 changes: 15 additions & 0 deletions src/librustc_session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,21 @@ pub enum CrateType {
ProcMacro,
}

impl CrateType {
/// Whether the output of this crate type requires codegen to be generated.
///
/// This is a bit of a hack to prevent bogus library names being outputted
/// from the PrintRequest code. Ideally that code would be fully aware of
/// the output requests, but that seems hard to do generally.
pub fn requires_codegen(self) -> bool {
use CrateType::*;
match self {
Cdylib | Dylib | Executable | Staticlib => true,
ProcMacro | Rlib => false,
}
}
}

impl_stable_hash_via_hash!(CrateType);

#[derive(Clone, Hash)]
Expand Down
1 change: 1 addition & 0 deletions src/test/run-make-fulldeps/crate-data-smoke/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ all:
[ `$(RUSTC) --print file-names --crate-type=lib \
--test crate.rs` = "$(call BIN,foo)" ]
[ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ]
[ "`$(RUSTC) --emit=dep-info,metadata --print file-names crate.rs`" = "" ] # Shouldn't print the binary name.
$(RUSTC) --print file-names lib.rs
$(RUSTC) --print file-names rlib.rs