From 4f7f60b927e4c7f951664e75e7ed385aee080d83 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 22 Jul 2024 14:21:58 -0400 Subject: [PATCH 1/4] rewrite rlib-format-packed-bundled-libs-2 to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../Makefile | 27 ---------------- .../rmake.rs | 32 +++++++++++++++++++ 3 files changed, 32 insertions(+), 28 deletions(-) delete mode 100644 tests/run-make/rlib-format-packed-bundled-libs-2/Makefile create mode 100644 tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index fa340a02213..86add3a75b1 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -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 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(); +} From c8f049cd802fd7e5a111218d65822a80bb796ac4 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 22 Jul 2024 15:08:26 -0400 Subject: [PATCH 2/4] rewrite native-link-modifier-whole-archive to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../Makefile | 52 ------------ .../rmake.rs | 85 +++++++++++++++++++ 3 files changed, 85 insertions(+), 53 deletions(-) delete mode 100644 tests/run-make/native-link-modifier-whole-archive/Makefile create mode 100644 tests/run-make/native-link-modifier-whole-archive/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 86add3a75b1..3ee3bf65cfa 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -34,7 +34,6 @@ run-make/long-linker-command-lines/Makefile run-make/macos-deployment-target/Makefile run-make/min-global-align/Makefile run-make/native-link-modifier-bundle/Makefile -run-make/native-link-modifier-whole-archive/Makefile run-make/no-alloc-shim/Makefile run-make/no-builtins-attribute/Makefile run-make/pdb-buildinfo-cl-cmd/Makefile diff --git a/tests/run-make/native-link-modifier-whole-archive/Makefile b/tests/run-make/native-link-modifier-whole-archive/Makefile deleted file mode 100644 index 5eb7a416f91..00000000000 --- a/tests/run-make/native-link-modifier-whole-archive/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# ignore-cross-compile -- compiling C++ code does not work well when cross-compiling - -# This test case makes sure that native libraries are linked with appropriate semantics -# when the `[+-]bundle,[+-]whole-archive` modifiers are applied to them. -# -# The test works by checking that the resulting executables produce the expected output, -# part of which is emitted by otherwise unreferenced C code. If +whole-archive didn't work -# that code would never make it into the final executable and we'd thus be missing some -# of the output. - -include ../tools.mk - -all: $(TMPDIR)/$(call BIN,directly_linked) \ - $(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive) \ - $(TMPDIR)/$(call BIN,directly_linked_test_minus_whole_archive) \ - $(TMPDIR)/$(call BIN,indirectly_linked) \ - $(TMPDIR)/$(call BIN,indirectly_linked_via_attr) - $(call RUN,directly_linked) | $(CGREP) 'static-initializer.directly_linked.' - $(call RUN,directly_linked_test_plus_whole_archive) --nocapture | $(CGREP) 'static-initializer.' - $(call RUN,directly_linked_test_minus_whole_archive) --nocapture | $(CGREP) -v 'static-initializer.' - $(call RUN,indirectly_linked) | $(CGREP) 'static-initializer.indirectly_linked.' - $(call RUN,indirectly_linked_via_attr) | $(CGREP) 'static-initializer.native_lib_in_src.' - -# Native lib linked directly into executable -$(TMPDIR)/$(call BIN,directly_linked): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) directly_linked.rs -l static:+whole-archive=c_static_lib_with_constructor - -# Native lib linked into test executable, +whole-archive -$(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) directly_linked_test_plus_whole_archive.rs --test -l static:+whole-archive=c_static_lib_with_constructor -# Native lib linked into test executable, -whole-archive -$(TMPDIR)/$(call BIN,directly_linked_test_minus_whole_archive): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) directly_linked_test_minus_whole_archive.rs --test -l static:-whole-archive=c_static_lib_with_constructor - -# Native lib linked into RLIB via `-l static:-bundle,+whole-archive`, RLIB linked into executable -$(TMPDIR)/$(call BIN,indirectly_linked): $(TMPDIR)/librlib_with_cmdline_native_lib.rlib - $(RUSTC) indirectly_linked.rs - -# Native lib linked into RLIB via #[link] attribute, RLIB linked into executable -$(TMPDIR)/$(call BIN,indirectly_linked_via_attr): $(TMPDIR)/libnative_lib_in_src.rlib - $(RUSTC) indirectly_linked_via_attr.rs - -# Native lib linked into rlib with via commandline -$(TMPDIR)/librlib_with_cmdline_native_lib.rlib: $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) rlib_with_cmdline_native_lib.rs --crate-type=rlib -l static:-bundle,+whole-archive=c_static_lib_with_constructor - -# Native lib linked into rlib via `#[link()]` attribute on extern block. -$(TMPDIR)/libnative_lib_in_src.rlib: $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) native_lib_in_src.rs --crate-type=rlib - -$(TMPDIR)/libc_static_lib_with_constructor.o: c_static_lib_with_constructor.cpp - $(call COMPILE_OBJ_CXX,$@,$<) diff --git a/tests/run-make/native-link-modifier-whole-archive/rmake.rs b/tests/run-make/native-link-modifier-whole-archive/rmake.rs new file mode 100644 index 00000000000..4e1f34d112e --- /dev/null +++ b/tests/run-make/native-link-modifier-whole-archive/rmake.rs @@ -0,0 +1,85 @@ +// This test case makes sure that native libraries are linked with appropriate semantics +// when the `[+-]bundle,[+-]whole-archive` modifiers are applied to them. +// The test works by checking that the resulting executables produce the expected output, +// part of which is emitted by otherwise unreferenced C code. If +whole-archive didn't work +// that code would never make it into the final executable and we'd thus be missing some +// of the output. +// See https://github.com/rust-lang/rust/issues/88085 + +//@ ignore-cross-compile +// Reason: compiling C++ code does not work well when cross-compiling +// plus, the compiled binary is executed + +use run_make_support::{cxx, is_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name}; + +fn main() { + let mut cxx = cxx(); + if is_msvc() { + cxx.arg("-EHs"); + } + cxx.input("c_static_lib_with_constructor.cpp") + .arg("-c") + .out_exe("libc_static_lib_with_constructor") + .run(); + + let mut llvm_ar = llvm_ar(); + llvm_ar.obj_to_ar(); + if is_msvc() { + llvm_ar + .output_input( + static_lib_name("c_static_lib_with_constructor"), + "libc_static_lib_with_constructor.obj", + ) + .run(); + } else { + llvm_ar + .output_input( + static_lib_name("c_static_lib_with_constructor"), + "libc_static_lib_with_constructor", + ) + .run(); + } + + // Native lib linked directly into executable + rustc() + .input("directly_linked.rs") + .arg("-lstatic:+whole-archive=c_static_lib_with_constructor") + .run(); + + // Native lib linked into test executable, +whole-archive + rustc() + .input("directly_linked_test_plus_whole_archive.rs") + .arg("--test") + .arg("-lstatic:+whole-archive=c_static_lib_with_constructor") + .run(); + + // Native lib linked into test executable, -whole-archive + rustc() + .input("directly_linked_test_minus_whole_archive.rs") + .arg("--test") + .arg("-lstatic:-whole-archive=c_static_lib_with_constructor") + .run(); + + // Native lib linked into rlib with via commandline + rustc() + .input("rlib_with_cmdline_native_lib.rs") + .crate_type("rlib") + .arg("-lstatic:-bundle,+whole-archive=c_static_lib_with_constructor") + .run(); + // Native lib linked into RLIB via `-l static:-bundle,+whole-archive`, RLIB linked into executable + rustc().input("indirectly_linked.rs").run(); + + // Native lib linked into rlib via `#[link()]` attribute on extern block. + rustc().input("native_lib_in_src.rs").crate_type("rlib").run(); + // Native lib linked into RLIB via #[link] attribute, RLIB linked into executable + rustc().input("indirectly_linked_via_attr.rs").run(); + + run("directly_linked").assert_stdout_contains("static-initializer.directly_linked."); + run_with_args("directly_linked_test_plus_whole_archive", &["--nocapture"]) + .assert_stdout_contains("static-initializer."); + run_with_args("directly_linked_test_minus_whole_archive", &["--nocapture"]) + .assert_stdout_not_contains("static-initializer."); + run("indirectly_linked").assert_stdout_contains("static-initializer.indirectly_linked."); + run("indirectly_linked_via_attr") + .assert_stdout_contains("static-initializer.native_lib_in_src."); +} From d5c073eb090f34b42da85f3f768ea6847b9ba7bc Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 22 Jul 2024 15:35:18 -0400 Subject: [PATCH 3/4] rewrite no-builtins-attribute to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - .../native-link-modifier-whole-archive/rmake.rs | 3 ++- tests/run-make/no-builtins-attribute/Makefile | 9 --------- tests/run-make/no-builtins-attribute/rmake.rs | 13 +++++++++++++ 4 files changed, 15 insertions(+), 11 deletions(-) delete mode 100644 tests/run-make/no-builtins-attribute/Makefile create mode 100644 tests/run-make/no-builtins-attribute/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 3ee3bf65cfa..d47d1b46fe1 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -35,7 +35,6 @@ run-make/macos-deployment-target/Makefile run-make/min-global-align/Makefile run-make/native-link-modifier-bundle/Makefile run-make/no-alloc-shim/Makefile -run-make/no-builtins-attribute/Makefile run-make/pdb-buildinfo-cl-cmd/Makefile run-make/pgo-gen-lto/Makefile run-make/pgo-indirect-call-promotion/Makefile diff --git a/tests/run-make/native-link-modifier-whole-archive/rmake.rs b/tests/run-make/native-link-modifier-whole-archive/rmake.rs index 4e1f34d112e..b8b814043e5 100644 --- a/tests/run-make/native-link-modifier-whole-archive/rmake.rs +++ b/tests/run-make/native-link-modifier-whole-archive/rmake.rs @@ -66,7 +66,8 @@ fn main() { .crate_type("rlib") .arg("-lstatic:-bundle,+whole-archive=c_static_lib_with_constructor") .run(); - // Native lib linked into RLIB via `-l static:-bundle,+whole-archive`, RLIB linked into executable + // Native lib linked into RLIB via `-l static:-bundle,+whole-archive` + // RLIB linked into executable rustc().input("indirectly_linked.rs").run(); // Native lib linked into rlib via `#[link()]` attribute on extern block. diff --git a/tests/run-make/no-builtins-attribute/Makefile b/tests/run-make/no-builtins-attribute/Makefile deleted file mode 100644 index 0ce95facaea..00000000000 --- a/tests/run-make/no-builtins-attribute/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -# We want to check if `no-builtins` is also added to the function declarations in the used crate. - -all: - $(RUSTC) no_builtins.rs --emit=link - $(RUSTC) main.rs --emit=llvm-ir - - cat "$(TMPDIR)"/main.ll | "$(LLVM_FILECHECK)" filecheck.main.txt diff --git a/tests/run-make/no-builtins-attribute/rmake.rs b/tests/run-make/no-builtins-attribute/rmake.rs new file mode 100644 index 00000000000..1e15b0c03f1 --- /dev/null +++ b/tests/run-make/no-builtins-attribute/rmake.rs @@ -0,0 +1,13 @@ +// `no_builtins` is an attribute related to LLVM's optimizations. In order to ensure that it has an +// effect on link-time optimizations (LTO), it should be added to function declarations in a crate. +// This test uses the `llvm-filecheck` tool to determine that this attribute is successfully +// being added to these function declarations. +// See https://github.com/rust-lang/rust/pull/113716 + +use run_make_support::{llvm_filecheck, rfs, rustc}; + +fn main() { + rustc().input("no_builtins.rs").emit("link").run(); + rustc().input("main.rs").emit("llvm-ir").run(); + llvm_filecheck().patterns("filecheck.main.txt").stdin(rfs::read("main.ll")).run(); +} From 1a15d901211c37aa2f4f818cbcc49bfa0c2e80b6 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 26 Jul 2024 12:06:25 -0400 Subject: [PATCH 4/4] assert_stdout_contains_regex in run_make_support + variations --- .../run-make-support/src/assertion_helpers.rs | 32 +++++++++++++++++- src/tools/run-make-support/src/command.rs | 33 ++++++++++++++++++- .../src/external_deps/llvm.rs | 30 +++++++++++++++++ src/tools/run-make-support/src/lib.rs | 7 ++-- .../rmake.rs | 8 ++--- 5 files changed, 99 insertions(+), 11 deletions(-) diff --git a/src/tools/run-make-support/src/assertion_helpers.rs b/src/tools/run-make-support/src/assertion_helpers.rs index 4b5b349431d..6d256fc594d 100644 --- a/src/tools/run-make-support/src/assertion_helpers.rs +++ b/src/tools/run-make-support/src/assertion_helpers.rs @@ -3,7 +3,7 @@ use std::panic; use std::path::Path; -use crate::fs; +use crate::{fs, regex}; /// Assert that `actual` is equal to `expected`. #[track_caller] @@ -47,6 +47,36 @@ pub fn assert_not_contains, N: AsRef>(haystack: H, needle: N) } } +/// Assert that `haystack` contains the regex pattern `needle`. +#[track_caller] +pub fn assert_contains_regex, N: AsRef>(haystack: H, needle: N) { + let haystack = haystack.as_ref(); + let needle = needle.as_ref(); + let re = regex::Regex::new(needle).unwrap(); + if !re.is_match(haystack) { + eprintln!("=== HAYSTACK ==="); + eprintln!("{}", haystack); + eprintln!("=== NEEDLE ==="); + eprintln!("{}", needle); + panic!("needle was not found in haystack"); + } +} + +/// Assert that `haystack` does not contain the regex pattern `needle`. +#[track_caller] +pub fn assert_not_contains_regex, N: AsRef>(haystack: H, needle: N) { + let haystack = haystack.as_ref(); + let needle = needle.as_ref(); + let re = regex::Regex::new(needle).unwrap(); + if re.is_match(haystack) { + eprintln!("=== HAYSTACK ==="); + eprintln!("{}", haystack); + eprintln!("=== NEEDLE ==="); + eprintln!("{}", needle); + panic!("needle was unexpectedly found in haystack"); + } +} + /// Assert that all files in `dir1` exist and have the same content in `dir2` pub fn assert_dirs_are_equal(dir1: impl AsRef, dir2: impl AsRef) { let dir2 = dir2.as_ref(); diff --git a/src/tools/run-make-support/src/command.rs b/src/tools/run-make-support/src/command.rs index 47376c401bb..8686855b6f3 100644 --- a/src/tools/run-make-support/src/command.rs +++ b/src/tools/run-make-support/src/command.rs @@ -6,7 +6,10 @@ use std::process::{Command as StdCommand, ExitStatus, Output, Stdio}; use crate::util::handle_failed_output; -use crate::{assert_contains, assert_equals, assert_not_contains}; +use crate::{ + assert_contains, assert_contains_regex, assert_equals, assert_not_contains, + assert_not_contains_regex, +}; use build_helper::drop_bomb::DropBomb; @@ -192,6 +195,13 @@ pub fn assert_stdout_not_contains>(&self, unexpected: S) -> &Self self } + /// Checks that `stdout` does not contain the regex pattern `unexpected`. + #[track_caller] + pub fn assert_stdout_not_contains_regex>(&self, unexpected: S) -> &Self { + assert_not_contains_regex(&self.stdout_utf8(), unexpected); + self + } + /// Checks that `stdout` contains `expected`. #[track_caller] pub fn assert_stdout_contains>(&self, expected: S) -> &Self { @@ -199,6 +209,13 @@ pub fn assert_stdout_contains>(&self, expected: S) -> &Self { self } + /// Checks that `stdout` contains the regex pattern `expected`. + #[track_caller] + pub fn assert_stdout_contains_regex>(&self, expected: S) -> &Self { + assert_contains_regex(&self.stdout_utf8(), expected); + self + } + /// Checks that trimmed `stderr` matches trimmed `expected`. #[track_caller] pub fn assert_stderr_equals>(&self, expected: S) -> &Self { @@ -213,6 +230,13 @@ pub fn assert_stderr_contains>(&self, expected: S) -> &Self { self } + /// Checks that `stderr` contains the regex pattern `expected`. + #[track_caller] + pub fn assert_stderr_contains_regex>(&self, expected: S) -> &Self { + assert_contains_regex(&self.stderr_utf8(), expected); + self + } + /// Checks that `stderr` does not contain `unexpected`. #[track_caller] pub fn assert_stderr_not_contains>(&self, unexpected: S) -> &Self { @@ -220,6 +244,13 @@ pub fn assert_stderr_not_contains>(&self, unexpected: S) -> &Self self } + /// Checks that `stderr` does not contain the regex pattern `unexpected`. + #[track_caller] + pub fn assert_stderr_not_contains_regex>(&self, unexpected: S) -> &Self { + assert_not_contains_regex(&self.stdout_utf8(), unexpected); + self + } + #[track_caller] pub fn assert_exit_code(&self, code: i32) -> &Self { assert!(self.output.status.code() == Some(code)); diff --git a/src/tools/run-make-support/src/external_deps/llvm.rs b/src/tools/run-make-support/src/external_deps/llvm.rs index b116bd08e3a..259bb615946 100644 --- a/src/tools/run-make-support/src/external_deps/llvm.rs +++ b/src/tools/run-make-support/src/external_deps/llvm.rs @@ -36,6 +36,12 @@ pub fn llvm_ar() -> LlvmAr { LlvmAr::new() } +/// Construct a new `llvm-nm` invocation. This assumes that `llvm-nm` is available +/// at `$LLVM_BIN_DIR/llvm-nm`. +pub fn llvm_nm() -> LlvmNm { + LlvmNm::new() +} + /// A `llvm-readobj` invocation builder. #[derive(Debug)] #[must_use] @@ -71,11 +77,19 @@ pub struct LlvmAr { cmd: Command, } +/// A `llvm-nm` invocation builder. +#[derive(Debug)] +#[must_use] +pub struct LlvmNm { + cmd: Command, +} + crate::macros::impl_common_helpers!(LlvmReadobj); crate::macros::impl_common_helpers!(LlvmProfdata); crate::macros::impl_common_helpers!(LlvmFilecheck); crate::macros::impl_common_helpers!(LlvmObjdump); crate::macros::impl_common_helpers!(LlvmAr); +crate::macros::impl_common_helpers!(LlvmNm); /// Generate the path to the bin directory of LLVM. #[must_use] @@ -244,3 +258,19 @@ pub fn output_input(&mut self, out: impl AsRef, input: impl AsRef) - self } } + +impl LlvmNm { + /// Construct a new `llvm-nm` invocation. This assumes that `llvm-nm` is available + /// at `$LLVM_BIN_DIR/llvm-nm`. + pub fn new() -> Self { + let llvm_nm = llvm_bin_dir().join("llvm-nm"); + let cmd = Command::new(llvm_nm); + Self { cmd } + } + + /// Provide an input file. + pub fn input>(&mut self, path: P) -> &mut Self { + self.cmd.arg(path.as_ref()); + self + } +} diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index 085120764b4..f28f2a120a4 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -48,8 +48,8 @@ pub mod rfs { pub use clang::{clang, Clang}; pub use htmldocck::htmldocck; pub use llvm::{ - llvm_ar, llvm_filecheck, llvm_objdump, llvm_profdata, llvm_readobj, LlvmAr, LlvmFilecheck, - LlvmObjdump, LlvmProfdata, LlvmReadobj, + llvm_ar, llvm_filecheck, llvm_nm, llvm_objdump, llvm_profdata, llvm_readobj, LlvmAr, + LlvmFilecheck, LlvmNm, LlvmObjdump, LlvmProfdata, LlvmReadobj, }; pub use python::python_command; pub use rustc::{aux_build, bare_rustc, rustc, Rustc}; @@ -84,7 +84,8 @@ pub mod rfs { pub use scoped_run::{run_in_tmpdir, test_while_readonly}; pub use assertion_helpers::{ - assert_contains, assert_dirs_are_equal, assert_equals, assert_not_contains, + assert_contains, assert_contains_regex, assert_dirs_are_equal, assert_equals, + assert_not_contains, assert_not_contains_regex, }; pub use string::{ 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 index 8d7afd3245e..5a1460963b6 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs +++ b/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs @@ -4,18 +4,14 @@ // 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}; +use run_make_support::{llvm_ar, llvm_nm, 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_nm().input(rust_lib_name("rust_dep")).run().assert_stdout_contains_regex("U.*native_f1"); llvm_ar() .arg("t") .arg(rust_lib_name("rust_dep"))