Skip to content

Commit 4fd82f7

Browse files
committed
make optimized-compiler-builtins target configurable
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent 6afee11 commit 4fd82f7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
469469
// If `compiler-rt` is available ensure that the `c` feature of the
470470
// `compiler-builtins` crate is enabled and it's configured to learn where
471471
// `compiler-rt` is located.
472-
let compiler_builtins_c_feature = if builder.config.optimized_compiler_builtins {
472+
let compiler_builtins_c_feature = if builder.config.optimized_compiler_builtins(target) {
473473
// NOTE: this interacts strangely with `llvm-has-rust-patches`. In that case, we enforce `submodules = false`, so this is a no-op.
474474
// But, the user could still decide to manually use an in-tree submodule.
475475
//

src/bootstrap/src/core/config/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ pub struct Target {
634634
pub runner: Option<String>,
635635
pub no_std: bool,
636636
pub codegen_backends: Option<Vec<String>>,
637+
pub optimized_compiler_builtins: Option<bool>,
637638
}
638639

639640
impl Target {
@@ -1219,6 +1220,7 @@ define_config! {
12191220
no_std: Option<bool> = "no-std",
12201221
codegen_backends: Option<Vec<String>> = "codegen-backends",
12211222
runner: Option<String> = "runner",
1223+
optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
12221224
}
12231225
}
12241226

@@ -2096,6 +2098,7 @@ impl Config {
20962098
target.sanitizers = cfg.sanitizers;
20972099
target.profiler = cfg.profiler;
20982100
target.rpath = cfg.rpath;
2101+
target.optimized_compiler_builtins = cfg.optimized_compiler_builtins;
20992102

21002103
if let Some(ref backends) = cfg.codegen_backends {
21012104
let available_backends = ["llvm", "cranelift", "gcc"];
@@ -2609,6 +2612,13 @@ impl Config {
26092612
self.target_config.get(&target).and_then(|t| t.rpath).unwrap_or(self.rust_rpath)
26102613
}
26112614

2615+
pub fn optimized_compiler_builtins(&self, target: TargetSelection) -> bool {
2616+
self.target_config
2617+
.get(&target)
2618+
.and_then(|t| t.optimized_compiler_builtins)
2619+
.unwrap_or(self.optimized_compiler_builtins)
2620+
}
2621+
26122622
pub fn llvm_enabled(&self, target: TargetSelection) -> bool {
26132623
self.codegen_backends(target).contains(&"llvm".to_owned())
26142624
}

0 commit comments

Comments
 (0)