Skip to content

Commit 90002cd

Browse files
committed
Auto merge of rust-lang#127381 - Oneirical:testalt-consciousness, r=<try>
Migrate `issue-83045`, `rustc-macro-dep-files` and `env-dep-info` `run-make` tests to rmake Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try on musl. try-job: dist-x86_64-musl
2 parents 51917e2 + 13115ce commit 90002cd

File tree

12 files changed

+96
-69
lines changed

12 files changed

+96
-69
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub use llvm::{
3535
LlvmProfdata, LlvmReadobj,
3636
};
3737
pub use run::{cmd, run, run_fail, run_with_args};
38-
pub use rustc::{aux_build, rustc, Rustc};
38+
pub use rustc::{aux_build, bare_rustc, rustc, Rustc};
3939
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
4040

4141
#[track_caller]

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ pub fn rustc() -> Rustc {
1010
Rustc::new()
1111
}
1212

13-
/// Construct a new `rustc` aux-build invocation.
13+
/// Construct a plain `rustc` invocation with no flags set.
14+
#[track_caller]
15+
pub fn bare_rustc() -> Rustc {
16+
Rustc::bare()
17+
}
18+
19+
// Construct a new `rustc` aux-build invocation.
1420
#[track_caller]
1521
pub fn aux_build() -> Rustc {
1622
Rustc::new_aux_build()
@@ -30,7 +36,6 @@ fn setup_common() -> Command {
3036
let rustc = env_var("RUSTC");
3137
let mut cmd = Command::new(rustc);
3238
set_host_rpath(&mut cmd);
33-
cmd.arg("-L").arg(cwd());
3439
cmd
3540
}
3641

@@ -40,6 +45,14 @@ impl Rustc {
4045
/// Construct a new `rustc` invocation.
4146
#[track_caller]
4247
pub fn new() -> Self {
48+
let mut cmd = setup_common();
49+
cmd.arg("-L").arg(cwd());
50+
Self { cmd }
51+
}
52+
53+
/// Construct a bare `rustc` invocation with no flags set.
54+
#[track_caller]
55+
pub fn bare() -> Self {
4356
let cmd = setup_common();
4457
Self { cmd }
4558
}

src/tools/tidy/src/allowed_run_make_makefiles.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ run-make/dump-mono-stats/Makefile
2626
run-make/emit-path-unhashed/Makefile
2727
run-make/emit-shared-files/Makefile
2828
run-make/emit-to-stdout/Makefile
29-
run-make/env-dep-info/Makefile
3029
run-make/export-executable-symbols/Makefile
3130
run-make/extern-diff-internal-name/Makefile
3231
run-make/extern-flag-disambiguates/Makefile
@@ -65,7 +64,6 @@ run-make/issue-36710/Makefile
6564
run-make/issue-37839/Makefile
6665
run-make/issue-47551/Makefile
6766
run-make/issue-69368/Makefile
68-
run-make/issue-83045/Makefile
6967
run-make/issue-83112-incr-test-moved-file/Makefile
7068
run-make/issue-84395-lto-embed-bitcode/Makefile
7169
run-make/issue-85019-moved-src-dir/Makefile
@@ -129,7 +127,6 @@ run-make/return-non-c-like-enum-from-c/Makefile
129127
run-make/rlib-format-packed-bundled-libs-2/Makefile
130128
run-make/rlib-format-packed-bundled-libs-3/Makefile
131129
run-make/rlib-format-packed-bundled-libs/Makefile
132-
run-make/rustc-macro-dep-files/Makefile
133130
run-make/sanitizer-cdylib-link/Makefile
134131
run-make/sanitizer-dylib-link/Makefile
135132
run-make/sanitizer-staticlib-link/Makefile

tests/run-make/env-dep-info/Makefile

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/run-make/env-dep-info/rmake.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Inside dep-info emit files, #71858 made it so all accessed environment
2+
// variables are usefully printed. This test checks that this feature works
3+
// as intended by checking if the environment variables used in compilation
4+
// appear in the output dep-info files.
5+
// See https://github.com/rust-lang/rust/issues/40364
6+
7+
use run_make_support::{fs_wrapper, rustc};
8+
9+
// FIXME(Oneirical): try on musl
10+
11+
fn main() {
12+
rustc()
13+
.env("EXISTING_ENV", "1")
14+
.env("EXISTING_OPT_ENV", "1")
15+
.emit("dep-info")
16+
.input("main.rs")
17+
.run();
18+
let dep_info = fs_wrapper::read_to_string("main.d");
19+
assert!(&dep_info.contains("# env-dep:EXISTING_ENV=1"));
20+
assert!(&dep_info.contains("# env-dep:EXISTING_OPT_ENV=1"));
21+
assert!(&dep_info.contains("# env-dep:NONEXISTENT_OPT_ENV"));
22+
assert!(dep_info.contains(r#"# env-dep:ESCAPE\nESCAPE\\"#));
23+
// Procedural macro
24+
rustc().input("macro_def.rs").run();
25+
rustc().env("EXISTING_PROC_MACRO_ENV", "1").emit("dep-info").input("macro_use.rs").run();
26+
let dep_info = fs_wrapper::read_to_string("macro_use.d");
27+
assert!(&dep_info.contains("# env-dep:EXISTING_PROC_MACRO_ENV=1"));
28+
assert!(dep_info.contains("# env-dep:NONEXISTENT_PROC_MACEO_ENV"));
29+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// This test case creates a situation where the crate loader would run
2+
// into an ICE (internal compiler error) when confronted with an invalid setup where it cannot
3+
// find the dependency of a direct dependency.
4+
//
5+
// The test case makes sure that the compiler produces the expected
6+
// error message but does not ICE immediately after.
7+
//
8+
// See https://github.com/rust-lang/rust/issues/83045
9+
10+
//@ only-x86_64
11+
//@ only-linux
12+
// Reason: This is a platform-independent issue, no need to waste time testing
13+
// everywhere.
14+
15+
// NOTE: We use `bare_rustc` below so that the compiler can't find liba.rlib
16+
// If we used `rustc` the additional '-L rmake_out' option would allow rustc to
17+
// actually find the crate.
18+
19+
use run_make_support::{bare_rustc, fs_wrapper, rust_lib_name, rustc};
20+
21+
fn main() {
22+
rustc().crate_name("a").crate_type("rlib").input("a.rs").arg("--verbose").run();
23+
rustc()
24+
.crate_name("b")
25+
.crate_type("rlib")
26+
.extern_("a", rust_lib_name("a"))
27+
.input("b.rs")
28+
.arg("--verbose")
29+
.run();
30+
bare_rustc()
31+
.extern_("b", rust_lib_name("b"))
32+
.crate_type("rlib")
33+
.edition("2018")
34+
.input("c.rs")
35+
.run_fail()
36+
.assert_stderr_contains("E0463")
37+
.assert_stderr_not_contains("internal compiler error");
38+
}

tests/run-make/issue-83045/Makefile

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/run-make/rustc-macro-dep-files/Makefile

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// --emit dep-info used to print all macro-generated code it could
2+
// find as if it was part of a nonexistent file named "proc-macro source",
3+
// which is not a valid path. After this was fixed in #36776, this test checks
4+
// that macro code is not falsely seen as coming from a different file in dep-info.
5+
// See https://github.com/rust-lang/rust/issues/36625
6+
7+
use run_make_support::{fs_wrapper, rustc, target};
8+
9+
fn main() {
10+
rustc().input("foo.rs").run();
11+
rustc().input("bar.rs").target(target()).emit("dep-info").run();
12+
assert!(!fs_wrapper::read_to_string("bar.d").contains("proc-macro source"));
13+
}

0 commit comments

Comments
 (0)