about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/tools/run-make-support/src/rustc.rs9
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt3
-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/a.rs (renamed from tests/run-make/issue-83045/a.rs)0
-rw-r--r--tests/run-make/ice-dep-cannot-find-dep/b.rs (renamed from tests/run-make/issue-83045/b.rs)0
-rw-r--r--tests/run-make/ice-dep-cannot-find-dep/c.rs (renamed from tests/run-make/issue-83045/c.rs)0
-rw-r--r--tests/run-make/ice-dep-cannot-find-dep/rmake.rs38
-rw-r--r--tests/run-make/issue-83045/Makefile33
-rw-r--r--tests/run-make/rustc-macro-dep-files/Makefile11
-rw-r--r--tests/run-make/rustc-macro-dep-files/correct.d3
-rw-r--r--tests/run-make/rustc-macro-dep-files/rmake.rs14
14 files changed, 96 insertions, 69 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 07d047a4815..f7ec7d0b3f6 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
@@ -57,7 +56,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-85401-static-mir/Makefile
 run-make/issue-88756-default-output/Makefile
@@ -114,7 +112,6 @@ run-make/return-non-c-like-enum-from-c/Makefile
 run-make/rlib-format-packed-bundled-libs-2/Makefile
 run-make/rlib-format-packed-bundled-libs-3/Makefile
 run-make/rlib-format-packed-bundled-libs/Makefile
-run-make/rustc-macro-dep-files/Makefile
 run-make/sanitizer-cdylib-link/Makefile
 run-make/sanitizer-dylib-link/Makefile
 run-make/sanitizer-staticlib-link/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/issue-83045/a.rs b/tests/run-make/ice-dep-cannot-find-dep/a.rs
index 66d9f758e9d..66d9f758e9d 100644
--- a/tests/run-make/issue-83045/a.rs
+++ b/tests/run-make/ice-dep-cannot-find-dep/a.rs
diff --git a/tests/run-make/issue-83045/b.rs b/tests/run-make/ice-dep-cannot-find-dep/b.rs
index f4876cfa457..f4876cfa457 100644
--- a/tests/run-make/issue-83045/b.rs
+++ b/tests/run-make/ice-dep-cannot-find-dep/b.rs
diff --git a/tests/run-make/issue-83045/c.rs b/tests/run-make/ice-dep-cannot-find-dep/c.rs
index e0c4525499e..e0c4525499e 100644
--- a/tests/run-make/issue-83045/c.rs
+++ b/tests/run-make/ice-dep-cannot-find-dep/c.rs
diff --git a/tests/run-make/ice-dep-cannot-find-dep/rmake.rs b/tests/run-make/ice-dep-cannot-find-dep/rmake.rs
new file mode 100644
index 00000000000..33c755bddd7
--- /dev/null
+++ b/tests/run-make/ice-dep-cannot-find-dep/rmake.rs
@@ -0,0 +1,38 @@
+// This test case creates a situation where the crate loader would run
+// into an ICE (internal compiler error) when confronted with an invalid setup where it cannot
+// find the dependency of a direct dependency.
+//
+// The test case makes sure that the compiler produces the expected
+// error message but does not ICE immediately after.
+//
+// See https://github.com/rust-lang/rust/issues/83045
+
+//@ only-x86_64
+//@ only-linux
+// Reason: This is a platform-independent issue, no need to waste time testing
+// everywhere.
+
+// NOTE: We use `bare_rustc` below so that the compiler can't find liba.rlib
+//       If we used `rustc` the additional '-L rmake_out' option would allow rustc to
+//       actually find the crate.
+
+use run_make_support::{bare_rustc, fs_wrapper, rust_lib_name, rustc};
+
+fn main() {
+    rustc().crate_name("a").crate_type("rlib").input("a.rs").arg("--verbose").run();
+    rustc()
+        .crate_name("b")
+        .crate_type("rlib")
+        .extern_("a", rust_lib_name("a"))
+        .input("b.rs")
+        .arg("--verbose")
+        .run();
+    bare_rustc()
+        .extern_("b", rust_lib_name("b"))
+        .crate_type("rlib")
+        .edition("2018")
+        .input("c.rs")
+        .run_fail()
+        .assert_stderr_contains("E0463")
+        .assert_stderr_not_contains("internal compiler error");
+}
diff --git a/tests/run-make/issue-83045/Makefile b/tests/run-make/issue-83045/Makefile
deleted file mode 100644
index b76e184b610..00000000000
--- a/tests/run-make/issue-83045/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-include ../tools.mk
-
-# This test case creates a situation where the crate loader would run
-# into an ICE when confronted with an invalid setup where it cannot
-# find the dependency of a direct dependency.
-#
-# The test case makes sure that the compiler produces the expected
-# error message but does not ICE immediately after.
-#
-# See https://github.com/rust-lang/rust/issues/83045
-
-# This is a platform-independent issue, no need to waste time testing
-# everywhere.
-# only-x86_64
-# only-linux
-
-# NOTE: We use BARE_RUSTC below so that the compiler can't find liba.rlib
-#       If we used RUSTC the additional '-L TMPDIR' option would allow rustc to
-#       actually find the crate.
-#
-#       We check that we get the expected error message
-#       But that we do not get an ICE
-
-all:
-	$(RUSTC) --crate-name=a --crate-type=rlib a.rs --verbose
-	$(RUSTC) --crate-name=b --crate-type=rlib --extern a=$(TMPDIR)/liba.rlib b.rs --verbose
-	$(BARE_RUSTC) --out-dir $(TMPDIR) \
-	              --extern b=$(TMPDIR)/libb.rlib \
-				  --crate-type=rlib \
-				  --edition=2018 \
-				  c.rs 2>&1 | tee $(TMPDIR)/output.txt || exit 0
-	$(CGREP) E0463 < $(TMPDIR)/output.txt
-	$(CGREP) -v "internal compiler error" < $(TMPDIR)/output.txt
diff --git a/tests/run-make/rustc-macro-dep-files/Makefile b/tests/run-make/rustc-macro-dep-files/Makefile
deleted file mode 100644
index 76d713c4bb3..00000000000
--- a/tests/run-make/rustc-macro-dep-files/Makefile
+++ /dev/null
@@ -1,11 +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:
-	$(BARE_RUSTC) $(ADDITIONAL_ARGS) foo.rs --out-dir $(TMPDIR)
-	$(RUSTC) bar.rs --target $(TARGET) --emit dep-info
-	$(CGREP) -v "proc-macro source" < $(TMPDIR)/bar.d
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
new file mode 100644
index 00000000000..bc02a04c9b8
--- /dev/null
+++ b/tests/run-make/rustc-macro-dep-files/rmake.rs
@@ -0,0 +1,14 @@
+// --emit dep-info used to print all macro-generated code it could
+// find as if it was part of a nonexistent file named "proc-macro source",
+// which is not a valid path. After this was fixed in #36776, this test checks
+// 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::{diff, rustc, target};
+
+fn main() {
+    rustc().input("foo.rs").run();
+    rustc().input("bar.rs").target(target()).emit("dep-info").run();
+    // The emitted file should not contain "proc-macro source".
+    diff().expected_file("correct.d").actual_file("bar.d").run();
+}