Skip to content

Commit 879d65b

Browse files
authored
Unrolled build for rust-lang#140843
Rollup merge of rust-lang#140843 - jieyouxu:broken-pipe, r=Kobzol Fix `broken-pipe-no-ice` run-make test for rpath-less builds The `broken-pipe-no-ice` run-make test currently fails on rpath-less builds, because host compiler runtime libs are not configured for raw std command usages. This PR is an alternative approach to rust-lang#140744. However, instead of duplicating `run_make_support::util::set_host_compiler_dylib_path` logic, we instead support "ejecting" the "configured" underlying std `Command` from `bare_rustc()` and `rustdoc()`, where host compiler runtime libs are already set. cc `@jchecahi` r? `@Kobzol`
2 parents dcecb99 + 84ed40d commit 879d65b

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ impl Command {
6363
}
6464
}
6565

66+
// Internal-only.
67+
pub(crate) fn into_raw_command(mut self) -> std::process::Command {
68+
self.drop_bomb.defuse();
69+
self.cmd
70+
}
71+
6672
/// Specify a stdin input buffer. This is a convenience helper,
6773
pub fn stdin_buf<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
6874
self.stdin_buf = Some(input.as_ref().to_vec().into_boxed_slice());

src/tools/run-make-support/src/external_deps/rustdoc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::command::Command;
55
use crate::env::env_var;
66
use crate::util::set_host_compiler_dylib_path;
77

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

3030
impl Rustdoc {
31-
/// Construct a bare `rustdoc` invocation.
31+
/// Construct a bare `rustdoc` invocation. This will configure the host compiler runtime libs.
3232
#[track_caller]
3333
pub fn new() -> Self {
3434
let cmd = setup_common();

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

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828
macro_rules! impl_common_helpers {
2929
($wrapper: ident) => {
3030
impl $wrapper {
31+
/// In very rare circumstances, you may need a e.g. `bare_rustc()` or `bare_rustdoc()`
32+
/// with host runtime libs configured, but want the underlying raw
33+
/// [`std::process::Command`] (e.g. for manipulating pipes or whatever). This function
34+
/// will consume the command wrapper and extract the underlying
35+
/// [`std::process::Command`].
36+
///
37+
/// Caution: this will mean that you can no longer use the convenience methods on the
38+
/// command wrapper. Use as a last resort.
39+
pub fn into_raw_command(self) -> ::std::process::Command {
40+
self.cmd.into_raw_command()
41+
}
42+
3143
/// Specify an environment variable.
3244
pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Self
3345
where

tests/run-make/broken-pipe-no-ice/rmake.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use std::io::Read;
1515
use std::process::{Command, Stdio};
1616

17-
use run_make_support::env_var;
17+
use run_make_support::{bare_rustc, rustdoc};
1818

1919
#[derive(Debug, PartialEq)]
2020
enum Binary {
@@ -67,11 +67,13 @@ fn check_broken_pipe_handled_gracefully(bin: Binary, mut cmd: Command) {
6767
}
6868

6969
fn main() {
70-
let mut rustc = Command::new(env_var("RUSTC"));
70+
let mut rustc = bare_rustc();
7171
rustc.arg("--print=sysroot");
72+
let rustc = rustc.into_raw_command();
7273
check_broken_pipe_handled_gracefully(Binary::Rustc, rustc);
7374

74-
let mut rustdoc = Command::new(env_var("RUSTDOC"));
75+
let mut rustdoc = rustdoc();
7576
rustdoc.arg("--version");
77+
let rustdoc = rustdoc.into_raw_command();
7678
check_broken_pipe_handled_gracefully(Binary::Rustdoc, rustdoc);
7779
}

0 commit comments

Comments
 (0)