Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 6 additions & 8 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2282,15 +2282,13 @@ impl Step for Assemble {
}

// In addition to `rust-lld` also install `wasm-component-ld` when
// LLD is enabled. This is a relatively small binary that primarily
// delegates to the `rust-lld` binary for linking and then runs
// logic to create the final binary. This is used by the
// `wasm32-wasip2` target of Rust.
// is enabled. This is used by the `wasm32-wasip2` target of Rust.
if builder.tool_enabled("wasm-component-ld") {
let wasm_component = builder.ensure(crate::core::build_steps::tool::WasmComponentLd {
compiler: build_compiler,
target: target_compiler.host,
});
let wasm_component =
builder.ensure(crate::core::build_steps::tool::WasmComponentLd::for_target(
builder,
target_compiler.host,
));
builder.copy_link(
&wasm_component.tool_path,
&libdir_bin.join(wasm_component.tool_path.file_name().unwrap()),
Expand Down
58 changes: 57 additions & 1 deletion src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ bootstrap_tool!(
// rustdoc-gui-test has a crate dependency on compiletest, so it needs the same unstable features.
RustdocGUITest, "src/tools/rustdoc-gui-test", "rustdoc-gui-test", is_unstable_tool = true, allow_features = COMPILETEST_ALLOW_FEATURES;
CoverageDump, "src/tools/coverage-dump", "coverage-dump";
WasmComponentLd, "src/tools/wasm-component-ld", "wasm-component-ld", is_unstable_tool = true, allow_features = "min_specialization";
UnicodeTableGenerator, "src/tools/unicode-table-generator", "unicode-table-generator";
FeaturesStatusDump, "src/tools/features-status-dump", "features-status-dump";
OptimizedDist, "src/tools/opt-dist", "opt-dist", submodules = &["src/tools/rustc-perf"];
Expand Down Expand Up @@ -929,6 +928,63 @@ impl Step for LldWrapper {
}
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct WasmComponentLd {
build_compiler: Compiler,
target: TargetSelection,
}

impl WasmComponentLd {
pub fn for_target(builder: &Builder<'_>, target: TargetSelection) -> Self {
Self { build_compiler: get_tool_target_compiler(builder, target), target }
}
}

impl Step for WasmComponentLd {
type Output = ToolBuildResult;

const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/wasm-component-ld")
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(WasmComponentLd {
build_compiler: get_tool_target_compiler(run.builder, run.target),
target: run.target,
});
}

#[cfg_attr(
feature = "tracing",
instrument(
level = "debug",
name = "WasmComponentLd::run",
skip_all,
fields(build_compiler = ?self.build_compiler),
),
)]
fn run(self, builder: &Builder<'_>) -> ToolBuildResult {
builder.ensure(ToolBuild {
build_compiler: self.build_compiler,
target: self.target,
tool: "wasm-component-ld",
mode: Mode::ToolTarget,
path: "src/tools/wasm-component-ld",
source_type: SourceType::InTree,
extra_features: vec![],
allow_features: "min-specialization",
Comment on lines +976 to +977
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: hm, might this be a problem if min_specialization ever gets renamed, removed or stabilized? Or rather, the tool now has to be support being built by both stage 0 compiler and stage 1 compiler right? In that situation, the tool would have to cfg(bootstrap) anyway I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the feature flag is even needed, the tool compiles with the stable compiler... Unless it does some weird detection in build scripts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep it for now, to leave the previous functionality intact. If it becomes an issue, we can always try to remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that sounds reasonable.

cargo_args: vec![],
artifact_kind: ToolArtifactKind::Binary,
})
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::build("WasmComponentLd", self.target).built_by(self.build_compiler))
}
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct RustAnalyzer {
pub compiler: Compiler,
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ impl<'a> Builder<'a> {
tool::CoverageDump,
tool::LlvmBitcodeLinker,
tool::RustcPerf,
tool::WasmComponentLd
),
Kind::Clippy => describe!(
clippy::Std,
Expand Down
2 changes: 0 additions & 2 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,6 @@ mod snapshot {
[build] rustc 0 <host> -> WasmComponentLd 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 1 <host> -> WasmComponentLd 2 <host>
[build] rustdoc 1 <host>
[doc] std 2 <host>
[build] rustc 2 <host> -> std 2 <host>
Expand Down Expand Up @@ -1205,7 +1204,6 @@ mod snapshot {
[build] rustc 0 <host> -> WasmComponentLd 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 1 <host> -> WasmComponentLd 2 <host>
[build] rustdoc 1 <host>
[doc] std 2 <target1>
[build] rustc 2 <host> -> std 2 <host>
Expand Down
Loading