about summary refs log tree commit diff
path: root/tests/run-make
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2024-12-21 10:06:07 -0500
committerjyn <github@jyn.dev>2025-01-20 16:46:45 -0500
commitb757663a00260e22799a1bbdc5d6ba603e4bb30d (patch)
tree4a78b3924fb7f6bfd37ef6cf9e2b19e8082f0eb0 /tests/run-make
parentcedd4cad21298ca8b825ab3c56a84753176dc8e8 (diff)
downloadrust-b757663a00260e22799a1bbdc5d6ba603e4bb30d.tar.gz
rust-b757663a00260e22799a1bbdc5d6ba603e4bb30d.zip
don't ICE when emitting linker errors during `-Z link-only`
note that this still ICEs when passed `-Z link-only --error-format json` because i can't be bothered to fix it right now
Diffstat (limited to 'tests/run-make')
-rw-r--r--tests/run-make/linker-warning/rmake.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/run-make/linker-warning/rmake.rs b/tests/run-make/linker-warning/rmake.rs
index d2bb12aafcb..5967f5b32e9 100644
--- a/tests/run-make/linker-warning/rmake.rs
+++ b/tests/run-make/linker-warning/rmake.rs
@@ -44,4 +44,33 @@ fn main() {
         .assert_stderr_contains("object files omitted")
         .assert_stderr_contains_regex(r"\{")
         .assert_stderr_not_contains_regex(r"lib(/|\\\\)libstd");
+
+    // Make sure we show linker warnings even across `-Z no-link`
+    rustc()
+        .arg("-Zno-link")
+        .input("-")
+        .stdin_buf("#![deny(linker_messages)] \n fn main() {}")
+        .run()
+        .assert_stderr_equals("");
+    rustc()
+        .arg("-Zlink-only")
+        .arg("rust_out.rlink")
+        .linker("./fake-linker")
+        .link_arg("run_make_warn")
+        .run_fail()
+        // NOTE: the error message here is quite bad (we don't have a source
+        // span, but still try to print the lint source). But `-Z link-only` is
+        // unstable and this still shows the linker warning itself so this is
+        // probably good enough.
+        .assert_stderr_contains("linker stderr: bar");
+
+    // Same thing, but with json output.
+    rustc()
+        .error_format("json")
+        .arg("-Zlink-only")
+        .arg("rust_out.rlink")
+        .linker("./fake-linker")
+        .link_arg("run_make_warn")
+        .run_fail()
+        .assert_stderr_contains(r#""$message_type":"diagnostic""#);
 }