authorbors <bors@rust-lang.org> 2024-06-20 18:21:01 UTC
committerbors <bors@rust-lang.org> 2024-06-20 18:21:01 UTC
log433355166d769afc9c19f761cc7efc4d152e9a2c
tree2412ee497bc589da0ba13b9f3ccc3ec166d745bb
parentcb8a7ea0ed866295e0f65725cea6662bea51971a
parent7b5ed5a66c7e1ec0d2d8ba3657a4048ceea36988

Auto merge of #126745 - matthiaskrgr:rollup-xagplef, r=matthiaskrgr

Rollup of 6 pull requests Successful merges: - #126095 (Migrate `link-args-order`, `ls-metadata` and `lto-readonly-lib` `run-make` tests to `rmake`) - #126629 (Migrate `run-make/compressed-debuginfo` to `rmake.rs`) - #126644 (Rewrite `extern-flag-rename-transitive`. `debugger-visualizer-dep-info`, `metadata-flag-frobs-symbols`, `extern-overrides-distribution` and `forced-unwind-terminate-pof` `run-make` tests to rmake) - #126735 (collect attrs in const block expr) - #126737 (Remove `feature(const_closures)` from libcore) - #126740 (add `needs-unwind` to UI test) r? `@ghost` `@rustbot` modify labels: rollup

25 files changed, 216 insertions(+), 97 deletions(-)

compiler/rustc_resolve/src/def_collector.rs+3
...@@ -343,6 +343,9 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {...@@ -343,6 +343,9 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
343 self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span)343 self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span)
344 }344 }
345 ExprKind::ConstBlock(ref constant) => {345 ExprKind::ConstBlock(ref constant) => {
346 for attr in &expr.attrs {
347 visit::walk_attribute(self, attr);
348 }
346 let def = self.create_def(349 let def = self.create_def(
347 constant.id,350 constant.id,
348 kw::Empty,351 kw::Empty,
library/core/src/lib.rs-1
...@@ -209,7 +209,6 @@...@@ -209,7 +209,6 @@
209#![feature(cfg_sanitize)]209#![feature(cfg_sanitize)]
210#![feature(cfg_target_has_atomic)]210#![feature(cfg_target_has_atomic)]
211#![feature(cfg_target_has_atomic_equal_alignment)]211#![feature(cfg_target_has_atomic_equal_alignment)]
212#![feature(const_closures)]
213#![feature(const_fn_floating_point_arithmetic)]212#![feature(const_fn_floating_point_arithmetic)]
214#![feature(const_for)]213#![feature(const_for)]
215#![feature(const_mut_refs)]214#![feature(const_mut_refs)]
src/tools/run-make-support/src/rustc.rs+18
...@@ -73,6 +73,12 @@ impl Rustc {...@@ -73,6 +73,12 @@ impl Rustc {
73 self73 self
74 }74 }
7575
76 /// Incorporate a hashed string to mangled symbols.
77 pub fn metadata(&mut self, meta: &str) -> &mut Self {
78 self.cmd.arg(format!("-Cmetadata={meta}"));
79 self
80 }
81
76 /// Add a suffix in each output filename.82 /// Add a suffix in each output filename.
77 pub fn extra_filename(&mut self, suffix: &str) -> &mut Self {83 pub fn extra_filename(&mut self, suffix: &str) -> &mut Self {
78 self.cmd.arg(format!("-Cextra-filename={suffix}"));84 self.cmd.arg(format!("-Cextra-filename={suffix}"));
...@@ -230,6 +236,12 @@ impl Rustc {...@@ -230,6 +236,12 @@ impl Rustc {
230 self236 self
231 }237 }
232238
239 /// Add multiple extra arguments to the linker invocation, via `-Clink-args`.
240 pub fn link_args(&mut self, link_args: &str) -> &mut Self {
241 self.cmd.arg(format!("-Clink-args={link_args}"));
242 self
243 }
244
233 /// Specify a stdin input245 /// Specify a stdin input
234 pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {246 pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
235 self.cmd.set_stdin(input.as_ref().to_vec().into_boxed_slice());247 self.cmd.set_stdin(input.as_ref().to_vec().into_boxed_slice());
...@@ -248,4 +260,10 @@ impl Rustc {...@@ -248,4 +260,10 @@ impl Rustc {
248 self.cmd.arg(format!("-Clinker={linker}"));260 self.cmd.arg(format!("-Clinker={linker}"));
249 self261 self
250 }262 }
263
264 /// Specify the linker flavor
265 pub fn linker_flavor(&mut self, linker_flavor: &str) -> &mut Self {
266 self.cmd.arg(format!("-Clinker-flavor={linker_flavor}"));
267 self
268 }
251}269}
src/tools/tidy/src/allowed_run_make_makefiles.txt-9
...@@ -13,7 +13,6 @@ run-make/cdylib-fewer-symbols/Makefile...@@ -13,7 +13,6 @@ run-make/cdylib-fewer-symbols/Makefile
13run-make/compiler-lookup-paths-2/Makefile13run-make/compiler-lookup-paths-2/Makefile
14run-make/compiler-lookup-paths/Makefile14run-make/compiler-lookup-paths/Makefile
15run-make/compiler-rt-works-on-mingw/Makefile15run-make/compiler-rt-works-on-mingw/Makefile
16run-make/compressed-debuginfo/Makefile
17run-make/crate-hash-rustc-version/Makefile16run-make/crate-hash-rustc-version/Makefile
18run-make/crate-name-priority/Makefile17run-make/crate-name-priority/Makefile
19run-make/cross-lang-lto-clang/Makefile18run-make/cross-lang-lto-clang/Makefile
...@@ -21,7 +20,6 @@ run-make/cross-lang-lto-pgo-smoketest/Makefile...@@ -21,7 +20,6 @@ run-make/cross-lang-lto-pgo-smoketest/Makefile
21run-make/cross-lang-lto-upstream-rlibs/Makefile20run-make/cross-lang-lto-upstream-rlibs/Makefile
22run-make/cross-lang-lto/Makefile21run-make/cross-lang-lto/Makefile
23run-make/debug-assertions/Makefile22run-make/debug-assertions/Makefile
24run-make/debugger-visualizer-dep-info/Makefile
25run-make/dep-info-doesnt-run-much/Makefile23run-make/dep-info-doesnt-run-much/Makefile
26run-make/dep-info-spaces/Makefile24run-make/dep-info-spaces/Makefile
27run-make/dep-info/Makefile25run-make/dep-info/Makefile
...@@ -38,7 +36,6 @@ run-make/export-executable-symbols/Makefile...@@ -38,7 +36,6 @@ run-make/export-executable-symbols/Makefile
38run-make/extern-diff-internal-name/Makefile36run-make/extern-diff-internal-name/Makefile
39run-make/extern-flag-disambiguates/Makefile37run-make/extern-flag-disambiguates/Makefile
40run-make/extern-flag-pathless/Makefile38run-make/extern-flag-pathless/Makefile
41run-make/extern-flag-rename-transitive/Makefile
42run-make/extern-fn-explicit-align/Makefile39run-make/extern-fn-explicit-align/Makefile
43run-make/extern-fn-generic/Makefile40run-make/extern-fn-generic/Makefile
44run-make/extern-fn-mangle/Makefile41run-make/extern-fn-mangle/Makefile
...@@ -49,10 +46,8 @@ run-make/extern-fn-with-packed-struct/Makefile...@@ -49,10 +46,8 @@ run-make/extern-fn-with-packed-struct/Makefile
49run-make/extern-fn-with-union/Makefile46run-make/extern-fn-with-union/Makefile
50run-make/extern-multiple-copies/Makefile47run-make/extern-multiple-copies/Makefile
51run-make/extern-multiple-copies2/Makefile48run-make/extern-multiple-copies2/Makefile
52run-make/extern-overrides-distribution/Makefile
53run-make/extra-filename-with-temp-outputs/Makefile49run-make/extra-filename-with-temp-outputs/Makefile
54run-make/fmt-write-bloat/Makefile50run-make/fmt-write-bloat/Makefile
55run-make/forced-unwind-terminate-pof/Makefile
56run-make/foreign-double-unwind/Makefile51run-make/foreign-double-unwind/Makefile
57run-make/foreign-exceptions/Makefile52run-make/foreign-exceptions/Makefile
58run-make/foreign-rust-exceptions/Makefile53run-make/foreign-rust-exceptions/Makefile
...@@ -96,7 +91,6 @@ run-make/libtest-json/Makefile...@@ -96,7 +91,6 @@ run-make/libtest-json/Makefile
96run-make/libtest-junit/Makefile91run-make/libtest-junit/Makefile
97run-make/libtest-padding/Makefile92run-make/libtest-padding/Makefile
98run-make/libtest-thread-limit/Makefile93run-make/libtest-thread-limit/Makefile
99run-make/link-args-order/Makefile
100run-make/link-cfg/Makefile94run-make/link-cfg/Makefile
101run-make/link-framework/Makefile95run-make/link-framework/Makefile
102run-make/link-path-order/Makefile96run-make/link-path-order/Makefile
...@@ -105,19 +99,16 @@ run-make/llvm-ident/Makefile...@@ -105,19 +99,16 @@ run-make/llvm-ident/Makefile
105run-make/long-linker-command-lines-cmd-exe/Makefile99run-make/long-linker-command-lines-cmd-exe/Makefile
106run-make/long-linker-command-lines/Makefile100run-make/long-linker-command-lines/Makefile
107run-make/longjmp-across-rust/Makefile101run-make/longjmp-across-rust/Makefile
108run-make/ls-metadata/Makefile
109run-make/lto-dylib-dep/Makefile102run-make/lto-dylib-dep/Makefile
110run-make/lto-empty/Makefile103run-make/lto-empty/Makefile
111run-make/lto-linkage-used-attr/Makefile104run-make/lto-linkage-used-attr/Makefile
112run-make/lto-no-link-whole-rlib/Makefile105run-make/lto-no-link-whole-rlib/Makefile
113run-make/lto-readonly-lib/Makefile
114run-make/lto-smoke-c/Makefile106run-make/lto-smoke-c/Makefile
115run-make/macos-deployment-target/Makefile107run-make/macos-deployment-target/Makefile
116run-make/macos-fat-archive/Makefile108run-make/macos-fat-archive/Makefile
117run-make/manual-link/Makefile109run-make/manual-link/Makefile
118run-make/many-crates-but-no-match/Makefile110run-make/many-crates-but-no-match/Makefile
119run-make/metadata-dep-info/Makefile111run-make/metadata-dep-info/Makefile
120run-make/metadata-flag-frobs-symbols/Makefile
121run-make/min-global-align/Makefile112run-make/min-global-align/Makefile
122run-make/mingw-export-call-convention/Makefile113run-make/mingw-export-call-convention/Makefile
123run-make/mismatching-target-triples/Makefile114run-make/mismatching-target-triples/Makefile
tests/run-make/compressed-debuginfo/Makefile deleted-14
...@@ -1,14 +0,0 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# only-linux
5#
6# This tests debuginfo-compression.
7
8all: zlib zstandard
9
10zlib:
11 test "`$(RUSTC) --crate-name=foo --crate-type=lib --emit=obj -C debuginfo=full -Z debuginfo-compression=zlib foo.rs 2>&1 | sed 's/.*unknown.*zlib.*/missing/' | head -n 1`" = missing || readelf -t $(TMPDIR)/foo.o | grep -q ZLIB
12
13zstandard:
14 test "`$(RUSTC) --crate-name=foo --crate-type=lib --emit=obj -C debuginfo=full -Z debuginfo-compression=zstd foo.rs 2>&1 | sed 's/.*unknown.*zstd.*/missing/' | head -n 1`" = missing || readelf -t $(TMPDIR)/foo.o | grep -q ZST
tests/run-make/compressed-debuginfo/rmake.rs created+36
...@@ -0,0 +1,36 @@
1// Checks the `debuginfo-compression` option.
2
3//@ only-linux
4//@ ignore-cross-compile
5
6// FIXME: This test isn't comprehensive and isn't covering all possible combinations.
7
8use run_make_support::{assert_contains, cmd, run_in_tmpdir, rustc};
9
10fn check_compression(compression: &str, to_find: &str) {
11 run_in_tmpdir(|| {
12 let out = rustc()
13 .crate_name("foo")
14 .crate_type("lib")
15 .emit("obj")
16 .arg("-Cdebuginfo=full")
17 .arg(&format!("-Zdebuginfo-compression={compression}"))
18 .input("foo.rs")
19 .run();
20 let stderr = out.stderr_utf8();
21 if stderr.is_empty() {
22 // FIXME: `readelf` might need to be replaced with `llvm-readelf`.
23 cmd("readelf").arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
24 } else {
25 assert_contains(
26 &stderr,
27 &format!("unknown debuginfo compression algorithm {compression}"),
28 );
29 }
30 });
31}
32
33fn main() {
34 check_compression("zlib", "ZLIB");
35 check_compression("zstd", "ZSTD");
36}
tests/run-make/debugger-visualizer-dep-info/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# This test makes sure that files referenced via #[debugger_visualizer] are
4# included in `--emit dep-info` output.
5
6all:
7 $(RUSTC) --emit dep-info main.rs
8 $(CGREP) "foo.py" < $(TMPDIR)/main.d
9 $(CGREP) "my_visualizers/bar.natvis" < $(TMPDIR)/main.d
tests/run-make/debugger-visualizer-dep-info/rmake.rs created+11
...@@ -0,0 +1,11 @@
1// This test checks that files referenced via #[debugger_visualizer] are
2// included in `--emit dep-info` output.
3// See https://github.com/rust-lang/rust/pull/111641
4
5use run_make_support::{invalid_utf8_contains, rustc};
6
7fn main() {
8 rustc().emit("dep-info").input("main.rs").run();
9 invalid_utf8_contains("main.d", "foo.py");
10 invalid_utf8_contains("main.d", "my_visualizers/bar.natvis");
11}
tests/run-make/extern-flag-rename-transitive/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs
5 $(RUSTC) bar.rs
6 $(RUSTC) baz.rs --extern a=$(TMPDIR)/libfoo.rlib
7
tests/run-make/extern-flag-rename-transitive/rmake.rs created+14
...@@ -0,0 +1,14 @@
1// In this test, baz.rs is looking for an extern crate "a" which
2// does not exist, and can only run through the --extern rustc flag
3// defining that the "a" crate is in fact just "foo". This test
4// checks that the --extern flag takes precedence over the extern
5// crate statement in the code.
6// See https://github.com/rust-lang/rust/pull/52723
7
8use run_make_support::{rust_lib_name, rustc};
9
10fn main() {
11 rustc().input("foo.rs").run();
12 rustc().input("bar.rs").run();
13 rustc().input("baz.rs").extern_("a", rust_lib_name("foo")).run();
14}
tests/run-make/extern-overrides-distribution/Makefile deleted-6
...@@ -1,6 +0,0 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) libc.rs -Cmetadata=foo
6 $(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib
tests/run-make/extern-overrides-distribution/rmake.rs created+14
...@@ -0,0 +1,14 @@
1// The --extern flag should override any "crate_type" declarations in the
2// Rust files themselves. In this test, libc is compiled as "lib", but
3// main.rs will only run with an rlib, which checks if the --extern flag
4// is successfully overriding the default behaviour.
5// See https://github.com/rust-lang/rust/pull/21782
6
7//@ ignore-cross-compile
8
9use run_make_support::{rust_lib_name, rustc};
10
11fn main() {
12 rustc().input("libc.rs").metadata("foo").run();
13 rustc().input("main.rs").extern_("libc", rust_lib_name("libc")).run();
14}
tests/run-make/forced-unwind-terminate-pof/Makefile deleted-9
...@@ -1,9 +0,0 @@
1# ignore-cross-compile
2# only-linux
3include ../tools.mk
4
5all: foo
6 $(call RUN,foo) | $(CGREP) -v "cannot unwind"
7
8foo: foo.rs
9 $(RUSTC) $<
tests/run-make/forced-unwind-terminate-pof/rmake.rs created+16
...@@ -0,0 +1,16 @@
1// During a forced unwind, crossing the non-Plain Old Frame
2// would define the forced unwind as undefined behaviour, and
3// immediately abort the unwinding process. This test checks
4// that the forced unwinding takes precedence.
5// See https://github.com/rust-lang/rust/issues/101469
6
7//@ ignore-cross-compile
8//@ ignore-windows
9//Reason: pthread (POSIX threads) is not available on Windows
10
11use run_make_support::{run, rustc};
12
13fn main() {
14 rustc().input("foo.rs").run();
15 run("foo").assert_stdout_not_contains("cannot unwind");
16}
tests/run-make/link-args-order/Makefile deleted-10
...@@ -1,10 +0,0 @@
1# ignore-msvc
2
3include ../tools.mk
4
5RUSTC_FLAGS = -C linker-flavor=ld -C link-arg=a -C link-args="b c" -C link-args="d e" -C link-arg=f
6RUSTC_FLAGS_PRE = -C linker-flavor=ld -Z pre-link-arg=a -Z pre-link-args="b c" -Z pre-link-args="d e" -Z pre-link-arg=f
7
8all:
9 $(RUSTC) $(RUSTC_FLAGS) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
10 $(RUSTC) $(RUSTC_FLAGS_PRE) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
tests/run-make/link-args-order/rmake.rs created+30
...@@ -0,0 +1,30 @@
1// Passing linker arguments to the compiler used to be lost or reordered in a messy way
2// as they were passed further to the linker. This was fixed in #70665, and this test
3// checks that linker arguments remain intact and in the order they were originally passed in.
4// See https://github.com/rust-lang/rust/pull/70665
5
6//@ ignore-msvc
7// Reason: the ld linker does not exist on Windows.
8
9use run_make_support::rustc;
10
11fn main() {
12 rustc()
13 .input("empty.rs")
14 .linker_flavor("ld")
15 .link_arg("a")
16 .link_args("b c")
17 .link_args("d e")
18 .link_arg("f")
19 .run_fail()
20 .assert_stderr_contains(r#""a" "b" "c" "d" "e" "f""#);
21 rustc()
22 .input("empty.rs")
23 .linker_flavor("ld")
24 .arg("-Zpre-link-arg=a")
25 .arg("-Zpre-link-args=b c")
26 .arg("-Zpre-link-args=d e")
27 .arg("-Zpre-link-arg=f")
28 .run_fail()
29 .assert_stderr_contains(r#""a" "b" "c" "d" "e" "f""#);
30}
tests/run-make/ls-metadata/Makefile deleted-8
...@@ -1,8 +0,0 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs
6 $(RUSTC) -Z ls=root $(TMPDIR)/foo
7 touch $(TMPDIR)/bar
8 $(RUSTC) -Z ls=root $(TMPDIR)/bar
tests/run-make/ls-metadata/rmake.rs created+17
...@@ -0,0 +1,17 @@
1// Passing invalid files to -Z ls (which lists the symbols
2// defined by a library crate) used to cause a segmentation fault.
3// As this was fixed in #11262, this test checks that no segfault
4// occurs when passing the invalid file `bar` to -Z ls.
5// See https://github.com/rust-lang/rust/issues/11259
6
7//@ ignore-cross-compile
8
9use run_make_support::fs_wrapper;
10use run_make_support::rustc;
11
12fn main() {
13 rustc().input("foo.rs").run();
14 rustc().arg("-Zls=root").input("foo").run();
15 fs_wrapper::create_file("bar");
16 rustc().arg("-Zls=root").input("bar").run();
17}
tests/run-make/lto-readonly-lib/Makefile deleted-13
...@@ -1,13 +0,0 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) lib.rs
6
7 # the compiler needs to copy and modify the rlib file when performing
8 # LTO, so we should ensure that it can cope with the original rlib
9 # being read-only.
10 chmod 444 $(TMPDIR)/*.rlib
11
12 $(RUSTC) main.rs -C lto
13 $(call RUN,main)
tests/run-make/lto-readonly-lib/rmake.rs created+19
...@@ -0,0 +1,19 @@
1// When the compiler is performing link time optimization, it will
2// need to copy the original rlib file, set the copy's permissions to read/write,
3// and modify that copy - even if the original
4// file is read-only. This test creates a read-only rlib, and checks that
5// compilation with LTO succeeds.
6// See https://github.com/rust-lang/rust/pull/17619
7
8//@ ignore-cross-compile
9
10use run_make_support::fs_wrapper;
11use run_make_support::{run, rust_lib_name, rustc, test_while_readonly};
12
13fn main() {
14 rustc().input("lib.rs").run();
15 test_while_readonly(rust_lib_name("lib"), || {
16 rustc().input("main.rs").arg("-Clto").run();
17 run("main");
18 });
19}
tests/run-make/metadata-flag-frobs-symbols/Makefile deleted-11
...@@ -1,11 +0,0 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs -C metadata=a -C extra-filename=-a
6 $(RUSTC) foo.rs -C metadata=b -C extra-filename=-b
7 $(RUSTC) bar.rs \
8 --extern foo1=$(TMPDIR)/libfoo-a.rlib \
9 --extern foo2=$(TMPDIR)/libfoo-b.rlib \
10 --print link-args
11 $(call RUN,bar)
tests/run-make/metadata-flag-frobs-symbols/rmake.rs created+20
...@@ -0,0 +1,20 @@
1// In this test, foo.rs is compiled twice with different hashes tied to its
2// symbols thanks to the metadata flag. bar.rs then ensures that the memory locations
3// of foo's symbols are different even though they came from the same original source code.
4// This checks that the metadata flag is doing its job.
5// See https://github.com/rust-lang/rust/issues/14471
6
7//@ ignore-cross-compile
8
9use run_make_support::{run, rust_lib_name, rustc};
10
11fn main() {
12 rustc().input("foo.rs").metadata("a").extra_filename("-a").run();
13 rustc().input("foo.rs").metadata("b").extra_filename("-b").run();
14 rustc()
15 .input("bar.rs")
16 .extern_("foo1", rust_lib_name("foo-a"))
17 .extern_("foo2", rust_lib_name("foo-b"))
18 .run();
19 run("bar");
20}
tests/ui/lifetimes/tail-expr-lock-poisoning.rs+1
...@@ -3,6 +3,7 @@...@@ -3,6 +3,7 @@
3//@ [edition2024] compile-flags: -Zunstable-options3//@ [edition2024] compile-flags: -Zunstable-options
4//@ [edition2024] edition: 20244//@ [edition2024] edition: 2024
5//@ run-pass5//@ run-pass
6//@ needs-unwind
6#![cfg_attr(edition2024, feature(shorter_tail_lifetimes))]7#![cfg_attr(edition2024, feature(shorter_tail_lifetimes))]
78
8use std::sync::Mutex;9use std::sync::Mutex;
tests/ui/resolve/path-attr-in-const-block.rs created+9
...@@ -0,0 +1,9 @@
1// issue#126516
2// issue#126647
3
4fn main() {
5 const {
6 #![path = foo!()]
7 //~^ ERROR: cannot find macro `foo` in this scope
8 }
9}
tests/ui/resolve/path-attr-in-const-block.stderr created+8
...@@ -0,0 +1,8 @@
1error: cannot find macro `foo` in this scope
2 --> $DIR/path-attr-in-const-block.rs:6:19
3 |
4LL | #![path = foo!()]
5 | ^^^
6
7error: aborting due to 1 previous error
8