Skip to content

Commit 49287a4

Browse files
authored
Rollup merge of #106051 - jyn514:cranelift-std, r=bjorn3
Allow building std with cranelift - Don't pass llvm-specific args when using cranelift - Don't use `asm` in compiler_builtins when using cranelift r? `@bjorn3` cc `@Mark-Simulacrum`
2 parents 3e58de2 + 0b3ffcb commit 49287a4

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

compiler/rustc_codegen_llvm/src/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ fn codegen_msvc_try<'ll>(
567567
// module.
568568
//
569569
// When modifying, make sure that the type_name string exactly matches
570-
// the one used in src/libpanic_unwind/seh.rs.
570+
// the one used in library/panic_unwind/src/seh.rs.
571571
let type_info_vtable = bx.declare_global("??_7type_info@@6B@", bx.type_i8p());
572572
let type_name = bx.const_bytes(b"rust_panic\0");
573573
let type_info =

src/bootstrap/builder.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,10 @@ impl<'a> Builder<'a> {
18631863
};
18641864

18651865
if let Some(limit) = limit {
1866-
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={}", limit));
1866+
if stage == 0 || self.config.default_codegen_backend().unwrap_or_default() == "llvm"
1867+
{
1868+
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={}", limit));
1869+
}
18671870
}
18681871
}
18691872

src/bootstrap/compile.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,15 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
321321
""
322322
};
323323

324+
let mut features = String::new();
325+
326+
// Cranelift doesn't support `asm`.
327+
if stage != 0 && builder.config.default_codegen_backend().unwrap_or_default() == "cranelift" {
328+
features += " compiler-builtins-no-asm";
329+
}
330+
324331
if builder.no_std(target) == Some(true) {
325-
let mut features = "compiler-builtins-mem".to_string();
332+
features += " compiler-builtins-mem";
326333
if !target.starts_with("bpf") {
327334
features.push_str(compiler_builtins_c_feature);
328335
}
@@ -335,7 +342,7 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
335342
.arg("--features")
336343
.arg(features);
337344
} else {
338-
let mut features = builder.std_features(target);
345+
features += &builder.std_features(target);
339346
features.push_str(compiler_builtins_c_feature);
340347

341348
cargo
@@ -754,7 +761,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
754761
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
755762
.env("CFG_VERSION", builder.rust_version());
756763

757-
if let Some(backend) = builder.config.rust_codegen_backends.get(0) {
764+
if let Some(backend) = builder.config.default_codegen_backend() {
758765
cargo.env("CFG_DEFAULT_CODEGEN_BACKEND", backend);
759766
}
760767

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,10 @@ impl Config {
16111611
self.submodules.unwrap_or(rust_info.is_managed_git_subrepository())
16121612
}
16131613

1614+
pub fn default_codegen_backend(&self) -> Option<Interned<String>> {
1615+
self.rust_codegen_backends.get(0).cloned()
1616+
}
1617+
16141618
/// Returns the commit to download, or `None` if we shouldn't download CI artifacts.
16151619
fn download_ci_rustc_commit(&self, download_rustc: Option<StringOrBool>) -> Option<String> {
16161620
// If `download-rustc` is not set, default to rebuilding.

src/bootstrap/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ impl Build {
795795
/// Gets the space-separated set of activated features for the standard
796796
/// library.
797797
fn std_features(&self, target: TargetSelection) -> String {
798-
let mut features = "panic-unwind".to_string();
798+
let mut features = " panic-unwind".to_string();
799799

800800
match self.config.llvm_libunwind(target) {
801801
LlvmLibunwind::InTree => features.push_str(" llvm-libunwind"),

0 commit comments

Comments
 (0)