Skip to content

Commit 7084f50

Browse files
authored
Unrolled build for rust-lang#137537
Rollup merge of rust-lang#137537 - jieyouxu:daily-rmake, r=Kobzol Prevent `rmake.rs` from using unstable features, and fix 3 run-make tests that currently do Addresses (mostly) rust-lang#137532. Follow-up to rust-lang#137373. ### Summary - Fix 3 run-make tests that currently use unstable features: 1. `tests/run-make/issue-107495-archive-permissions/rmake.rs` uses `#![feature(rustc_private)]` for `libc` on `unix`, but `run_make_support` already exports `libc`, so just use that. 2. `tests/run-make/cross-lang-lto/rmake.rs` uses `#![feature(path_file_prefix)]` for convenience, replaced with similar filename prefix logic. 3. `tests/run-make/broken-pipe-no-ice/rmake.rs` uses `#![feature(anonymous_pipe)]` for anonymous pipes. This is more complicated[^race-condition], and I decided to temporarily introduce a dependency on [`os_pipe`] before std's `anonymous_pipe` library feature is stabilized[^pipe-stab]. I left a FIXME tracked by rust-lang#137532 to make the switch once `anonymous_pipe` stabilizes and reaches beta. - Use `RUSTC_BOOTSTRAP=-1` when building `rmake.rs` to have the stage 0 rustc reject any unstable features used in `rmake.rs`. - The requirement that `rmake.rs` may not use any unstable features is now documented in rustc-dev-guide. - This PR does not impose `RUSTC_BOOTSTRAP=-1` when building `run-make-support`, but I suppose we could. r? `@Kobzol` try-job: x86_64-msvc-1 try-job: x86_64-mingw-1 [`os_pipe`]: https://github.com/oconnor663/os_pipe.rs [^race-condition]: We can't just try to spawn `rustc` and immediate close the stderr handle because of race condition, as there's no guarantee `rustc` will not try to print to stderr before the handle gets closed. [^pipe-stab]: In-progress stabilization PR over at rust-lang#135822.
2 parents f5a1ef7 + c9c572c commit 7084f50

File tree

9 files changed

+43
-15
lines changed

9 files changed

+43
-15
lines changed

Cargo.lock

+11
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,16 @@ version = "0.2.0"
25262526
source = "registry+https://github.com/rust-lang/crates.io-index"
25272527
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
25282528

2529+
[[package]]
2530+
name = "os_pipe"
2531+
version = "1.2.1"
2532+
source = "registry+https://github.com/rust-lang/crates.io-index"
2533+
checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982"
2534+
dependencies = [
2535+
"libc",
2536+
"windows-sys 0.59.0",
2537+
]
2538+
25292539
[[package]]
25302540
name = "overload"
25312541
version = "0.1.1"
@@ -3050,6 +3060,7 @@ dependencies = [
30503060
"gimli 0.31.1",
30513061
"libc",
30523062
"object 0.36.7",
3063+
"os_pipe",
30533064
"regex",
30543065
"serde_json",
30553066
"similar",

src/bootstrap/src/core/builder/cargo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ impl Builder<'_> {
597597
// sysroot. Passing this cfg enables raw-dylib support instead, which makes the native
598598
// library unnecessary. This can be removed when windows-rs enables raw-dylib
599599
// unconditionally.
600-
if let Mode::Rustc | Mode::ToolRustc = mode {
600+
if let Mode::Rustc | Mode::ToolRustc | Mode::ToolBootstrap = mode {
601601
rustflags.arg("--cfg=windows_raw_dylib");
602602
}
603603

src/doc/rustc-dev-guide/src/tests/compiletest.md

+4
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,10 @@ Compiletest directives like `//@ only-<target>` or `//@ ignore-<target>` are
415415
supported in `rmake.rs`, like in UI tests. However, revisions or building
416416
auxiliary via directives are not currently supported.
417417

418+
`rmake.rs` and `run-make-support` may *not* use any nightly/unstable features,
419+
as they must be compilable by a stage 0 rustc that may be a beta or even stable
420+
rustc.
421+
418422
#### Quickly check if `rmake.rs` tests can be compiled
419423

420424
You can quickly check if `rmake.rs` tests can be compiled without having to

src/tools/compiletest/src/runtest/run_make.rs

+5
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ impl TestCx<'_> {
105105
.expect("stage0 rustc is required to run run-make tests");
106106
let mut rustc = Command::new(&stage0_rustc);
107107
rustc
108+
// `rmake.rs` **must** be buildable by a stable compiler, it may not use *any* unstable
109+
// library or compiler features. Here, we force the stage 0 rustc to consider itself as
110+
// a stable-channel compiler via `RUSTC_BOOTSTRAP=-1` to prevent *any* unstable
111+
// library/compiler usages, even if stage 0 rustc is *actually* a nightly rustc.
112+
.env("RUSTC_BOOTSTRAP", "-1")
108113
.arg("-o")
109114
.arg(&recipe_bin)
110115
// Specify library search paths for `run_make_support`.

src/tools/run-make-support/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ build_helper = { path = "../../build_helper" }
1414
serde_json = "1.0"
1515
libc = "0.2"
1616

17+
# FIXME(#137532): replace `os_pipe` with `anonymous_pipe` once it stabilizes and
18+
# reaches beta.
19+
os_pipe = "1.2.1"
20+
1721
[lib]
1822
crate-type = ["lib", "dylib"]

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

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub use bstr;
4040
pub use gimli;
4141
pub use libc;
4242
pub use object;
43+
// FIXME(#137532): replace with std `anonymous_pipe` once it stabilizes and reaches beta.
44+
pub use os_pipe;
4345
pub use regex;
4446
pub use serde_json;
4547
pub use similar;

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
// Internal Compiler Error strangely, but it doesn't even go through normal diagnostic infra. Very
1212
// strange.
1313

14-
#![feature(anonymous_pipe)]
15-
1614
use std::io::Read;
1715
use std::process::{Command, Stdio};
1816

19-
use run_make_support::env_var;
17+
// FIXME(#137532): replace `os_pipe` dependency with std `anonymous_pipe` once that stabilizes and
18+
// reaches beta.
19+
use run_make_support::{env_var, os_pipe};
2020

2121
#[derive(Debug, PartialEq)]
2222
enum Binary {
@@ -25,7 +25,7 @@ enum Binary {
2525
}
2626

2727
fn check_broken_pipe_handled_gracefully(bin: Binary, mut cmd: Command) {
28-
let (reader, writer) = std::io::pipe().unwrap();
28+
let (reader, writer) = os_pipe::pipe().unwrap();
2929
drop(reader); // close read-end
3030
cmd.stdout(writer).stderr(Stdio::piped());
3131

tests/run-make/cross-lang-lto/rmake.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// -Clinker-plugin-lto.
44
// See https://github.com/rust-lang/rust/pull/50000
55

6-
#![feature(path_file_prefix)]
7-
86
use std::path::PathBuf;
97

108
use run_make_support::{
@@ -92,10 +90,17 @@ fn check_bitcode(instructions: LibBuild) {
9290
llvm_ar().extract().arg(&instructions.output).run();
9391
}
9492

95-
for object in shallow_find_files(cwd(), |path| {
96-
has_prefix(path, instructions.output.file_prefix().unwrap().to_str().unwrap())
93+
let objects = shallow_find_files(cwd(), |path| {
94+
let mut output_path = instructions.output.clone();
95+
output_path.set_extension("");
96+
has_prefix(path, output_path.file_name().unwrap().to_str().unwrap())
9797
&& has_extension(path, "o")
98-
}) {
98+
});
99+
assert!(!objects.is_empty());
100+
println!("objects: {:#?}", objects);
101+
102+
for object in objects {
103+
println!("reading bitcode: {}", object.display());
99104
// All generated object files should be LLVM bitcode files - this will fail otherwise.
100105
llvm_bcanalyzer().input(object).run();
101106
}

tests/run-make/issue-107495-archive-permissions/rmake.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
#![feature(rustc_private)]
2-
3-
#[cfg(unix)]
4-
extern crate libc;
5-
61
#[cfg(unix)]
72
use std::os::unix::fs::PermissionsExt;
83
use std::path::Path;
94

5+
#[cfg(unix)]
6+
use run_make_support::libc;
107
use run_make_support::{aux_build, rfs};
118

129
fn main() {

0 commit comments

Comments
 (0)