Skip to content

Commit 4333551

Browse files
committed
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
2 parents cb8a7ea + 7b5ed5a commit 4333551

File tree

25 files changed

+216
-97
lines changed

25 files changed

+216
-97
lines changed

compiler/rustc_resolve/src/def_collector.rs

+3
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
343343
self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span)
344344
}
345345
ExprKind::ConstBlock(ref constant) => {
346+
for attr in &expr.attrs {
347+
visit::walk_attribute(self, attr);
348+
}
346349
let def = self.create_def(
347350
constant.id,
348351
kw::Empty,

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@
209209
#![feature(cfg_sanitize)]
210210
#![feature(cfg_target_has_atomic)]
211211
#![feature(cfg_target_has_atomic_equal_alignment)]
212-
#![feature(const_closures)]
213212
#![feature(const_fn_floating_point_arithmetic)]
214213
#![feature(const_for)]
215214
#![feature(const_mut_refs)]

src/tools/run-make-support/src/rustc.rs

+18
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ impl Rustc {
7373
self
7474
}
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+
7682
/// Add a suffix in each output filename.
7783
pub fn extra_filename(&mut self, suffix: &str) -> &mut Self {
7884
self.cmd.arg(format!("-Cextra-filename={suffix}"));
@@ -230,6 +236,12 @@ impl Rustc {
230236
self
231237
}
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+
233245
/// Specify a stdin input
234246
pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
235247
self.cmd.set_stdin(input.as_ref().to_vec().into_boxed_slice());
@@ -248,4 +260,10 @@ impl Rustc {
248260
self.cmd.arg(format!("-Clinker={linker}"));
249261
self
250262
}
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+
}
251269
}

src/tools/tidy/src/allowed_run_make_makefiles.txt

-9
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ run-make/cdylib-fewer-symbols/Makefile
1313
run-make/compiler-lookup-paths-2/Makefile
1414
run-make/compiler-lookup-paths/Makefile
1515
run-make/compiler-rt-works-on-mingw/Makefile
16-
run-make/compressed-debuginfo/Makefile
1716
run-make/crate-hash-rustc-version/Makefile
1817
run-make/crate-name-priority/Makefile
1918
run-make/cross-lang-lto-clang/Makefile
2019
run-make/cross-lang-lto-pgo-smoketest/Makefile
2120
run-make/cross-lang-lto-upstream-rlibs/Makefile
2221
run-make/cross-lang-lto/Makefile
2322
run-make/debug-assertions/Makefile
24-
run-make/debugger-visualizer-dep-info/Makefile
2523
run-make/dep-info-doesnt-run-much/Makefile
2624
run-make/dep-info-spaces/Makefile
2725
run-make/dep-info/Makefile
@@ -38,7 +36,6 @@ run-make/export-executable-symbols/Makefile
3836
run-make/extern-diff-internal-name/Makefile
3937
run-make/extern-flag-disambiguates/Makefile
4038
run-make/extern-flag-pathless/Makefile
41-
run-make/extern-flag-rename-transitive/Makefile
4239
run-make/extern-fn-explicit-align/Makefile
4340
run-make/extern-fn-generic/Makefile
4441
run-make/extern-fn-mangle/Makefile
@@ -49,10 +46,8 @@ run-make/extern-fn-with-packed-struct/Makefile
4946
run-make/extern-fn-with-union/Makefile
5047
run-make/extern-multiple-copies/Makefile
5148
run-make/extern-multiple-copies2/Makefile
52-
run-make/extern-overrides-distribution/Makefile
5349
run-make/extra-filename-with-temp-outputs/Makefile
5450
run-make/fmt-write-bloat/Makefile
55-
run-make/forced-unwind-terminate-pof/Makefile
5651
run-make/foreign-double-unwind/Makefile
5752
run-make/foreign-exceptions/Makefile
5853
run-make/foreign-rust-exceptions/Makefile
@@ -96,7 +91,6 @@ run-make/libtest-json/Makefile
9691
run-make/libtest-junit/Makefile
9792
run-make/libtest-padding/Makefile
9893
run-make/libtest-thread-limit/Makefile
99-
run-make/link-args-order/Makefile
10094
run-make/link-cfg/Makefile
10195
run-make/link-framework/Makefile
10296
run-make/link-path-order/Makefile
@@ -105,19 +99,16 @@ run-make/llvm-ident/Makefile
10599
run-make/long-linker-command-lines-cmd-exe/Makefile
106100
run-make/long-linker-command-lines/Makefile
107101
run-make/longjmp-across-rust/Makefile
108-
run-make/ls-metadata/Makefile
109102
run-make/lto-dylib-dep/Makefile
110103
run-make/lto-empty/Makefile
111104
run-make/lto-linkage-used-attr/Makefile
112105
run-make/lto-no-link-whole-rlib/Makefile
113-
run-make/lto-readonly-lib/Makefile
114106
run-make/lto-smoke-c/Makefile
115107
run-make/macos-deployment-target/Makefile
116108
run-make/macos-fat-archive/Makefile
117109
run-make/manual-link/Makefile
118110
run-make/many-crates-but-no-match/Makefile
119111
run-make/metadata-dep-info/Makefile
120-
run-make/metadata-flag-frobs-symbols/Makefile
121112
run-make/min-global-align/Makefile
122113
run-make/mingw-export-call-convention/Makefile
123114
run-make/mismatching-target-triples/Makefile

tests/run-make/compressed-debuginfo/Makefile

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -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+
8+
use run_make_support::{assert_contains, cmd, run_in_tmpdir, rustc};
9+
10+
fn 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+
33+
fn main() {
34+
check_compression("zlib", "ZLIB");
35+
check_compression("zstd", "ZSTD");
36+
}

tests/run-make/debugger-visualizer-dep-info/Makefile

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -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+
5+
use run_make_support::{invalid_utf8_contains, rustc};
6+
7+
fn 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

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -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+
8+
use run_make_support::{rust_lib_name, rustc};
9+
10+
fn 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

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -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+
9+
use run_make_support::{rust_lib_name, rustc};
10+
11+
fn 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

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -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+
11+
use run_make_support::{run, rustc};
12+
13+
fn main() {
14+
rustc().input("foo.rs").run();
15+
run("foo").assert_stdout_not_contains("cannot unwind");
16+
}

tests/run-make/link-args-order/Makefile

-10
This file was deleted.
+30
Original file line numberDiff line numberDiff line change
@@ -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+
9+
use run_make_support::rustc;
10+
11+
fn 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

-8
This file was deleted.

tests/run-make/ls-metadata/rmake.rs

+17
Original file line numberDiff line numberDiff line change
@@ -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+
9+
use run_make_support::fs_wrapper;
10+
use run_make_support::rustc;
11+
12+
fn 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

-13
This file was deleted.
+19
Original file line numberDiff line numberDiff line change
@@ -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+
10+
use run_make_support::fs_wrapper;
11+
use run_make_support::{run, rust_lib_name, rustc, test_while_readonly};
12+
13+
fn 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

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -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+
9+
use run_make_support::{run, rust_lib_name, rustc};
10+
11+
fn 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+
}

0 commit comments

Comments
 (0)