Skip to content

Commit

Permalink
Only use coresimd when codegen_backend is LLVM
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Jul 7, 2018
1 parent c7c534f commit a533041
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/bootstrap/bin/rustc.rs
Expand Up @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/builder.rs
Expand Up @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions src/libcore/lib.rs
Expand Up @@ -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;
12 changes: 12 additions & 0 deletions src/librustc/session/config.rs
Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions src/libstd/lib.rs
Expand Up @@ -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
Expand Down

0 comments on commit a533041

Please sign in to comment.