handle no_std targets on std builds
This change unifies the `Step::run_make` logic and improves it by skipping std specific crates for no_std targets. Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
parent
a5ee5cbad1
commit
6e247195c6
3 changed files with 22 additions and 8 deletions
|
@ -3,7 +3,7 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use crate::core::build_steps::compile::{
|
||||
add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo,
|
||||
add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo, std_crates_for_run_make,
|
||||
};
|
||||
use crate::core::build_steps::tool::{prepare_tool_cargo, SourceType};
|
||||
use crate::core::builder::{
|
||||
|
@ -49,7 +49,7 @@ impl Step for Std {
|
|||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
let crates = run.make_run_crates(Alias::Library);
|
||||
let crates = std_crates_for_run_make(&run);
|
||||
run.builder.ensure(Std { target: run.target, crates, override_build_kind: None });
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ use super::compile::{librustc_stamp, libstd_stamp, run_cargo, rustc_cargo, std_c
|
|||
use super::tool::{prepare_tool_cargo, SourceType};
|
||||
use super::{check, compile};
|
||||
use crate::builder::{Builder, ShouldRun};
|
||||
use crate::core::build_steps::compile::std_crates_for_run_make;
|
||||
use crate::core::builder;
|
||||
use crate::core::builder::{crate_description, Alias, Kind, RunConfig, Step};
|
||||
use crate::{Mode, Subcommand, TargetSelection};
|
||||
|
@ -106,7 +107,7 @@ impl Step for Std {
|
|||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
let crates = run.make_run_crates(Alias::Library);
|
||||
let crates = std_crates_for_run_make(&run);
|
||||
run.builder.ensure(Std { target: run.target, crates });
|
||||
}
|
||||
|
||||
|
|
|
@ -123,11 +123,7 @@ impl Step for Std {
|
|||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
// If the paths include "library", build the entire standard library.
|
||||
let has_alias =
|
||||
run.paths.iter().any(|set| set.assert_single_path().path.ends_with("library"));
|
||||
let crates = if has_alias { Default::default() } else { run.cargo_crates_in_set() };
|
||||
|
||||
let crates = std_crates_for_run_make(&run);
|
||||
run.builder.ensure(Std {
|
||||
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
|
||||
target: run.target,
|
||||
|
@ -425,6 +421,23 @@ fn copy_self_contained_objects(
|
|||
target_deps
|
||||
}
|
||||
|
||||
/// Resolves standard library crates for `Std::run_make` for any build kind (like check, build, clippy, etc.).
|
||||
pub fn std_crates_for_run_make(run: &RunConfig<'_>) -> Vec<String> {
|
||||
let has_alias = run.paths.iter().any(|set| set.assert_single_path().path.ends_with("library"));
|
||||
let target_is_no_std = run.builder.no_std(run.target).unwrap_or(false);
|
||||
|
||||
// For no_std targets, do not add any additional crates to the compilation other than what `compile::std_cargo` already adds for no_std targets.
|
||||
if target_is_no_std {
|
||||
vec![]
|
||||
}
|
||||
// If the paths include "library", build the entire standard library.
|
||||
else if has_alias {
|
||||
run.make_run_crates(builder::Alias::Library)
|
||||
} else {
|
||||
run.cargo_crates_in_set()
|
||||
}
|
||||
}
|
||||
|
||||
/// Configure cargo to compile the standard library, adding appropriate env vars
|
||||
/// and such.
|
||||
pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, cargo: &mut Cargo) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue