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.
This commit is contained in:
Matthias Krüger 2022-01-20 17:10:32 +01:00 committed by GitHub
commit 02379e917b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 24 additions and 17 deletions

View file

@ -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'

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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'

View file

@ -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

View file

@ -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)