about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-07-22 14:21:58 -0400
committerOneirical <manchot@videotron.ca>2024-07-26 12:06:37 -0400
commit4f7f60b927e4c7f951664e75e7ed385aee080d83 (patch)
tree98ea61ceba0113512e3ab54abcb9d0b123de3353 /tests
parent2d5a628a1de1d38318909a710ef37da6251e362e (diff)
downloadrust-4f7f60b927e4c7f951664e75e7ed385aee080d83.tar.gz
rust-4f7f60b927e4c7f951664e75e7ed385aee080d83.zip
rewrite rlib-format-packed-bundled-libs-2 to rmake
Diffstat (limited to 'tests')
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-2/Makefile27
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs32
2 files changed, 32 insertions, 27 deletions
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile b/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile
deleted file mode 100644
index d2a740b06b3..00000000000
--- a/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-include ../tools.mk
-
-# ignore-cross-compile
-
-# Make sure -Zpacked_bundled_libs is compatible with verbatim.
-
-# We're using the llvm-nm instead of the system nm to ensure it is compatible
-# with the LLVM bitcode generated by rustc.
-# Except on Windows where piping/IO redirection under MSYS2 is wonky with llvm-nm.
-ifndef IS_WINDOWS
-NM = "$(LLVM_BIN_DIR)"/llvm-nm
-else
-NM = nm
-endif
-
-all:
-	# Build strange-named dep.
-	$(RUSTC) native_dep.rs --crate-type=staticlib -o $(TMPDIR)/native_dep.ext
-
-	$(RUSTC) rust_dep.rs --crate-type=rlib -Zpacked_bundled_libs
-	$(NM) $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "U.*native_f1"
-	$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) "native_dep.ext"
-
-	# Make sure compiler doesn't use files, that it shouldn't know about.
-	rm $(TMPDIR)/native_dep.ext
-
-	$(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep.rlib -Zpacked_bundled_libs
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs b/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs
new file mode 100644
index 00000000000..8d7afd3245e
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs
@@ -0,0 +1,32 @@
+// `-Z packed_bundled_libs` is an unstable rustc flag that makes the compiler
+// only require a native library and no supplementary object files to compile.
+// This test simply checks that this flag can be passed alongside verbatim syntax
+// in rustc flags without a compilation failure or the removal of expected symbols.
+// See https://github.com/rust-lang/rust/pull/100101
+
+//FIXME(Oneirical): try it on test-various
+
+use run_make_support::{llvm_ar, llvm_readobj, regex, rfs, rust_lib_name, rustc};
+
+fn main() {
+    // Build a strangely named dependency.
+    rustc().input("native_dep.rs").crate_type("staticlib").output("native_dep.ext").run();
+
+    rustc().input("rust_dep.rs").crate_type("rlib").arg("-Zpacked_bundled_libs").run();
+    let symbols = llvm_readobj().symbols().input(rust_lib_name("rust_dep")).run().stdout_utf8();
+    let re = regex::Regex::new("U.*native_f1").unwrap();
+    assert!(re.is_match(&symbols));
+    llvm_ar()
+        .arg("t")
+        .arg(rust_lib_name("rust_dep"))
+        .run()
+        .assert_stdout_contains("native_dep.ext");
+
+    // Ensure the compiler does not use files it should not be aware of.
+    rfs::remove_file("native_dep.ext");
+    rustc()
+        .input("main.rs")
+        .extern_("rust_dep", rust_lib_name("rust_dep"))
+        .arg("-Zpacked_bundled_libs")
+        .run();
+}