Skip to content

Commit 8cc0310

Browse files
committed
Auto merge of #127060 - Oneirical:testificate, r=<try>
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
2 parents 595316b + 83b80a6 commit 8cc0310

File tree

7 files changed

+220
-126
lines changed

7 files changed

+220
-126
lines changed

Diff for: src/tools/compiletest/src/command-list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
117117
"ignore-watchos",
118118
"ignore-windows",
119119
"ignore-windows-gnu",
120+
"ignore-windows-msvc",
120121
"ignore-x32",
121122
"ignore-x86",
122123
"ignore-x86_64",

Diff for: src/tools/run-make-support/src/command.rs

+8
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,19 @@ pub struct CompletedProcess {
163163

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

170171
#[must_use]
172+
#[track_caller]
173+
pub fn invalid_stdout_utf8(&self) -> String {
174+
String::from_utf8_lossy(&self.output.stdout.clone()).to_string()
175+
}
176+
177+
#[must_use]
178+
#[track_caller]
171179
pub fn stderr_utf8(&self) -> String {
172180
String::from_utf8(self.output.stderr.clone()).expect("stderr is not valid UTF-8")
173181
}

Diff for: src/tools/run-make-support/src/external_deps/llvm.rs

+30
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ pub fn llvm_ar() -> LlvmAr {
3636
LlvmAr::new()
3737
}
3838

39+
/// Construct a new `llvm-nm` invocation. This assumes that `llvm-nm` is available
40+
/// at `$LLVM_BIN_DIR/llvm-nm`.
41+
pub fn llvm_nm() -> LlvmNm {
42+
LlvmNm::new()
43+
}
44+
3945
/// A `llvm-readobj` invocation builder.
4046
#[derive(Debug)]
4147
#[must_use]
@@ -71,11 +77,19 @@ pub struct LlvmAr {
7177
cmd: Command,
7278
}
7379

80+
/// A `llvm-nm` invocation builder.
81+
#[derive(Debug)]
82+
#[must_use]
83+
pub struct LlvmNm {
84+
cmd: Command,
85+
}
86+
7487
crate::macros::impl_common_helpers!(LlvmReadobj);
7588
crate::macros::impl_common_helpers!(LlvmProfdata);
7689
crate::macros::impl_common_helpers!(LlvmFilecheck);
7790
crate::macros::impl_common_helpers!(LlvmObjdump);
7891
crate::macros::impl_common_helpers!(LlvmAr);
92+
crate::macros::impl_common_helpers!(LlvmNm);
7993

8094
/// Generate the path to the bin directory of LLVM.
8195
#[must_use]
@@ -244,3 +258,19 @@ impl LlvmAr {
244258
self
245259
}
246260
}
261+
262+
impl LlvmNm {
263+
/// Construct a new `llvm-nm` invocation. This assumes that `llvm-nm` is available
264+
/// at `$LLVM_BIN_DIR/llvm-nm`.
265+
pub fn new() -> Self {
266+
let llvm_nm = llvm_bin_dir().join("llvm-nm");
267+
let cmd = Command::new(llvm_nm);
268+
Self { cmd }
269+
}
270+
271+
/// Provide an input file.
272+
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
273+
self.cmd.arg(path.as_ref());
274+
self
275+
}
276+
}

Diff for: src/tools/run-make-support/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ pub use cc::{cc, cxx, extra_c_flags, extra_cxx_flags, Cc};
4848
pub use clang::{clang, Clang};
4949
pub use htmldocck::htmldocck;
5050
pub use llvm::{
51-
llvm_ar, llvm_filecheck, llvm_objdump, llvm_profdata, llvm_readobj, LlvmAr, LlvmFilecheck,
52-
LlvmObjdump, LlvmProfdata, LlvmReadobj,
51+
llvm_ar, llvm_filecheck, llvm_nm, llvm_objdump, llvm_profdata, llvm_readobj, LlvmAr,
52+
LlvmFilecheck, LlvmNm, LlvmObjdump, LlvmProfdata, LlvmReadobj,
5353
};
5454
pub use python::python_command;
5555
pub use rustc::{aux_build, bare_rustc, rustc, Rustc};

Diff for: src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ run-make/split-debuginfo/Makefile
5252
run-make/stable-symbol-names/Makefile
5353
run-make/staticlib-dylib-linkage/Makefile
5454
run-make/symbol-mangling-hashed/Makefile
55-
run-make/symbol-visibility/Makefile
5655
run-make/sysroot-crates-are-unstable/Makefile
5756
run-make/thumb-none-cortex-m/Makefile
5857
run-make/thumb-none-qemu/Makefile

Diff for: tests/run-make/symbol-visibility/Makefile

-123
This file was deleted.

0 commit comments

Comments
 (0)