Skip to content

Commit

Permalink
Rollup merge of rust-lang#125787 - Oneirical:infinite-test-a-novel, r…
Browse files Browse the repository at this point in the history
…=jieyouxu

Migrate `bin-emit-no-symbols` `run-make` test to `rmake`

Part of rust-lang#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
  • Loading branch information
jieyouxu authored Jun 19, 2024
2 parents 51ca222 + 977d3f6 commit 03032b8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
28 changes: 23 additions & 5 deletions src/tools/run-make-support/src/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::path::{Path, PathBuf};

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()
Expand Down Expand Up @@ -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.
Expand All @@ -90,6 +101,13 @@ impl LlvmReadobj {
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 {
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 @@ -84,7 +84,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
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions tests/run-make/bin-emit-no-symbols/rmake.rs
Original file line number Diff line number Diff line change
@@ -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");
}
9 changes: 0 additions & 9 deletions tests/run-make/issue-51671/Makefile

This file was deleted.

0 comments on commit 03032b8

Please sign in to comment.