about summary refs log tree commit diff
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-10-18 17:34:47 +0800
committer许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-10-22 19:43:22 +0800
commite641b6c2bda63b22e9fc6d4a4e975fd02b5f79d7 (patch)
tree50dc7a150d84b62c2c64933e9871c80e7c11e8eb
parentef743af119f9f244d47d3857c33c92ed2e217020 (diff)
downloadrust-e641b6c2bda63b22e9fc6d4a4e975fd02b5f79d7.tar.gz
rust-e641b6c2bda63b22e9fc6d4a4e975fd02b5f79d7.zip
tests/run-make: port `issue-84395-lto-embed-bitcode` to rmake.rs
Co-authored-by: Oneirical <manchot@videotron.ca>
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/issue-84395-lto-embed-bitcode/Makefile14
-rw-r--r--tests/run-make/issue-84395-lto-embed-bitcode/rmake.rs27
3 files changed, 27 insertions, 15 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 7a0f98d59f0..0e156b9d1ac 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -2,7 +2,6 @@ run-make/branch-protection-check-IBT/Makefile
 run-make/cat-and-grep-sanity-check/Makefile
 run-make/extern-fn-reachable/Makefile
 run-make/incr-add-rust-src-component/Makefile
-run-make/issue-84395-lto-embed-bitcode/Makefile
 run-make/jobserver-error/Makefile
 run-make/libs-through-symlinks/Makefile
 run-make/split-debuginfo/Makefile
diff --git a/tests/run-make/issue-84395-lto-embed-bitcode/Makefile b/tests/run-make/issue-84395-lto-embed-bitcode/Makefile
deleted file mode 100644
index aabe90754a6..00000000000
--- a/tests/run-make/issue-84395-lto-embed-bitcode/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# needs-force-clang-based-tests
-
-# FIXME(#126180): This test doesn't actually run anywhere, because the only
-# CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests.
-
-# This test makes sure the embed bitcode in elf created with
-# lto-embed-bitcode=optimized is valid llvm BC module.
-
-include ../tools.mk
-
-all:
-	$(RUSTC) test.rs --target $(TARGET) -Clink-arg=-fuse-ld=lld -Clinker-plugin-lto -Clinker=$(CLANG) -Clink-arg=-Wl,--plugin-opt=-lto-embed-bitcode=optimized -Zemit-thin-lto=no
-	$(LLVM_BIN_DIR)/objcopy --dump-section .llvmbc=$(TMPDIR)/test.bc $(TMPDIR)/test
-	$(LLVM_BIN_DIR)/llvm-dis $(TMPDIR)/test.bc
diff --git a/tests/run-make/issue-84395-lto-embed-bitcode/rmake.rs b/tests/run-make/issue-84395-lto-embed-bitcode/rmake.rs
new file mode 100644
index 00000000000..450d8a9f099
--- /dev/null
+++ b/tests/run-make/issue-84395-lto-embed-bitcode/rmake.rs
@@ -0,0 +1,27 @@
+//! Smoke test to make sure the embed bitcode in elf created with
+//! `--plugin-opt=-lto-embed-bitcode=optimized` is valid llvm BC module.
+//!
+//! See <https://github.com/rust-lang/rust/issues/84395> where passing
+//! `-lto-embed-bitcode=optimized` to lld when linking rust code via `linker-plugin-lto` doesn't
+//! produce the expected result.
+//!
+//! See PR <https://github.com/rust-lang/rust/pull/98162> which initially introduced this test.
+
+//@ needs-force-clang-based-tests
+
+use run_make_support::{env_var, llvm_dis, llvm_objcopy, rustc};
+
+fn main() {
+    rustc()
+        .input("test.rs")
+        .arg("-Clink-arg=-fuse-ld=lld")
+        .arg("-Clinker-plugin-lto")
+        .arg(format!("-Clinker={}", env_var("CLANG")))
+        .arg("-Clink-arg=-Wl,--plugin-opt=-lto-embed-bitcode=optimized")
+        .arg("-Zemit-thin-lto=no")
+        .run();
+
+    llvm_objcopy().dump_section(".llvmbc", "test.bc").arg("test").run();
+
+    llvm_dis().arg("test.bc").run();
+}