Skip to content

Fix broken-pipe-no-ice run-make test for rpath-less builds #140843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/tools/run-make-support/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ impl Command {
}
}

// Internal-only.
pub(crate) fn into_raw_command(mut self) -> std::process::Command {
self.drop_bomb.defuse();
self.cmd
}

/// Specify a stdin input buffer. This is a convenience helper,
pub fn stdin_buf<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
self.stdin_buf = Some(input.as_ref().to_vec().into_boxed_slice());
Expand Down
4 changes: 2 additions & 2 deletions src/tools/run-make-support/src/external_deps/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::command::Command;
use crate::env::env_var;
use crate::util::set_host_compiler_dylib_path;

/// Construct a new `rustdoc` invocation.
/// Construct a new `rustdoc` invocation. This will configure the host compiler runtime libs.
#[track_caller]
pub fn rustdoc() -> Rustdoc {
Rustdoc::new()
Expand All @@ -28,7 +28,7 @@ fn setup_common() -> Command {
}

impl Rustdoc {
/// Construct a bare `rustdoc` invocation.
/// Construct a bare `rustdoc` invocation. This will configure the host compiler runtime libs.
#[track_caller]
pub fn new() -> Self {
let cmd = setup_common();
Expand Down
12 changes: 12 additions & 0 deletions src/tools/run-make-support/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@
macro_rules! impl_common_helpers {
($wrapper: ident) => {
impl $wrapper {
/// In very rare circumstances, you may need a e.g. `bare_rustc()` or `bare_rustdoc()`
/// with host runtime libs configured, but want the underlying raw
/// [`std::process::Command`] (e.g. for manipulating pipes or whatever). This function
/// will consume the command wrapper and extract the underlying
/// [`std::process::Command`].
///
/// Caution: this will mean that you can no longer use the convenience methods on the
/// command wrapper. Use as a last resort.
pub fn into_raw_command(self) -> ::std::process::Command {
self.cmd.into_raw_command()
}

/// Specify an environment variable.
pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Self
where
Expand Down
8 changes: 5 additions & 3 deletions tests/run-make/broken-pipe-no-ice/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use std::io::Read;
use std::process::{Command, Stdio};

use run_make_support::env_var;
use run_make_support::{bare_rustc, rustdoc};

#[derive(Debug, PartialEq)]
enum Binary {
Expand Down Expand Up @@ -67,11 +67,13 @@ fn check_broken_pipe_handled_gracefully(bin: Binary, mut cmd: Command) {
}

fn main() {
let mut rustc = Command::new(env_var("RUSTC"));
let mut rustc = bare_rustc();
rustc.arg("--print=sysroot");
let rustc = rustc.into_raw_command();
check_broken_pipe_handled_gracefully(Binary::Rustc, rustc);

let mut rustdoc = Command::new(env_var("RUSTDOC"));
let mut rustdoc = rustdoc();
rustdoc.arg("--version");
let rustdoc = rustdoc.into_raw_command();
check_broken_pipe_handled_gracefully(Binary::Rustdoc, rustdoc);
}
Loading