about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2025-06-16 12:07:24 -0700
committerJubilee Young <workingjubilee@gmail.com>2025-06-16 12:43:36 -0700
commit7b29a5d2827f4336ee2c3ca163378c9dc5a82238 (patch)
treed468d3e0ffdceb8ac58f370010bd3149691ee3f0
parent3bc767e1a215c4bf8f099b32e84edb85780591b1 (diff)
downloadrust-7b29a5d2827f4336ee2c3ca163378c9dc5a82238.tar.gz
rust-7b29a5d2827f4336ee2c3ca163378c9dc5a82238.zip
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:
- f66787a08d57dc1296619b314d2be596085bfeef
- 72a9219e82c157041bfc8dfd378c9cb2b09c0650
- 98bb597c05c32365abbd6898f278b097352774ed
- c59b70841c36277464b51161e3fcf12dfcb667e0

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.
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs19
-rw-r--r--tests/ui/print-request/emit-warning-print-link-info-without-staticlib.rs5
-rw-r--r--tests/ui/print-request/emit-warning-print-link-info-without-staticlib.stderr6
-rw-r--r--tests/ui/print-request/emit-warning-while-exe-and-print-link-info.rs3
-rw-r--r--tests/ui/print-request/emit-warning-while-exe-and-print-link-info.stderr4
-rw-r--r--tests/ui/print-request/stability.rs1
6 files changed, 0 insertions, 38 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index 8c52ed6ed12..8882ba359b7 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -69,23 +69,6 @@ pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) {
     }
 }
 
-fn check_link_info_print_request(sess: &Session, crate_types: &[CrateType]) {
-    let print_native_static_libs =
-        sess.opts.prints.iter().any(|p| p.kind == PrintKind::NativeStaticLibs);
-    let has_staticlib = crate_types.iter().any(|ct| *ct == CrateType::Staticlib);
-    if print_native_static_libs {
-        if !has_staticlib {
-            sess.dcx()
-                .warn(format!("cannot output linkage information without staticlib crate-type"));
-            sess.dcx()
-                .note(format!("consider `--crate-type staticlib` to print linkage information"));
-        } else if !sess.opts.output_types.should_link() {
-            sess.dcx()
-                .warn(format!("cannot output linkage information when --emit link is not passed"));
-        }
-    }
-}
-
 /// Performs the linkage portion of the compilation phase. This will generate all
 /// of the requested outputs for this compilation session.
 pub fn link_binary(
@@ -208,8 +191,6 @@ pub fn link_binary(
         }
     }
 
-    check_link_info_print_request(sess, &codegen_results.crate_info.crate_types);
-
     // Remove the temporary object file and metadata if we aren't saving temps.
     sess.time("link_binary_remove_temps", || {
         // If the user requests that temporaries are saved, don't delete any.
diff --git a/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.rs b/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.rs
deleted file mode 100644
index b100c062bba..00000000000
--- a/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-//@ compile-flags: --print native-static-libs
-//@ check-pass
-//~? WARN cannot output linkage information without staticlib crate-type
-
-fn main() {}
diff --git a/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.stderr b/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.stderr
deleted file mode 100644
index ceff08baa13..00000000000
--- a/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.stderr
+++ /dev/null
@@ -1,6 +0,0 @@
-warning: cannot output linkage information without staticlib crate-type
-
-note: consider `--crate-type staticlib` to print linkage information
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.rs b/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.rs
deleted file mode 100644
index 3e9ca457a9c..00000000000
--- a/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-//@ compile-flags: --print native-static-libs --crate-type staticlib  --emit metadata
-//@ check-pass
-//~? WARN cannot output linkage information when --emit link is not passed
diff --git a/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.stderr b/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.stderr
deleted file mode 100644
index b32e1437d6b..00000000000
--- a/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.stderr
+++ /dev/null
@@ -1,4 +0,0 @@
-warning: cannot output linkage information when --emit link is not passed
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/print-request/stability.rs b/tests/ui/print-request/stability.rs
index fbcdf916cc7..54142ce78ce 100644
--- a/tests/ui/print-request/stability.rs
+++ b/tests/ui/print-request/stability.rs
@@ -110,4 +110,3 @@ fn main() {}
 //[check_cfg]~? ERROR the `-Z unstable-options` flag must also be passed to enable the `check-cfg` print option
 //[supported_crate_types]~? ERROR the `-Z unstable-options` flag must also be passed to enable the `supported-crate-types` print option
 //[target_spec_json]~? ERROR the `-Z unstable-options` flag must also be passed to enable the `target-spec-json` print option
-//[native_static_libs]~? WARNING cannot output linkage information without staticlib crate-type