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
This commit is contained in:
León Orell Valerian Liehr 2024-06-19 09:52:00 +02:00 committed by GitHub
commit 11391115cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 39 additions and 15 deletions

View File

@ -2,8 +2,8 @@
use crate::{env_var, Command};
/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
/// at `$LLVM_BIN_DIR/llvm-readobj`.
/// Construct a new `llvm-readobj` invocation with the `GNU` output style.
/// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.
#[track_caller]
pub fn llvm_readobj() -> LlvmReadobj {
LlvmReadobj::new()
@ -70,13 +70,24 @@ pub fn llvm_bin_dir() -> PathBuf {
}
impl LlvmReadobj {
/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
/// at `$LLVM_BIN_DIR/llvm-readobj`.
/// Construct a new `llvm-readobj` invocation with the `GNU` output style.
/// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.
#[track_caller]
pub fn new() -> Self {
let llvm_readobj = llvm_bin_dir().join("llvm-readobj");
let cmd = Command::new(llvm_readobj);
Self { cmd }
let mut readobj = Self { cmd };
readobj.elf_output_style("GNU");
readobj
}
/// Specify the format of the ELF information.
///
/// Valid options are `LLVM` (default), `GNU`, and `JSON`.
pub fn elf_output_style(&mut self, style: &str) -> &mut Self {
self.cmd.arg("--elf-output-style");
self.cmd.arg(style);
self
}
/// Provide an input file.
@ -90,6 +101,13 @@ pub fn file_header(&mut self) -> &mut Self {
self.cmd.arg("--file-header");
self
}
/// Specify the section to display.
pub fn section(&mut self, section: &str) -> &mut Self {
self.cmd.arg("--string-dump");
self.cmd.arg(section);
self
}
}
impl LlvmProfdata {

View File

@ -83,7 +83,6 @@ run-make/issue-37839/Makefile
run-make/issue-40535/Makefile
run-make/issue-47384/Makefile
run-make/issue-47551/Makefile
run-make/issue-51671/Makefile
run-make/issue-68794-textrel-on-minimal-lib/Makefile
run-make/issue-69368/Makefile
run-make/issue-83045/Makefile

View File

@ -0,0 +1,16 @@
// When setting the crate type as a "bin" (in app.rs),
// this could cause a bug where some symbols would not be
// emitted in the object files. This has been fixed, and
// this test checks that the correct symbols have been successfully
// emitted inside the object files.
// See https://github.com/rust-lang/rust/issues/51671
use run_make_support::{llvm_readobj, rustc};
fn main() {
rustc().emit("obj").input("app.rs").run();
let out = llvm_readobj().input("app.o").arg("--symbols").run();
out.assert_stdout_contains("rust_begin_unwind");
out.assert_stdout_contains("rust_eh_personality");
out.assert_stdout_contains("__rg_oom");
}

View File

@ -1,9 +0,0 @@
include ../tools.mk
# ignore-windows-msvc
all:
$(RUSTC) --emit=obj app.rs
nm $(TMPDIR)/app.o | $(CGREP) rust_begin_unwind
nm $(TMPDIR)/app.o | $(CGREP) rust_eh_personality
nm $(TMPDIR)/app.o | $(CGREP) __rg_oom