Skip to content

Commit 7b29a5d

Browse files
Revert overeager warning for misuse of --print native-static-libs
In a PR to emit warnings on misuse of `--print native-static-libs`, we did not consider the matter of composing parts of build systems. If you are not directly invoking rustc, it can be difficult to know when you will in fact compile a staticlib, so making sure everyone uses `--print native-static-lib` correctly can be just a nuisance. This reverts the following commits: - f66787a - 72a9219 - 98bb597 - c59b708 Next cycle we can reland a slightly more narrowly focused variant or one that focuses on `--emit` instead of `--print native-static-libs`. But in its current state, I am not sure the warning is very useful.
1 parent 3bc767e commit 7b29a5d

File tree

6 files changed

+0
-38
lines changed

6 files changed

+0
-38
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

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

72-
fn check_link_info_print_request(sess: &Session, crate_types: &[CrateType]) {
73-
let print_native_static_libs =
74-
sess.opts.prints.iter().any(|p| p.kind == PrintKind::NativeStaticLibs);
75-
let has_staticlib = crate_types.iter().any(|ct| *ct == CrateType::Staticlib);
76-
if print_native_static_libs {
77-
if !has_staticlib {
78-
sess.dcx()
79-
.warn(format!("cannot output linkage information without staticlib crate-type"));
80-
sess.dcx()
81-
.note(format!("consider `--crate-type staticlib` to print linkage information"));
82-
} else if !sess.opts.output_types.should_link() {
83-
sess.dcx()
84-
.warn(format!("cannot output linkage information when --emit link is not passed"));
85-
}
86-
}
87-
}
88-
8972
/// Performs the linkage portion of the compilation phase. This will generate all
9073
/// of the requested outputs for this compilation session.
9174
pub fn link_binary(
@@ -208,8 +191,6 @@ pub fn link_binary(
208191
}
209192
}
210193

211-
check_link_info_print_request(sess, &codegen_results.crate_info.crate_types);
212-
213194
// Remove the temporary object file and metadata if we aren't saving temps.
214195
sess.time("link_binary_remove_temps", || {
215196
// If the user requests that temporaries are saved, don't delete any.

tests/ui/print-request/emit-warning-print-link-info-without-staticlib.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/ui/print-request/emit-warning-print-link-info-without-staticlib.stderr

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/ui/print-request/emit-warning-while-exe-and-print-link-info.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/ui/print-request/emit-warning-while-exe-and-print-link-info.stderr

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/ui/print-request/stability.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,3 @@ fn main() {}
110110
//[check_cfg]~? ERROR the `-Z unstable-options` flag must also be passed to enable the `check-cfg` print option
111111
//[supported_crate_types]~? ERROR the `-Z unstable-options` flag must also be passed to enable the `supported-crate-types` print option
112112
//[target_spec_json]~? ERROR the `-Z unstable-options` flag must also be passed to enable the `target-spec-json` print option
113-
//[native_static_libs]~? WARNING cannot output linkage information without staticlib crate-type

0 commit comments

Comments
 (0)