about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-05-22 15:25:43 -0400
committerOneirical <manchot@videotron.ca>2024-05-22 15:25:43 -0400
commitd4e5426256db81e8a5fc7b737f373a162b632a45 (patch)
tree8e646ac57fb228d52bd3396216809e26d229bbac
parentc24d1c7ff8fd6374a8bf8b1172e04ae828da438d (diff)
downloadrust-d4e5426256db81e8a5fc7b737f373a162b632a45.tar.gz
rust-d4e5426256db81e8a5fc7b737f373a162b632a45.zip
rewrite and rename `issue-24445` to rmake
-rw-r--r--src/tools/run-make-support/src/cc.rs8
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/issue-24445/Makefile11
-rw-r--r--tests/run-make/non-pie-thread-local/foo.c (renamed from tests/run-make/issue-24445/foo.c)0
-rw-r--r--tests/run-make/non-pie-thread-local/foo.rs (renamed from tests/run-make/issue-24445/foo.rs)0
-rw-r--r--tests/run-make/non-pie-thread-local/rmake.rs36
6 files changed, 44 insertions, 12 deletions
diff --git a/src/tools/run-make-support/src/cc.rs b/src/tools/run-make-support/src/cc.rs
index a67f5c8a9ee..799c36b1049 100644
--- a/src/tools/run-make-support/src/cc.rs
+++ b/src/tools/run-make-support/src/cc.rs
@@ -45,6 +45,14 @@ impl Cc {
         self
     }
 
+    /// Adds directories to the list that the linker searches for libraries.
+    /// Equivalent to `-L`.
+    pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
+        self.cmd.arg("-L");
+        self.cmd.arg(path.as_ref());
+        self
+    }
+
     /// Specify `-o` or `-Fe`/`-Fo` depending on platform/compiler. This assumes that the executable
     /// is under `$TMPDIR`.
     pub fn out_exe(&mut self, name: &str) -> &mut Self {
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 2d62a064fae..b4b40bdd7fb 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -97,7 +97,6 @@ run-make/issue-15460/Makefile
 run-make/issue-18943/Makefile
 run-make/issue-20626/Makefile
 run-make/issue-22131/Makefile
-run-make/issue-24445/Makefile
 run-make/issue-25581/Makefile
 run-make/issue-26006/Makefile
 run-make/issue-26092/Makefile
diff --git a/tests/run-make/issue-24445/Makefile b/tests/run-make/issue-24445/Makefile
deleted file mode 100644
index a13910aa73e..00000000000
--- a/tests/run-make/issue-24445/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-
-# only-linux
-
-all:
-	$(RUSTC) foo.rs
-	$(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -o $(TMPDIR)/foo
-	$(call RUN,foo)
-	$(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -pie -fPIC -o $(TMPDIR)/foo
-	$(call RUN,foo)
diff --git a/tests/run-make/issue-24445/foo.c b/tests/run-make/non-pie-thread-local/foo.c
index bb4036b06e1..bb4036b06e1 100644
--- a/tests/run-make/issue-24445/foo.c
+++ b/tests/run-make/non-pie-thread-local/foo.c
diff --git a/tests/run-make/issue-24445/foo.rs b/tests/run-make/non-pie-thread-local/foo.rs
index b67f3847cd4..b67f3847cd4 100644
--- a/tests/run-make/issue-24445/foo.rs
+++ b/tests/run-make/non-pie-thread-local/foo.rs
diff --git a/tests/run-make/non-pie-thread-local/rmake.rs b/tests/run-make/non-pie-thread-local/rmake.rs
new file mode 100644
index 00000000000..fb89e4199c7
--- /dev/null
+++ b/tests/run-make/non-pie-thread-local/rmake.rs
@@ -0,0 +1,36 @@
+// It was once required to use a position-independent executable (PIE)
+// in order to use the thread_local! macro, or some symbols would contain
+// a NULL address. This was fixed, and this test checks a non-PIE, then a PIE
+// build to see if this bug makes a resurgence.
+// See https://github.com/rust-lang/rust/pull/24448
+
+//@ ignore-cross compile
+//@ only-linux
+
+use run_make_support::{cc, run, rustc, tmp_dir};
+
+fn main() {
+    rustc().input("foo.rs").run();
+    cc().input("foo.c")
+        .arg("-lfoo")
+        .library_search_path(tmp_dir())
+        .arg("-Wl")
+        .arg("--gc-sections")
+        .arg("-lpthread")
+        .arg("-ldl")
+        .out_exe(tmp_dir().join("foo"))
+        .run();
+    run("foo");
+    cc().input("foo.c")
+        .arg("-lfoo")
+        .library_search_path(tmp_dir())
+        .arg("-Wl")
+        .arg("--gc-sections")
+        .arg("-lpthread")
+        .arg("-ldl")
+        .arg("-pie")
+        .arg("-fPIC")
+        .out_exe(tmp_dir().join("foo"))
+        .run();
+    run("foo");
+}