about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-01-20 17:10:32 +0100
committerGitHub <noreply@github.com>2022-01-20 17:10:32 +0100
commit02379e917b2e187997bdabd290e61ecf0744faaf (patch)
tree90ecc736327bbe5a68f50eb5e9e16a2fdfdc1295 /src
parentd188287a54f1bb202e4c16067a6c4cdff4bdfd6c (diff)
parent371bd4643587da89ce1bbe7e577f49d9b8acb990 (diff)
downloadrust-02379e917b2e187997bdabd290e61ecf0744faaf.tar.gz
rust-02379e917b2e187997bdabd290e61ecf0744faaf.zip
Rollup merge of #91606 - joshtriplett:stabilize-print-link-args, r=pnkfelix
Stabilize `-Z print-link-args` as `--print link-args`

We have stable options for adding linker arguments; we should have a
stable option to help debug linker arguments.

Add documentation for the new option. In the documentation, make it clear that
the *exact* format of the output is not a stable guarantee.
Diffstat (limited to 'src')
-rw-r--r--src/doc/rustc/src/command-line-arguments.md6
-rw-r--r--src/test/run-make-fulldeps/codegen-options-parsing/Makefile4
-rw-r--r--src/test/run-make-fulldeps/interdependent-c-libraries/Makefile2
-rw-r--r--src/test/run-make-fulldeps/link-arg/Makefile2
-rw-r--r--src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile2
-rw-r--r--src/test/run-make-fulldeps/no-builtins-lto/Makefile2
-rw-r--r--src/test/run-make-fulldeps/redundant-libs/Makefile2
-rw-r--r--src/test/run-make-fulldeps/static-nobundle/Makefile4
8 files changed, 15 insertions, 9 deletions
diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md
index 7f482f0f2b1..11925ab9785 100644
--- a/src/doc/rustc/src/command-line-arguments.md
+++ b/src/doc/rustc/src/command-line-arguments.md
@@ -170,6 +170,12 @@ The valid types of print values are:
   include a diagnostic note that indicates the linker flags to use when
   linking the resulting static library. The note starts with the text
   `native-static-libs:` to make it easier to fetch the output.
+- `link-args` — This flag does not disable the `--emit` step. When linking,
+  this flag causes `rustc` to print the full linker invocation in a
+  human-readable form. This can be useful when debugging linker options. The
+  exact format of this debugging output is not a stable guarantee, other than
+  that it will include the linker executable and the text of each command-line
+  argument passed to the linker.
 
 [conditional compilation]: ../reference/conditional-compilation.html
 
diff --git a/src/test/run-make-fulldeps/codegen-options-parsing/Makefile b/src/test/run-make-fulldeps/codegen-options-parsing/Makefile
index 39e9a9bdd6b..f1410b69b3f 100644
--- a/src/test/run-make-fulldeps/codegen-options-parsing/Makefile
+++ b/src/test/run-make-fulldeps/codegen-options-parsing/Makefile
@@ -24,8 +24,8 @@ all:
 	$(RUSTC) -C lto dummy.rs
 
 	# Should not link dead code...
-	$(RUSTC) -Z print-link-args dummy.rs 2>&1 | \
+	$(RUSTC) --print link-args dummy.rs 2>&1 | \
 		$(CGREP) -e '--gc-sections|-z[^ ]* [^ ]*<ignore>|-dead_strip|/OPT:REF'
 	# ... unless you specifically ask to keep it
-	$(RUSTC) -Z print-link-args -C link-dead-code dummy.rs 2>&1 | \
+	$(RUSTC) --print link-args -C link-dead-code dummy.rs 2>&1 | \
 		$(CGREP) -ve '--gc-sections|-z[^ ]* [^ ]*<ignore>|-dead_strip|/OPT:REF'
diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/Makefile b/src/test/run-make-fulldeps/interdependent-c-libraries/Makefile
index 1268022e37b..0a50859cdaa 100644
--- a/src/test/run-make-fulldeps/interdependent-c-libraries/Makefile
+++ b/src/test/run-make-fulldeps/interdependent-c-libraries/Makefile
@@ -11,4 +11,4 @@
 all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar)
 	$(RUSTC) foo.rs
 	$(RUSTC) bar.rs
-	$(RUSTC) main.rs -Z print-link-args
+	$(RUSTC) main.rs --print link-args
diff --git a/src/test/run-make-fulldeps/link-arg/Makefile b/src/test/run-make-fulldeps/link-arg/Makefile
index d7c9fd27112..0360ede7625 100644
--- a/src/test/run-make-fulldeps/link-arg/Makefile
+++ b/src/test/run-make-fulldeps/link-arg/Makefile
@@ -1,5 +1,5 @@
 -include ../tools.mk
-RUSTC_FLAGS = -C link-arg="-lfoo" -C link-arg="-lbar" -Z print-link-args
+RUSTC_FLAGS = -C link-arg="-lfoo" -C link-arg="-lbar" --print link-args
 
 all:
 	$(RUSTC) $(RUSTC_FLAGS) empty.rs | $(CGREP) lfoo lbar
diff --git a/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile
index 09e6ae0bbf7..3ffbba9444b 100644
--- a/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile
+++ b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile
@@ -6,5 +6,5 @@ all:
 	$(RUSTC) bar.rs \
 		--extern foo1=$(TMPDIR)/libfoo-a.rlib \
 		--extern foo2=$(TMPDIR)/libfoo-b.rlib \
-		-Z print-link-args
+		--print link-args
 	$(call RUN,bar)
diff --git a/src/test/run-make-fulldeps/no-builtins-lto/Makefile b/src/test/run-make-fulldeps/no-builtins-lto/Makefile
index b9688f16c64..2e41be39d5d 100644
--- a/src/test/run-make-fulldeps/no-builtins-lto/Makefile
+++ b/src/test/run-make-fulldeps/no-builtins-lto/Makefile
@@ -6,4 +6,4 @@ all:
 	# Build an executable that depends on that crate using LTO. The no_builtins crate doesn't
 	# participate in LTO, so its rlib must be explicitly linked into the final binary. Verify this by
 	# grepping the linker arguments.
-	$(RUSTC) main.rs -C lto -Z print-link-args | $(CGREP) 'libno_builtins.rlib'
+	$(RUSTC) main.rs -C lto --print link-args | $(CGREP) 'libno_builtins.rlib'
diff --git a/src/test/run-make-fulldeps/redundant-libs/Makefile b/src/test/run-make-fulldeps/redundant-libs/Makefile
index 8468d102bec..e09841fb42e 100644
--- a/src/test/run-make-fulldeps/redundant-libs/Makefile
+++ b/src/test/run-make-fulldeps/redundant-libs/Makefile
@@ -16,7 +16,7 @@ RUSTC_FLAGS = \
     -l foo \
     -l static=baz \
     -l foo \
-    -Z print-link-args
+    --print link-args
 
 all: $(call DYLIB,foo) $(call STATICLIB,bar) $(call STATICLIB,baz)
 	$(RUSTC) $(RUSTC_FLAGS) main.rs
diff --git a/src/test/run-make-fulldeps/static-nobundle/Makefile b/src/test/run-make-fulldeps/static-nobundle/Makefile
index abc32d4423b..8f78c401a11 100644
--- a/src/test/run-make-fulldeps/static-nobundle/Makefile
+++ b/src/test/run-make-fulldeps/static-nobundle/Makefile
@@ -13,9 +13,9 @@ all: $(call NATIVE_STATICLIB,aaa)
 	nm $(TMPDIR)/libbbb.rlib | $(CGREP) -e "U _*native_func"
 
 	# Check that aaa gets linked (either as `-l aaa` or `aaa.lib`) when building ccc.
-	$(RUSTC) ccc.rs -C prefer-dynamic --crate-type=dylib -Z print-link-args | $(CGREP) -e '-l[" ]*aaa|aaa\.lib'
+	$(RUSTC) ccc.rs -C prefer-dynamic --crate-type=dylib --print link-args | $(CGREP) -e '-l[" ]*aaa|aaa\.lib'
 
 	# Check that aaa does NOT get linked when building ddd.
-	$(RUSTC) ddd.rs -Z print-link-args | $(CGREP) -ve '-l[" ]*aaa|aaa\.lib'
+	$(RUSTC) ddd.rs --print link-args | $(CGREP) -ve '-l[" ]*aaa|aaa\.lib'
 
 	$(call RUN,ddd)