Skip to content

Commit 1848322

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 1848322

File tree

14 files changed

+161
-199
lines changed

14 files changed

+161
-199
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: 7 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,14 @@ impl Step for BuildManifest {
26952695
}
26962696

26972697
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
2698-
let build_manifest = builder.tool_exe(Tool::BuildManifest);
2698+
// FIXME: Should BuildManifest actually be built for `self.target`?
2699+
// Today CI only builds this step where that matches the host_target so it doesn't matter
2700+
// today.
2701+
let build_manifest =
2702+
builder.ensure(tool::BuildManifest::new(builder, builder.config.host_target));
26992703

27002704
let tarball = Tarball::new(builder, "build-manifest", &self.target.triple);
2701-
tarball.add_file(&build_manifest, "bin", FileType::Executable);
2705+
tarball.add_file(&build_manifest.tool_path, "bin", FileType::Executable);
27022706
tarball.generate()
27032707
}
27042708

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ 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.ensure(tool::BuildManifest::new(builder, builder.config.host_target)).tool_path,
42+
);
4143
let sign = builder.config.dist_sign_folder.as_ref().unwrap_or_else(|| {
4244
panic!("\n\nfailed to specify `dist.sign-folder` in `bootstrap.toml`\n\n")
4345
});

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

Lines changed: 46 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,52 @@ impl Step for LibcxxVersionTool {
12681267
}
12691268
}
12701269

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

0 commit comments

Comments
 (0)