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
This commit is contained in:
bors 2024-06-20 18:21:01 +00:00
commit 433355166d
25 changed files with 216 additions and 97 deletions

View file

@ -343,6 +343,9 @@ fn visit_expr(&mut self, expr: &'a Expr) {
self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span)
}
ExprKind::ConstBlock(ref constant) => {
for attr in &expr.attrs {
visit::walk_attribute(self, attr);
}
let def = self.create_def(
constant.id,
kw::Empty,

View file

@ -209,7 +209,6 @@
#![feature(cfg_sanitize)]
#![feature(cfg_target_has_atomic)]
#![feature(cfg_target_has_atomic_equal_alignment)]
#![feature(const_closures)]
#![feature(const_fn_floating_point_arithmetic)]
#![feature(const_for)]
#![feature(const_mut_refs)]

View file

@ -73,6 +73,12 @@ pub fn opt_level(&mut self, option: &str) -> &mut Self {
self
}
/// Incorporate a hashed string to mangled symbols.
pub fn metadata(&mut self, meta: &str) -> &mut Self {
self.cmd.arg(format!("-Cmetadata={meta}"));
self
}
/// Add a suffix in each output filename.
pub fn extra_filename(&mut self, suffix: &str) -> &mut Self {
self.cmd.arg(format!("-Cextra-filename={suffix}"));
@ -230,6 +236,12 @@ pub fn link_arg(&mut self, link_arg: &str) -> &mut Self {
self
}
/// Add multiple extra arguments to the linker invocation, via `-Clink-args`.
pub fn link_args(&mut self, link_args: &str) -> &mut Self {
self.cmd.arg(format!("-Clink-args={link_args}"));
self
}
/// Specify a stdin input
pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
self.cmd.set_stdin(input.as_ref().to_vec().into_boxed_slice());
@ -248,4 +260,10 @@ pub fn linker(&mut self, linker: &str) -> &mut Self {
self.cmd.arg(format!("-Clinker={linker}"));
self
}
/// Specify the linker flavor
pub fn linker_flavor(&mut self, linker_flavor: &str) -> &mut Self {
self.cmd.arg(format!("-Clinker-flavor={linker_flavor}"));
self
}
}

View file

@ -13,7 +13,6 @@ run-make/cdylib-fewer-symbols/Makefile
run-make/compiler-lookup-paths-2/Makefile
run-make/compiler-lookup-paths/Makefile
run-make/compiler-rt-works-on-mingw/Makefile
run-make/compressed-debuginfo/Makefile
run-make/crate-hash-rustc-version/Makefile
run-make/crate-name-priority/Makefile
run-make/cross-lang-lto-clang/Makefile
@ -21,7 +20,6 @@ run-make/cross-lang-lto-pgo-smoketest/Makefile
run-make/cross-lang-lto-upstream-rlibs/Makefile
run-make/cross-lang-lto/Makefile
run-make/debug-assertions/Makefile
run-make/debugger-visualizer-dep-info/Makefile
run-make/dep-info-doesnt-run-much/Makefile
run-make/dep-info-spaces/Makefile
run-make/dep-info/Makefile
@ -38,7 +36,6 @@ run-make/export-executable-symbols/Makefile
run-make/extern-diff-internal-name/Makefile
run-make/extern-flag-disambiguates/Makefile
run-make/extern-flag-pathless/Makefile
run-make/extern-flag-rename-transitive/Makefile
run-make/extern-fn-explicit-align/Makefile
run-make/extern-fn-generic/Makefile
run-make/extern-fn-mangle/Makefile
@ -49,10 +46,8 @@ run-make/extern-fn-with-packed-struct/Makefile
run-make/extern-fn-with-union/Makefile
run-make/extern-multiple-copies/Makefile
run-make/extern-multiple-copies2/Makefile
run-make/extern-overrides-distribution/Makefile
run-make/extra-filename-with-temp-outputs/Makefile
run-make/fmt-write-bloat/Makefile
run-make/forced-unwind-terminate-pof/Makefile
run-make/foreign-double-unwind/Makefile
run-make/foreign-exceptions/Makefile
run-make/foreign-rust-exceptions/Makefile
@ -96,7 +91,6 @@ run-make/libtest-json/Makefile
run-make/libtest-junit/Makefile
run-make/libtest-padding/Makefile
run-make/libtest-thread-limit/Makefile
run-make/link-args-order/Makefile
run-make/link-cfg/Makefile
run-make/link-framework/Makefile
run-make/link-path-order/Makefile
@ -105,19 +99,16 @@ run-make/llvm-ident/Makefile
run-make/long-linker-command-lines-cmd-exe/Makefile
run-make/long-linker-command-lines/Makefile
run-make/longjmp-across-rust/Makefile
run-make/ls-metadata/Makefile
run-make/lto-dylib-dep/Makefile
run-make/lto-empty/Makefile
run-make/lto-linkage-used-attr/Makefile
run-make/lto-no-link-whole-rlib/Makefile
run-make/lto-readonly-lib/Makefile
run-make/lto-smoke-c/Makefile
run-make/macos-deployment-target/Makefile
run-make/macos-fat-archive/Makefile
run-make/manual-link/Makefile
run-make/many-crates-but-no-match/Makefile
run-make/metadata-dep-info/Makefile
run-make/metadata-flag-frobs-symbols/Makefile
run-make/min-global-align/Makefile
run-make/mingw-export-call-convention/Makefile
run-make/mismatching-target-triples/Makefile

View file

@ -1,14 +0,0 @@
# ignore-cross-compile
include ../tools.mk
# only-linux
#
# This tests debuginfo-compression.
all: zlib zstandard
zlib:
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
zstandard:
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

View file

@ -0,0 +1,36 @@
// Checks the `debuginfo-compression` option.
//@ only-linux
//@ ignore-cross-compile
// FIXME: This test isn't comprehensive and isn't covering all possible combinations.
use run_make_support::{assert_contains, cmd, run_in_tmpdir, rustc};
fn check_compression(compression: &str, to_find: &str) {
run_in_tmpdir(|| {
let out = rustc()
.crate_name("foo")
.crate_type("lib")
.emit("obj")
.arg("-Cdebuginfo=full")
.arg(&format!("-Zdebuginfo-compression={compression}"))
.input("foo.rs")
.run();
let stderr = out.stderr_utf8();
if stderr.is_empty() {
// FIXME: `readelf` might need to be replaced with `llvm-readelf`.
cmd("readelf").arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
} else {
assert_contains(
&stderr,
&format!("unknown debuginfo compression algorithm {compression}"),
);
}
});
}
fn main() {
check_compression("zlib", "ZLIB");
check_compression("zstd", "ZSTD");
}

View file

@ -1,9 +0,0 @@
include ../tools.mk
# This test makes sure that files referenced via #[debugger_visualizer] are
# included in `--emit dep-info` output.
all:
$(RUSTC) --emit dep-info main.rs
$(CGREP) "foo.py" < $(TMPDIR)/main.d
$(CGREP) "my_visualizers/bar.natvis" < $(TMPDIR)/main.d

View file

@ -0,0 +1,11 @@
// This test checks that files referenced via #[debugger_visualizer] are
// included in `--emit dep-info` output.
// See https://github.com/rust-lang/rust/pull/111641
use run_make_support::{invalid_utf8_contains, rustc};
fn main() {
rustc().emit("dep-info").input("main.rs").run();
invalid_utf8_contains("main.d", "foo.py");
invalid_utf8_contains("main.d", "my_visualizers/bar.natvis");
}

View file

@ -1,7 +0,0 @@
include ../tools.mk
all:
$(RUSTC) foo.rs
$(RUSTC) bar.rs
$(RUSTC) baz.rs --extern a=$(TMPDIR)/libfoo.rlib

View file

@ -0,0 +1,14 @@
// In this test, baz.rs is looking for an extern crate "a" which
// does not exist, and can only run through the --extern rustc flag
// defining that the "a" crate is in fact just "foo". This test
// checks that the --extern flag takes precedence over the extern
// crate statement in the code.
// See https://github.com/rust-lang/rust/pull/52723
use run_make_support::{rust_lib_name, rustc};
fn main() {
rustc().input("foo.rs").run();
rustc().input("bar.rs").run();
rustc().input("baz.rs").extern_("a", rust_lib_name("foo")).run();
}

View file

@ -1,6 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all:
$(RUSTC) libc.rs -Cmetadata=foo
$(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib

View file

@ -0,0 +1,14 @@
// The --extern flag should override any "crate_type" declarations in the
// Rust files themselves. In this test, libc is compiled as "lib", but
// main.rs will only run with an rlib, which checks if the --extern flag
// is successfully overriding the default behaviour.
// See https://github.com/rust-lang/rust/pull/21782
//@ ignore-cross-compile
use run_make_support::{rust_lib_name, rustc};
fn main() {
rustc().input("libc.rs").metadata("foo").run();
rustc().input("main.rs").extern_("libc", rust_lib_name("libc")).run();
}

View file

@ -1,9 +0,0 @@
# ignore-cross-compile
# only-linux
include ../tools.mk
all: foo
$(call RUN,foo) | $(CGREP) -v "cannot unwind"
foo: foo.rs
$(RUSTC) $<

View file

@ -0,0 +1,16 @@
// During a forced unwind, crossing the non-Plain Old Frame
// would define the forced unwind as undefined behaviour, and
// immediately abort the unwinding process. This test checks
// that the forced unwinding takes precedence.
// See https://github.com/rust-lang/rust/issues/101469
//@ ignore-cross-compile
//@ ignore-windows
//Reason: pthread (POSIX threads) is not available on Windows
use run_make_support::{run, rustc};
fn main() {
rustc().input("foo.rs").run();
run("foo").assert_stdout_not_contains("cannot unwind");
}

View file

@ -1,10 +0,0 @@
# ignore-msvc
include ../tools.mk
RUSTC_FLAGS = -C linker-flavor=ld -C link-arg=a -C link-args="b c" -C link-args="d e" -C link-arg=f
RUSTC_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
all:
$(RUSTC) $(RUSTC_FLAGS) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
$(RUSTC) $(RUSTC_FLAGS_PRE) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'

View file

@ -0,0 +1,30 @@
// Passing linker arguments to the compiler used to be lost or reordered in a messy way
// as they were passed further to the linker. This was fixed in #70665, and this test
// checks that linker arguments remain intact and in the order they were originally passed in.
// See https://github.com/rust-lang/rust/pull/70665
//@ ignore-msvc
// Reason: the ld linker does not exist on Windows.
use run_make_support::rustc;
fn main() {
rustc()
.input("empty.rs")
.linker_flavor("ld")
.link_arg("a")
.link_args("b c")
.link_args("d e")
.link_arg("f")
.run_fail()
.assert_stderr_contains(r#""a" "b" "c" "d" "e" "f""#);
rustc()
.input("empty.rs")
.linker_flavor("ld")
.arg("-Zpre-link-arg=a")
.arg("-Zpre-link-args=b c")
.arg("-Zpre-link-args=d e")
.arg("-Zpre-link-arg=f")
.run_fail()
.assert_stderr_contains(r#""a" "b" "c" "d" "e" "f""#);
}

View file

@ -1,8 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all:
$(RUSTC) foo.rs
$(RUSTC) -Z ls=root $(TMPDIR)/foo
touch $(TMPDIR)/bar
$(RUSTC) -Z ls=root $(TMPDIR)/bar

View file

@ -0,0 +1,17 @@
// Passing invalid files to -Z ls (which lists the symbols
// defined by a library crate) used to cause a segmentation fault.
// As this was fixed in #11262, this test checks that no segfault
// occurs when passing the invalid file `bar` to -Z ls.
// See https://github.com/rust-lang/rust/issues/11259
//@ ignore-cross-compile
use run_make_support::fs_wrapper;
use run_make_support::rustc;
fn main() {
rustc().input("foo.rs").run();
rustc().arg("-Zls=root").input("foo").run();
fs_wrapper::create_file("bar");
rustc().arg("-Zls=root").input("bar").run();
}

View file

@ -1,13 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all:
$(RUSTC) lib.rs
# the compiler needs to copy and modify the rlib file when performing
# LTO, so we should ensure that it can cope with the original rlib
# being read-only.
chmod 444 $(TMPDIR)/*.rlib
$(RUSTC) main.rs -C lto
$(call RUN,main)

View file

@ -0,0 +1,19 @@
// When the compiler is performing link time optimization, it will
// need to copy the original rlib file, set the copy's permissions to read/write,
// and modify that copy - even if the original
// file is read-only. This test creates a read-only rlib, and checks that
// compilation with LTO succeeds.
// See https://github.com/rust-lang/rust/pull/17619
//@ ignore-cross-compile
use run_make_support::fs_wrapper;
use run_make_support::{run, rust_lib_name, rustc, test_while_readonly};
fn main() {
rustc().input("lib.rs").run();
test_while_readonly(rust_lib_name("lib"), || {
rustc().input("main.rs").arg("-Clto").run();
run("main");
});
}

View file

@ -1,11 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all:
$(RUSTC) foo.rs -C metadata=a -C extra-filename=-a
$(RUSTC) foo.rs -C metadata=b -C extra-filename=-b
$(RUSTC) bar.rs \
--extern foo1=$(TMPDIR)/libfoo-a.rlib \
--extern foo2=$(TMPDIR)/libfoo-b.rlib \
--print link-args
$(call RUN,bar)

View file

@ -0,0 +1,20 @@
// In this test, foo.rs is compiled twice with different hashes tied to its
// symbols thanks to the metadata flag. bar.rs then ensures that the memory locations
// of foo's symbols are different even though they came from the same original source code.
// This checks that the metadata flag is doing its job.
// See https://github.com/rust-lang/rust/issues/14471
//@ ignore-cross-compile
use run_make_support::{run, rust_lib_name, rustc};
fn main() {
rustc().input("foo.rs").metadata("a").extra_filename("-a").run();
rustc().input("foo.rs").metadata("b").extra_filename("-b").run();
rustc()
.input("bar.rs")
.extern_("foo1", rust_lib_name("foo-a"))
.extern_("foo2", rust_lib_name("foo-b"))
.run();
run("bar");
}

View file

@ -3,6 +3,7 @@
//@ [edition2024] compile-flags: -Zunstable-options
//@ [edition2024] edition: 2024
//@ run-pass
//@ needs-unwind
#![cfg_attr(edition2024, feature(shorter_tail_lifetimes))]
use std::sync::Mutex;

View file

@ -0,0 +1,9 @@
// issue#126516
// issue#126647
fn main() {
const {
#![path = foo!()]
//~^ ERROR: cannot find macro `foo` in this scope
}
}

View file

@ -0,0 +1,8 @@
error: cannot find macro `foo` in this scope
--> $DIR/path-attr-in-const-block.rs:6:19
|
LL | #![path = foo!()]
| ^^^
error: aborting due to 1 previous error