rewrite rlib-format-packed-bundled-libs-2 to rmake

This commit is contained in:
Oneirical 2024-07-22 14:21:58 -04:00
parent 2d5a628a1d
commit 4f7f60b927
3 changed files with 32 additions and 28 deletions

View file

@ -51,7 +51,6 @@ run-make/redundant-libs/Makefile
run-make/remap-path-prefix-dwarf/Makefile
run-make/reproducible-build-2/Makefile
run-make/reproducible-build/Makefile
run-make/rlib-format-packed-bundled-libs-2/Makefile
run-make/rlib-format-packed-bundled-libs/Makefile
run-make/sanitizer-cdylib-link/Makefile
run-make/sanitizer-dylib-link/Makefile

View file

@ -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

View file

@ -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();
}