about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-06-19 11:09:05 -0400
committerOneirical <manchot@videotron.ca>2024-06-28 16:28:24 -0400
commita4f3e5f725c82b22eecf6576798f07a60b5ea7f5 (patch)
tree2318dab06a90a4cb18809bfbd9e2e489e583f3b0
parent55b581689d5e75349c1b2a4e44d0b3177a4f945b (diff)
downloadrust-a4f3e5f725c82b22eecf6576798f07a60b5ea7f5.tar.gz
rust-a4f3e5f725c82b22eecf6576798f07a60b5ea7f5.zip
rewrite and slightly rename issue-68794-textrel-on-minimal-lib
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/issue-68794-textrel-on-minimal-lib/Makefile18
-rw-r--r--tests/run-make/textrel-on-minimal-lib/bar.c (renamed from tests/run-make/issue-68794-textrel-on-minimal-lib/bar.c)0
-rw-r--r--tests/run-make/textrel-on-minimal-lib/foo.rs (renamed from tests/run-make/issue-68794-textrel-on-minimal-lib/foo.rs)0
-rw-r--r--tests/run-make/textrel-on-minimal-lib/rmake.rs30
5 files changed, 30 insertions, 19 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 21e20d1026e..dfbd3773d46 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -70,7 +70,6 @@ run-make/issue-37839/Makefile
 run-make/issue-40535/Makefile
 run-make/issue-47384/Makefile
 run-make/issue-47551/Makefile
-run-make/issue-68794-textrel-on-minimal-lib/Makefile
 run-make/issue-69368/Makefile
 run-make/issue-83045/Makefile
 run-make/issue-83112-incr-test-moved-file/Makefile
diff --git a/tests/run-make/issue-68794-textrel-on-minimal-lib/Makefile b/tests/run-make/issue-68794-textrel-on-minimal-lib/Makefile
deleted file mode 100644
index 6140b39c0e2..00000000000
--- a/tests/run-make/issue-68794-textrel-on-minimal-lib/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# ignore-cross-compile
-# Regression test for issue #68794
-#
-# Verify that no text relocations are accidentally introduced by linking a
-# minimal rust staticlib.
-#
-# The test links a rust static library into a shared library, and checks that
-# the linker doesn't have to flag the resulting file as containing TEXTRELs.
-
-include ../tools.mk
-
-# only-linux
-
-all:
-	$(RUSTC) foo.rs
-	$(CC) bar.c $(call STATICLIB,foo) -fPIC -shared -o $(call DYLIB,bar) \
-		$(EXTRACFLAGS) $(EXTRACXXFLAGS)
-	readelf -d $(call DYLIB,bar) | grep TEXTREL; test $$? -eq 1
diff --git a/tests/run-make/issue-68794-textrel-on-minimal-lib/bar.c b/tests/run-make/textrel-on-minimal-lib/bar.c
index bb4036b06e1..bb4036b06e1 100644
--- a/tests/run-make/issue-68794-textrel-on-minimal-lib/bar.c
+++ b/tests/run-make/textrel-on-minimal-lib/bar.c
diff --git a/tests/run-make/issue-68794-textrel-on-minimal-lib/foo.rs b/tests/run-make/textrel-on-minimal-lib/foo.rs
index a3e865b638e..a3e865b638e 100644
--- a/tests/run-make/issue-68794-textrel-on-minimal-lib/foo.rs
+++ b/tests/run-make/textrel-on-minimal-lib/foo.rs
diff --git a/tests/run-make/textrel-on-minimal-lib/rmake.rs b/tests/run-make/textrel-on-minimal-lib/rmake.rs
new file mode 100644
index 00000000000..4c272955915
--- /dev/null
+++ b/tests/run-make/textrel-on-minimal-lib/rmake.rs
@@ -0,0 +1,30 @@
+// Verify that no text relocations are accidentally introduced by linking a
+// minimal rust staticlib.
+// The test links a rust static library into a shared library, and checks that
+// the linker doesn't have to flag the resulting file as containing TEXTRELs.
+// This bug otherwise breaks Android builds, which forbid TEXTRELs.
+// See https://github.com/rust-lang/rust/issues/68794
+
+//@ ignore-cross-compile
+//FIXME(Oneirical): check that it works on more than just only-linux
+
+use run_make_support::{
+    cc, dynamic_lib_name, extra_c_flags, extra_cxx_flags, llvm_readobj, rustc, static_lib_name,
+};
+
+fn main() {
+    rustc().input("foo.rs").run();
+    cc().input("bar.c")
+        .input(static_lib_name("foo"))
+        .out_exe(&dynamic_lib_name("bar"))
+        .arg("-fPIC")
+        .arg("-shared")
+        .args(&extra_c_flags())
+        .args(&extra_cxx_flags())
+        .run();
+    llvm_readobj()
+        .input(dynamic_lib_name("bar"))
+        .arg("--dynamic")
+        .run()
+        .assert_stdout_not_contains("TEXTREL");
+}