Skip to content

Commit 72a9219

Browse files
committed
check all crate-type to find staticlib
Signed-off-by: xizheyin <[email protected]>
1 parent 98bb597 commit 72a9219

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) {
6868
}
6969
}
7070

71-
fn check_link_info_print_request(sess: &Session, crate_type: CrateType) {
71+
fn check_link_info_print_request(sess: &Session, crate_types: &[CrateType]) {
7272
let print_native_static_libs =
7373
sess.opts.prints.iter().any(|p| p.kind == PrintKind::NativeStaticLibs);
74+
let has_staticlib = crate_types.iter().any(|ct| *ct == CrateType::Staticlib);
7475
if print_native_static_libs {
75-
if crate_type != CrateType::Staticlib {
76+
if !has_staticlib {
7677
sess.dcx()
7778
.warn(format!("cannot output linkage information without staticlib crate-type"));
7879
sess.dcx()
7980
.note(format!("consider `--crate-type staticlib` to print linkage information"));
8081
} else if !sess.opts.output_types.should_link() {
81-
sess.dcx().warn(format!(
82-
"cannot output linkage information when --emit link is not passed"
83-
));
82+
sess.dcx()
83+
.warn(format!("cannot output linkage information when --emit link is not passed"));
8484
}
8585
}
8686
}
@@ -196,7 +196,7 @@ pub fn link_binary(
196196
}
197197
}
198198

199-
check_link_info_print_request(sess, crate_type);
199+
check_link_info_print_request(sess, &codegen_results.crate_info.crate_types);
200200
}
201201

202202
// Remove the temporary object file and metadata if we aren't saving temps.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
//@ compile-flags: --print native-static-libs --crate-type staticlib --emit metadata
22
//@ check-pass
3-
//~? WARN skipping link step due to conflict: cannot output linkage information without emitting link
3+
//~? WARN cannot output linkage information when --emit link is not passed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: skipping link step due to conflict: cannot output linkage information without emitting link
1+
warning: cannot output linkage information when --emit link is not passed
22

33
warning: 1 warning emitted
44

0 commit comments

Comments
 (0)