Skip to content

Commit 7ee4357

Browse files
Move build-manifest target lists to rustc target metadata
This ensures that as long as the target metadata is updated to reflect the current state (tier 3 vs 1/2, host toolchain support), the manifest will also be updated. This avoids an extremely common 'oops' when we move targets between tiers. This mostly removes a bunch of tier 3 targets from manifests. I didn't spot check against produced artifacts but given that they are tier 3 it's probably reasonable to leave it as-is and bug reporters can fix the target metadata in rustc (or we can stop producing artifacts). Follow-up work would ideally lint the artifact list as part of nightly/beta/stable builds as well, but for now this is simple and hopefully removes at common source of extra PRs when modifying targets.
1 parent e1a2ec6 commit 7ee4357

File tree

13 files changed

+148
-198
lines changed

13 files changed

+148
-198
lines changed

compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
1717
metadata: TargetMetadata {
1818
description: Some("ARM64 MinGW (Windows 10+), LLVM ABI".into()),
1919
tier: Some(2),
20-
host_tools: Some(false),
20+
host_tools: Some(true),
2121
std: Some(true),
2222
},
2323
pointer_width: 64,

compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,11 @@ pub(crate) fn target() -> Target {
55
base.rustc_abi = None; // overwrite the SSE2 ABI set by the base target
66
base.cpu = "pentium".into();
77
base.llvm_target = "i586-unknown-linux-gnu".into();
8+
base.metadata = crate::spec::TargetMetadata {
9+
description: Some("32-bit Linux (kernel 3.2, glibc 2.17+)".into()),
10+
tier: Some(2),
11+
host_tools: Some(false),
12+
std: Some(true),
13+
};
814
base
915
}

compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(crate) fn target() -> Target {
1818
metadata: TargetMetadata {
1919
description: Some("SPARC Solaris 11.4".into()),
2020
tier: Some(2),
21-
host_tools: Some(false),
21+
host_tools: Some(true),
2222
std: Some(true),
2323
},
2424
pointer_width: 64,

compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub(crate) fn target() -> Target {
6363
llvm_target: "wasm32-wasip2".into(),
6464
metadata: TargetMetadata {
6565
description: Some("WebAssembly".into()),
66-
tier: Some(3),
66+
tier: Some(2),
6767
host_tools: Some(false),
6868
std: Some(true),
6969
},

compiler/rustc_target/src/spec/targets/wasm32_wasip3.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ pub(crate) fn target() -> Target {
1515
// and this may grow over time as more features are supported.
1616
let mut target = super::wasm32_wasip2::target();
1717
target.llvm_target = "wasm32-wasip3".into();
18+
target.metadata = crate::spec::TargetMetadata {
19+
description: Some("WebAssembly".into()),
20+
tier: Some(3),
21+
host_tools: Some(false),
22+
std: Some(true),
23+
};
1824
target.options.env = Env::P3;
1925
target
2026
}

compiler/rustc_target/src/spec/targets/x86_64_pc_solaris.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(crate) fn target() -> Target {
2020
metadata: TargetMetadata {
2121
description: Some("64-bit Solaris 11.4".into()),
2222
tier: Some(2),
23-
host_tools: Some(false),
23+
host_tools: Some(true),
2424
std: Some(true),
2525
},
2626
pointer_width: 64,

compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(crate) fn target() -> Target {
1414
metadata: TargetMetadata {
1515
description: Some("64-bit x86 MinGW (Windows 10+), LLVM ABI".into()),
1616
tier: Some(2),
17-
host_tools: Some(false),
17+
host_tools: Some(true),
1818
std: Some(true),
1919
},
2020
pointer_width: 64,

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use tracing::instrument;
2222
use crate::core::build_steps::compile::{get_codegen_backend_file, normalize_codegen_backend_name};
2323
use crate::core::build_steps::doc::DocumentationFormat;
2424
use crate::core::build_steps::tool::{
25-
self, RustcPrivateCompilers, Tool, ToolTargetBuildMode, get_tool_target_compiler,
25+
self, RustcPrivateCompilers, ToolTargetBuildMode, get_tool_target_compiler,
2626
};
2727
use crate::core::build_steps::vendor::{VENDOR_DIR, Vendor};
2828
use crate::core::build_steps::{compile, llvm};
@@ -2695,10 +2695,13 @@ impl Step for BuildManifest {
26952695
}
26962696

26972697
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
2698-
let build_manifest = builder.tool_exe(Tool::BuildManifest);
2698+
let build_manifest = builder.ensure(tool::BuildManifest {
2699+
compiler: builder.compiler(1, builder.config.host_target),
2700+
target: builder.config.host_target,
2701+
});
26992702

27002703
let tarball = Tarball::new(builder, "build-manifest", &self.target.triple);
2701-
tarball.add_file(&build_manifest, "bin", FileType::Executable);
2704+
tarball.add_file(&build_manifest.tool_path, "bin", FileType::Executable);
27022705
tarball.generate()
27032706
}
27042707

src/bootstrap/src/core/build_steps/run.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ impl Step for BuildManifest {
3737
fn run(self, builder: &Builder<'_>) {
3838
// This gets called by `promote-release`
3939
// (https://github.com/rust-lang/promote-release).
40-
let mut cmd = builder.tool_cmd(Tool::BuildManifest);
40+
let mut cmd = command(
41+
builder
42+
.ensure(tool::BuildManifest {
43+
compiler: builder.compiler(1, builder.config.host_target),
44+
target: builder.config.host_target,
45+
})
46+
.tool_path,
47+
);
4148
let sign = builder.config.dist_sign_folder.as_ref().unwrap_or_else(|| {
4249
panic!("\n\nfailed to specify `dist.sign-folder` in `bootstrap.toml`\n\n")
4350
});

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ bootstrap_tool!(
485485
Linkchecker, "src/tools/linkchecker", "linkchecker";
486486
CargoTest, "src/tools/cargotest", "cargotest";
487487
Compiletest, "src/tools/compiletest", "compiletest";
488-
BuildManifest, "src/tools/build-manifest", "build-manifest";
489488
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
490489
RustInstaller, "src/tools/rust-installer", "rust-installer";
491490
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
@@ -1268,6 +1267,49 @@ impl Step for LibcxxVersionTool {
12681267
}
12691268
}
12701269

1270+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
1271+
pub struct BuildManifest {
1272+
pub compiler: Compiler,
1273+
pub target: TargetSelection,
1274+
}
1275+
1276+
impl Step for BuildManifest {
1277+
type Output = ToolBuildResult;
1278+
1279+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1280+
run.path("src/tools/build-manifest")
1281+
}
1282+
1283+
fn make_run(run: RunConfig<'_>) {
1284+
run.builder.ensure(BuildManifest {
1285+
compiler: run.builder.compiler(1, run.builder.config.host_target),
1286+
target: run.target,
1287+
});
1288+
}
1289+
1290+
fn run(self, builder: &Builder<'_>) -> ToolBuildResult {
1291+
// Building with the beta compiler will produce a broken build-manifest that doesn't support
1292+
// recently stabilized targets/hosts.
1293+
assert!(self.compiler.stage != 0);
1294+
builder.ensure(ToolBuild {
1295+
build_compiler: self.compiler,
1296+
target: self.target,
1297+
tool: "build-manifest",
1298+
mode: Mode::ToolStd,
1299+
path: "src/tools/build-manifest",
1300+
source_type: SourceType::InTree,
1301+
extra_features: vec![],
1302+
allow_features: "",
1303+
cargo_args: vec![],
1304+
artifact_kind: ToolArtifactKind::Binary,
1305+
})
1306+
}
1307+
1308+
fn metadata(&self) -> Option<StepMetadata> {
1309+
Some(StepMetadata::build("build-manifest", self.target).built_by(self.compiler))
1310+
}
1311+
}
1312+
12711313
/// Represents which compilers are involved in the compilation of a tool
12721314
/// that depends on compiler internals (`rustc_private`).
12731315
/// Their compilation looks like this:

0 commit comments

Comments
 (0)