diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 4607ca5cf9f..98fec4c4861 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -107,6 +107,13 @@ fn main() { env::join_paths(&dylib_path).unwrap()); let mut maybe_crate = None; + // Don't use metadata only backend for snapshot compiler, because it may be broken + if env::var("RUSTC_SHOULD_USE_METADATA_ONLY_BACKEND").is_ok() && stage != "0" { + //cmd.arg("-Zcodegen-backend=metadata_only"); + } else { + cmd.arg("--cfg").arg("codegen_backend=\"llvm\""); + } + // Print backtrace in case of ICE if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() { cmd.env("RUST_BACKTRACE", "1"); diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index d2f9b2653d5..7e4a12f7310 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -747,6 +747,10 @@ impl<'a> Builder<'a> { stage = compiler.stage; } + if self.config.rust_codegen_backends.is_empty() { + cargo.env("RUSTC_SHOULD_USE_METADATA_ONLY_BACKEND", "1"); + } + let mut extra_args = env::var(&format!("RUSTFLAGS_STAGE_{}", stage)).unwrap_or_default(); if stage != 0 { let s = env::var("RUSTFLAGS_STAGE_NOT_0").unwrap_or_default(); diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index bbe6ae8619f..0971f50913c 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -241,12 +241,13 @@ macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*) #[path = "../stdsimd/coresimd/mod.rs"] #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)] #[unstable(feature = "stdsimd", issue = "48556")] -#[cfg(not(stage0))] // allow changes to how stdsimd works in stage0 +// allow changes to how stdsimd works in stage0 and don't use whithout LLVM +#[cfg(all(not(stage0), codegen_backend="llvm"))] mod coresimd; #[unstable(feature = "stdsimd", issue = "48556")] -#[cfg(not(stage0))] +#[cfg(all(not(stage0), codegen_backend="llvm"))] pub use coresimd::simd; #[stable(feature = "simd_arch", since = "1.27.0")] -#[cfg(not(stage0))] +#[cfg(all(not(stage0), codegen_backend="llvm"))] pub use coresimd::arch; diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 95c68214ec7..05e08cb7973 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1418,6 +1418,18 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig { if sess.opts.crate_types.contains(&CrateTypeProcMacro) { ret.insert((Symbol::intern("proc_macro"), None)); } + /*if nightly_options::is_nightly_build() { + let backend_name = sess.opts + .debugging_opts + .codegen_backend + .as_ref() + .map(|s| s as &str) + .unwrap_or("llvm"); + ret.insert(( + Symbol::intern("codegen_backend"), + Some(Symbol::intern(backend_name)), + )); + }*/ return ret; } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index d73cb1f8349..d79f851a3d7 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -523,22 +523,22 @@ pub mod rt; #[path = "../stdsimd/stdsimd/mod.rs"] #[allow(missing_debug_implementations, missing_docs, dead_code)] #[unstable(feature = "stdsimd", issue = "48556")] -#[cfg(all(not(stage0), not(test)))] +#[cfg(all(not(stage0), not(test), codegen_backend="llvm"))] mod stdsimd; // A "fake" module needed by the `stdsimd` module to compile, not actually // exported though. -#[cfg(not(stage0))] +#[cfg(all(not(stage0), codegen_backend="llvm"))] mod coresimd { pub use core::arch; pub use core::simd; } #[unstable(feature = "stdsimd", issue = "48556")] -#[cfg(all(not(stage0), not(test)))] +#[cfg(all(not(stage0), not(test), codegen_backend="llvm"))] pub use stdsimd::simd; #[stable(feature = "simd_arch", since = "1.27.0")] -#[cfg(all(not(stage0), not(test)))] +#[cfg(all(not(stage0), not(test), codegen_backend="llvm"))] pub use stdsimd::arch; // Include a number of private modules that exist solely to provide