Skip to content

Commit 1139111

Browse files
authored
Rollup merge of #125787 - Oneirical:infinite-test-a-novel, r=jieyouxu
Migrate `bin-emit-no-symbols` `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). try-job: x86_64-msvc try-job: armhf-gnu
2 parents 96144c9 + 977d3f6 commit 1139111

File tree

5 files changed

+39
-15
lines changed

5 files changed

+39
-15
lines changed

src/tools/run-make-support/src/llvm.rs

+23-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::path::{Path, PathBuf};
22

33
use crate::{env_var, Command};
44

5-
/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
6-
/// at `$LLVM_BIN_DIR/llvm-readobj`.
5+
/// Construct a new `llvm-readobj` invocation with the `GNU` output style.
6+
/// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.
77
#[track_caller]
88
pub fn llvm_readobj() -> LlvmReadobj {
99
LlvmReadobj::new()
@@ -70,13 +70,24 @@ pub fn llvm_bin_dir() -> PathBuf {
7070
}
7171

7272
impl LlvmReadobj {
73-
/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
74-
/// at `$LLVM_BIN_DIR/llvm-readobj`.
73+
/// Construct a new `llvm-readobj` invocation with the `GNU` output style.
74+
/// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.
7575
#[track_caller]
7676
pub fn new() -> Self {
7777
let llvm_readobj = llvm_bin_dir().join("llvm-readobj");
7878
let cmd = Command::new(llvm_readobj);
79-
Self { cmd }
79+
let mut readobj = Self { cmd };
80+
readobj.elf_output_style("GNU");
81+
readobj
82+
}
83+
84+
/// Specify the format of the ELF information.
85+
///
86+
/// Valid options are `LLVM` (default), `GNU`, and `JSON`.
87+
pub fn elf_output_style(&mut self, style: &str) -> &mut Self {
88+
self.cmd.arg("--elf-output-style");
89+
self.cmd.arg(style);
90+
self
8091
}
8192

8293
/// Provide an input file.
@@ -90,6 +101,13 @@ impl LlvmReadobj {
90101
self.cmd.arg("--file-header");
91102
self
92103
}
104+
105+
/// Specify the section to display.
106+
pub fn section(&mut self, section: &str) -> &mut Self {
107+
self.cmd.arg("--string-dump");
108+
self.cmd.arg(section);
109+
self
110+
}
93111
}
94112

95113
impl LlvmProfdata {

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ run-make/issue-37839/Makefile
8383
run-make/issue-40535/Makefile
8484
run-make/issue-47384/Makefile
8585
run-make/issue-47551/Makefile
86-
run-make/issue-51671/Makefile
8786
run-make/issue-68794-textrel-on-minimal-lib/Makefile
8887
run-make/issue-69368/Makefile
8988
run-make/issue-83045/Makefile
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// When setting the crate type as a "bin" (in app.rs),
2+
// this could cause a bug where some symbols would not be
3+
// emitted in the object files. This has been fixed, and
4+
// this test checks that the correct symbols have been successfully
5+
// emitted inside the object files.
6+
// See https://github.com/rust-lang/rust/issues/51671
7+
8+
use run_make_support::{llvm_readobj, rustc};
9+
10+
fn main() {
11+
rustc().emit("obj").input("app.rs").run();
12+
let out = llvm_readobj().input("app.o").arg("--symbols").run();
13+
out.assert_stdout_contains("rust_begin_unwind");
14+
out.assert_stdout_contains("rust_eh_personality");
15+
out.assert_stdout_contains("__rg_oom");
16+
}

tests/run-make/issue-51671/Makefile

-9
This file was deleted.

0 commit comments

Comments
 (0)