about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-07-05 15:26:29 -0400
committerOneirical <manchot@videotron.ca>2024-07-12 10:58:20 -0400
commitfe76650144a6da47583d50e6df8021bcf94e37d1 (patch)
tree0819eb6912d32828b526a5494ccbe2b8574d21b4
parent87c7a42ba92d341c6d4a330a5d4c02b839158c1e (diff)
rewrite env-dep-info to rmake
-rw-r--r--src/tools/run-make-support/src/rustc.rs9
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt2
-rw-r--r--tests/run-make/env-dep-info/Makefile19
-rw-r--r--tests/run-make/env-dep-info/correct_macro.d6
-rw-r--r--tests/run-make/env-dep-info/correct_main.d8
-rw-r--r--tests/run-make/env-dep-info/rmake.rs21
-rw-r--r--tests/run-make/ice-dep-cannot-find-dep/rmake.rs1
-rw-r--r--tests/run-make/rustc-macro-dep-files/correct.d3
-rw-r--r--tests/run-make/rustc-macro-dep-files/rmake.rs5
9 files changed, 47 insertions, 27 deletions
diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs
index a2a7c8064dc..ae200d51431 100644
--- a/src/tools/run-make-support/src/rustc.rs
+++ b/src/tools/run-make-support/src/rustc.rs
@@ -4,13 +4,15 @@ use std::path::Path;
 
 use crate::{command, cwd, env_var, set_host_rpath};
 
-/// Construct a new `rustc` invocation.
+/// Construct a new `rustc` invocation. This will automatically set the library
+/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
 #[track_caller]
 pub fn rustc() -> Rustc {
     Rustc::new()
 }
 
-/// Construct a plain `rustc` invocation with no flags set.
+/// Construct a plain `rustc` invocation with no flags set. Note that [`set_host_rpath`]
+/// still presets the environment variable `HOST_RPATH_DIR` by default.
 #[track_caller]
 pub fn bare_rustc() -> Rustc {
     Rustc::bare()
@@ -42,7 +44,8 @@ fn setup_common() -> Command {
 impl Rustc {
     // `rustc` invocation constructor methods
 
-    /// Construct a new `rustc` invocation.
+    /// Construct a new `rustc` invocation. This will automatically set the library
+    /// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
     #[track_caller]
     pub fn new() -> Self {
         let mut cmd = setup_common();
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 22edea79adf..b8e203fe0ea 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -23,7 +23,6 @@ run-make/dep-info/Makefile
 run-make/dump-ice-to-disk/Makefile
 run-make/dump-mono-stats/Makefile
 run-make/emit-to-stdout/Makefile
-run-make/env-dep-info/Makefile
 run-make/export-executable-symbols/Makefile
 run-make/extern-diff-internal-name/Makefile
 run-make/extern-flag-disambiguates/Makefile
@@ -58,7 +57,6 @@ run-make/issue-35164/Makefile
 run-make/issue-36710/Makefile
 run-make/issue-47551/Makefile
 run-make/issue-69368/Makefile
-run-make/issue-83045/Makefile
 run-make/issue-84395-lto-embed-bitcode/Makefile
 run-make/issue-85019-moved-src-dir/Makefile
 run-make/issue-85401-static-mir/Makefile
diff --git a/tests/run-make/env-dep-info/Makefile b/tests/run-make/env-dep-info/Makefile
deleted file mode 100644
index bc0ffc2df1e..00000000000
--- a/tests/run-make/env-dep-info/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-include ../tools.mk
-
-# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`
-# instead of hardcoding them everywhere they're needed.
-ifeq ($(IS_MUSL_HOST),1)
-ADDITIONAL_ARGS := $(RUSTFLAGS)
-endif
-
-all:
-	EXISTING_ENV=1 EXISTING_OPT_ENV=1 $(RUSTC) --emit dep-info main.rs
-	$(CGREP) "# env-dep:EXISTING_ENV=1" < $(TMPDIR)/main.d
-	$(CGREP) "# env-dep:EXISTING_OPT_ENV=1" < $(TMPDIR)/main.d
-	$(CGREP) "# env-dep:NONEXISTENT_OPT_ENV" < $(TMPDIR)/main.d
-	$(CGREP) "# env-dep:ESCAPE\nESCAPE\\" < $(TMPDIR)/main.d
-	# Proc macro
-	$(BARE_RUSTC) $(ADDITIONAL_ARGS) --out-dir $(TMPDIR) macro_def.rs
-	EXISTING_PROC_MACRO_ENV=1 $(RUSTC) --emit dep-info macro_use.rs
-	$(CGREP) "# env-dep:EXISTING_PROC_MACRO_ENV=1" < $(TMPDIR)/macro_use.d
-	$(CGREP) "# env-dep:NONEXISTENT_PROC_MACEO_ENV" < $(TMPDIR)/macro_use.d
diff --git a/tests/run-make/env-dep-info/correct_macro.d b/tests/run-make/env-dep-info/correct_macro.d
new file mode 100644
index 00000000000..edfe0e63202
--- /dev/null
+++ b/tests/run-make/env-dep-info/correct_macro.d
@@ -0,0 +1,6 @@
+macro_use.d: macro_use.rs
+
+macro_use.rs:
+
+# env-dep:EXISTING_PROC_MACRO_ENV=1
+# env-dep:NONEXISTENT_PROC_MACEO_ENV
diff --git a/tests/run-make/env-dep-info/correct_main.d b/tests/run-make/env-dep-info/correct_main.d
new file mode 100644
index 00000000000..ef89729841d
--- /dev/null
+++ b/tests/run-make/env-dep-info/correct_main.d
@@ -0,0 +1,8 @@
+main.d: main.rs
+
+main.rs:
+
+# env-dep:ESCAPE\nESCAPE\\
+# env-dep:EXISTING_ENV=1
+# env-dep:EXISTING_OPT_ENV=1
+# env-dep:NONEXISTENT_OPT_ENV
diff --git a/tests/run-make/env-dep-info/rmake.rs b/tests/run-make/env-dep-info/rmake.rs
new file mode 100644
index 00000000000..5b51a5476f4
--- /dev/null
+++ b/tests/run-make/env-dep-info/rmake.rs
@@ -0,0 +1,21 @@
+// Inside dep-info emit files, #71858 made it so all accessed environment
+// variables are usefully printed. This test checks that this feature works
+// as intended by checking if the environment variables used in compilation
+// appear in the output dep-info files.
+// See https://github.com/rust-lang/rust/issues/40364
+
+use run_make_support::{diff, rustc};
+
+fn main() {
+    rustc()
+        .env("EXISTING_ENV", "1")
+        .env("EXISTING_OPT_ENV", "1")
+        .emit("dep-info")
+        .input("main.rs")
+        .run();
+    diff().expected_file("correct_main.d").actual_file("main.d").run();
+    // Procedural macro
+    rustc().input("macro_def.rs").run();
+    rustc().env("EXISTING_PROC_MACRO_ENV", "1").emit("dep-info").input("macro_use.rs").run();
+    diff().expected_file("correct_macro.d").actual_file("macro_use.d").run();
+}
diff --git a/tests/run-make/ice-dep-cannot-find-dep/rmake.rs b/tests/run-make/ice-dep-cannot-find-dep/rmake.rs
index 4256831a1ee..33c755bddd7 100644
--- a/tests/run-make/ice-dep-cannot-find-dep/rmake.rs
+++ b/tests/run-make/ice-dep-cannot-find-dep/rmake.rs
@@ -27,7 +27,6 @@ fn main() {
         .input("b.rs")
         .arg("--verbose")
         .run();
-    fs_wrapper::create_dir("wrong_directory");
     bare_rustc()
         .extern_("b", rust_lib_name("b"))
         .crate_type("rlib")
diff --git a/tests/run-make/rustc-macro-dep-files/correct.d b/tests/run-make/rustc-macro-dep-files/correct.d
new file mode 100644
index 00000000000..8cb708fff61
--- /dev/null
+++ b/tests/run-make/rustc-macro-dep-files/correct.d
@@ -0,0 +1,3 @@
+bar.d: bar.rs
+
+bar.rs:
diff --git a/tests/run-make/rustc-macro-dep-files/rmake.rs b/tests/run-make/rustc-macro-dep-files/rmake.rs
index b90e719b7d6..bc02a04c9b8 100644
--- a/tests/run-make/rustc-macro-dep-files/rmake.rs
+++ b/tests/run-make/rustc-macro-dep-files/rmake.rs
@@ -4,10 +4,11 @@
 // that macro code is not falsely seen as coming from a different file in dep-info.
 // See https://github.com/rust-lang/rust/issues/36625
 
-use run_make_support::{fs_wrapper, rustc, target};
+use run_make_support::{diff, rustc, target};
 
 fn main() {
     rustc().input("foo.rs").run();
     rustc().input("bar.rs").target(target()).emit("dep-info").run();
-    assert!(!fs_wrapper::read_to_string("bar.d").contains("proc-macro source"));
+    // The emitted file should not contain "proc-macro source".
+    diff().expected_file("correct.d").actual_file("bar.d").run();
 }