Skip to content

Commit 6511ece

Browse files
committed
Port RemoteTestServer to ToolTarget
1 parent 2fbc642 commit 6511ece

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::core::build_steps::compile::{
55
};
66
use crate::core::build_steps::tool;
77
use crate::core::build_steps::tool::{
8-
COMPILETEST_ALLOW_FEATURES, SourceType, get_tool_target_compiler, prepare_tool_cargo,
8+
COMPILETEST_ALLOW_FEATURES, SourceType, get_compiler_for_target, prepare_tool_cargo,
99
};
1010
use crate::core::builder::{
1111
self, Alias, Builder, Kind, RunConfig, ShouldRun, Step, StepMetadata, crate_description,
@@ -252,7 +252,7 @@ fn prepare_compiler_for_check(
252252

253253
match mode {
254254
Mode::ToolBootstrap => builder.compiler(0, host),
255-
Mode::ToolTarget => get_tool_target_compiler(builder, target),
255+
Mode::ToolTarget => get_compiler_for_target(builder, target),
256256
Mode::ToolStd => {
257257
// These tools require the local standard library to be checked
258258
let build_compiler = builder.compiler(builder.top_stage, host);

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2941,7 +2941,8 @@ impl Step for RemoteCopyLibs {
29412941

29422942
builder.info(&format!("REMOTE copy libs to emulator ({target})"));
29432943

2944-
let remote_test_server = builder.ensure(tool::RemoteTestServer { compiler, target });
2944+
let remote_test_server =
2945+
builder.ensure(tool::RemoteTestServer { build_compiler: compiler, target });
29452946

29462947
// Spawn the emulator and wait for it to come online
29472948
let tool = builder.tool_exe(Tool::RemoteTestClient);

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

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl Step for ToolBuild {
133133
builder.std(self.build_compiler, target);
134134
}
135135
}
136-
Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs
136+
Mode::ToolBootstrap | Mode::ToolTarget => {} // uses downloaded stage0 compiler libs
137137
_ => panic!("unexpected Mode for tool build"),
138138
}
139139

@@ -196,7 +196,7 @@ impl Step for ToolBuild {
196196
Kind::Build,
197197
self.mode,
198198
self.tool,
199-
self.build_compiler.stage,
199+
self.build_compiler.stage + 1,
200200
&self.build_compiler.host,
201201
&self.target,
202202
);
@@ -365,15 +365,15 @@ pub(crate) fn get_tool_rustc_compiler(
365365
builder.compiler(target_compiler.stage.saturating_sub(1), builder.config.host_target)
366366
}
367367

368-
/// Returns a compiler that is able to compile a `ToolTarget` tool for the given `target`.
369-
pub(crate) fn get_tool_target_compiler(builder: &Builder<'_>, target: TargetSelection) -> Compiler {
370-
todo!("FIX");
371-
if builder.host_target == target {
368+
/// Returns the smallest stage compiler that is able to compile code for the given `target`.
369+
pub(crate) fn get_compiler_for_target(builder: &Builder<'_>, target: TargetSelection) -> Compiler {
370+
let compiler = if builder.host_target == target {
372371
builder.compiler(0, builder.host_target)
373372
} else {
374-
// FIXME: should this be builder.top_stage to avoid rebuilds?
375-
builder.compiler(1, target)
376-
}
373+
builder.compiler(1, builder.host_target)
374+
};
375+
builder.std(compiler, target);
376+
compiler
377377
}
378378

379379
/// Links a built tool binary with the given `name` from the build directory to the
@@ -648,7 +648,7 @@ impl Step for ErrorIndex {
648648

649649
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
650650
pub struct RemoteTestServer {
651-
pub compiler: Compiler,
651+
pub build_compiler: Compiler,
652652
pub target: TargetSelection,
653653
}
654654

@@ -661,17 +661,17 @@ impl Step for RemoteTestServer {
661661

662662
fn make_run(run: RunConfig<'_>) {
663663
run.builder.ensure(RemoteTestServer {
664-
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.host_target),
664+
build_compiler: get_compiler_for_target(run.builder, run.target),
665665
target: run.target,
666666
});
667667
}
668668

669669
fn run(self, builder: &Builder<'_>) -> ToolBuildResult {
670670
builder.ensure(ToolBuild {
671-
build_compiler: self.compiler,
671+
build_compiler: self.build_compiler,
672672
target: self.target,
673673
tool: "remote-test-server",
674-
mode: Mode::ToolStd,
674+
mode: Mode::ToolTarget,
675675
path: "src/tools/remote-test-server",
676676
source_type: SourceType::InTree,
677677
extra_features: Vec::new(),
@@ -680,6 +680,10 @@ impl Step for RemoteTestServer {
680680
artifact_kind: ToolArtifactKind::Binary,
681681
})
682682
}
683+
684+
fn metadata(&self) -> Option<StepMetadata> {
685+
Some(StepMetadata::build("remote-test-server", self.target).built_by(self.build_compiler))
686+
}
683687
}
684688

685689
#[derive(Debug, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]

0 commit comments

Comments
 (0)