Skip to content

Commit

Permalink
Auto merge of #127060 - Oneirical:testificate, r=<try>
Browse files Browse the repository at this point in the history
Migrate `symbol-visibility` `run-make` test to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Pretty scary!

- The expected number of symbols on each check has been changed slightly to reflect the differences between `llvm_readobj` and `nm`, as I think the former will print hidden symbols once and visible symbols twice, while the latter will only print visible symbols.
- The original test ran the same exact checks on `cdylib` twice, for seemingly no reason. I have removed it.
- This may be possible to optimize some more? `llvm_readobj` could get called only once for each library type, and the regex could avoid being created repeatedly. I am not sure if these kinds of considerations are important for a `run-make` test.

Demands a Windows try-job.

try-job: x86_64-mingw
  • Loading branch information
bors committed Jul 30, 2024
2 parents 595316b + 83b80a6 commit 8cc0310
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 126 deletions.
1 change: 1 addition & 0 deletions src/tools/compiletest/src/command-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-watchos",
"ignore-windows",
"ignore-windows-gnu",
"ignore-windows-msvc",
"ignore-x32",
"ignore-x86",
"ignore-x86_64",
Expand Down
8 changes: 8 additions & 0 deletions src/tools/run-make-support/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,19 @@ pub struct CompletedProcess {

impl CompletedProcess {
#[must_use]
#[track_caller]
pub fn stdout_utf8(&self) -> String {
String::from_utf8(self.output.stdout.clone()).expect("stdout is not valid UTF-8")
}

#[must_use]
#[track_caller]
pub fn invalid_stdout_utf8(&self) -> String {
String::from_utf8_lossy(&self.output.stdout.clone()).to_string()
}

#[must_use]
#[track_caller]
pub fn stderr_utf8(&self) -> String {
String::from_utf8(self.output.stderr.clone()).expect("stderr is not valid UTF-8")
}
Expand Down
30 changes: 30 additions & 0 deletions src/tools/run-make-support/src/external_deps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -244,3 +258,19 @@ impl LlvmAr {
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<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg(path.as_ref());
self
}
}
4 changes: 2 additions & 2 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ pub use cc::{cc, cxx, extra_c_flags, extra_cxx_flags, Cc};
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};
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ run-make/split-debuginfo/Makefile
run-make/stable-symbol-names/Makefile
run-make/staticlib-dylib-linkage/Makefile
run-make/symbol-mangling-hashed/Makefile
run-make/symbol-visibility/Makefile
run-make/sysroot-crates-are-unstable/Makefile
run-make/thumb-none-cortex-m/Makefile
run-make/thumb-none-qemu/Makefile
Expand Down
123 changes: 0 additions & 123 deletions tests/run-make/symbol-visibility/Makefile

This file was deleted.

Loading

0 comments on commit 8cc0310

Please sign in to comment.