Skip to content

Commit a533041

Browse files
committed
Only use coresimd when codegen_backend is LLVM
1 parent c7c534f commit a533041

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ fn main() {
107107
env::join_paths(&dylib_path).unwrap());
108108
let mut maybe_crate = None;
109109

110+
// Don't use metadata only backend for snapshot compiler, because it may be broken
111+
if env::var("RUSTC_SHOULD_USE_METADATA_ONLY_BACKEND").is_ok() && stage != "0" {
112+
//cmd.arg("-Zcodegen-backend=metadata_only");
113+
} else {
114+
cmd.arg("--cfg").arg("codegen_backend=\"llvm\"");
115+
}
116+
110117
// Print backtrace in case of ICE
111118
if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() {
112119
cmd.env("RUST_BACKTRACE", "1");

src/bootstrap/builder.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ impl<'a> Builder<'a> {
747747
stage = compiler.stage;
748748
}
749749

750+
if self.config.rust_codegen_backends.is_empty() {
751+
cargo.env("RUSTC_SHOULD_USE_METADATA_ONLY_BACKEND", "1");
752+
}
753+
750754
let mut extra_args = env::var(&format!("RUSTFLAGS_STAGE_{}", stage)).unwrap_or_default();
751755
if stage != 0 {
752756
let s = env::var("RUSTFLAGS_STAGE_NOT_0").unwrap_or_default();

src/libcore/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,13 @@ macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*)
241241
#[path = "../stdsimd/coresimd/mod.rs"]
242242
#[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
243243
#[unstable(feature = "stdsimd", issue = "48556")]
244-
#[cfg(not(stage0))] // allow changes to how stdsimd works in stage0
244+
// allow changes to how stdsimd works in stage0 and don't use whithout LLVM
245+
#[cfg(all(not(stage0), codegen_backend="llvm"))]
245246
mod coresimd;
246247

247248
#[unstable(feature = "stdsimd", issue = "48556")]
248-
#[cfg(not(stage0))]
249+
#[cfg(all(not(stage0), codegen_backend="llvm"))]
249250
pub use coresimd::simd;
250251
#[stable(feature = "simd_arch", since = "1.27.0")]
251-
#[cfg(not(stage0))]
252+
#[cfg(all(not(stage0), codegen_backend="llvm"))]
252253
pub use coresimd::arch;

src/librustc/session/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,18 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
14181418
if sess.opts.crate_types.contains(&CrateTypeProcMacro) {
14191419
ret.insert((Symbol::intern("proc_macro"), None));
14201420
}
1421+
/*if nightly_options::is_nightly_build() {
1422+
let backend_name = sess.opts
1423+
.debugging_opts
1424+
.codegen_backend
1425+
.as_ref()
1426+
.map(|s| s as &str)
1427+
.unwrap_or("llvm");
1428+
ret.insert((
1429+
Symbol::intern("codegen_backend"),
1430+
Some(Symbol::intern(backend_name)),
1431+
));
1432+
}*/
14211433
return ret;
14221434
}
14231435

src/libstd/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,22 +523,22 @@ pub mod rt;
523523
#[path = "../stdsimd/stdsimd/mod.rs"]
524524
#[allow(missing_debug_implementations, missing_docs, dead_code)]
525525
#[unstable(feature = "stdsimd", issue = "48556")]
526-
#[cfg(all(not(stage0), not(test)))]
526+
#[cfg(all(not(stage0), not(test), codegen_backend="llvm"))]
527527
mod stdsimd;
528528

529529
// A "fake" module needed by the `stdsimd` module to compile, not actually
530530
// exported though.
531-
#[cfg(not(stage0))]
531+
#[cfg(all(not(stage0), codegen_backend="llvm"))]
532532
mod coresimd {
533533
pub use core::arch;
534534
pub use core::simd;
535535
}
536536

537537
#[unstable(feature = "stdsimd", issue = "48556")]
538-
#[cfg(all(not(stage0), not(test)))]
538+
#[cfg(all(not(stage0), not(test), codegen_backend="llvm"))]
539539
pub use stdsimd::simd;
540540
#[stable(feature = "simd_arch", since = "1.27.0")]
541-
#[cfg(all(not(stage0), not(test)))]
541+
#[cfg(all(not(stage0), not(test), codegen_backend="llvm"))]
542542
pub use stdsimd::arch;
543543

544544
// Include a number of private modules that exist solely to provide

0 commit comments

Comments
 (0)