Skip to content

Commit ff12beb

Browse files
committed
Revert changes to bootstrap, rustc_driver and fix {core,std}simd
1 parent 163cb57 commit ff12beb

File tree

11 files changed

+36
-61
lines changed

11 files changed

+36
-61
lines changed

config.toml.example

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
# =============================================================================
1515
[llvm]
1616

17+
# Indicates whether rustc will support compilation with LLVM
18+
# note: rustc does not compile without LLVM at the moment
19+
#enabled = true
20+
1721
# Indicates whether the LLVM build is a Release or Debug build
1822
#optimize = true
1923

@@ -330,8 +334,8 @@
330334
# This is an array of the codegen backends that will be compiled for the rustc
331335
# that's being compiled. The default is to only build the LLVM codegen backend,
332336
# but you can also optionally enable the "emscripten" backend for asm.js or
333-
# make this an empty array (which will disable LLVM, but that probably won't
334-
# get too far in the bootstrap)
337+
# make this an empty array (but that probably won't get too far in the
338+
# bootstrap)
335339
#codegen-backends = ["llvm"]
336340

337341
# This is the name of the directory in which codegen backends will get installed

src/bootstrap/bin/rustc.rs

-5
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,6 @@ 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_err() {
112-
cmd.arg("--cfg").arg("codegen_backend=\"llvm\"");
113-
}
114-
115110
// Print backtrace in case of ICE
116111
if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() {
117112
cmd.env("RUST_BACKTRACE", "1");

src/bootstrap/builder.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,6 @@ 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-
754750
let mut extra_args = env::var(&format!("RUSTFLAGS_STAGE_{}", stage)).unwrap_or_default();
755751
if stage != 0 {
756752
let s = env::var("RUSTFLAGS_STAGE_NOT_0").unwrap_or_default();
@@ -897,7 +893,7 @@ impl<'a> Builder<'a> {
897893
//
898894
// If LLVM support is disabled we need to use the snapshot compiler to compile
899895
// build scripts, as the new compiler doesn't support executables.
900-
if mode == Mode::Std || self.config.rust_codegen_backends.is_empty() {
896+
if mode == Mode::Std || !self.config.llvm_enabled {
901897
cargo
902898
.env("RUSTC_SNAPSHOT", &self.initial_rustc)
903899
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());

src/bootstrap/compile.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,11 @@ pub fn std_cargo(builder: &Builder,
182182
// missing
183183
// We also only build the runtimes when --enable-sanitizers (or its
184184
// config.toml equivalent) is used
185-
if !builder.config.rust_codegen_backends.is_empty() {
186-
let llvm_config = builder.ensure(native::Llvm {
187-
target: builder.config.build,
188-
emscripten: false,
189-
});
190-
cargo.env("LLVM_CONFIG", llvm_config);
191-
}
185+
let llvm_config = builder.ensure(native::Llvm {
186+
target: builder.config.build,
187+
emscripten: false,
188+
});
189+
cargo.env("LLVM_CONFIG", llvm_config);
192190
}
193191

194192
cargo.arg("--features").arg(features)
@@ -645,13 +643,14 @@ impl Step for CodegenBackend {
645643

646644
fn make_run(run: RunConfig) {
647645
let backend = run.builder.config.rust_codegen_backends.get(0);
648-
if let Some(backend) = backend.cloned() {
649-
run.builder.ensure(CodegenBackend {
650-
compiler: run.builder.compiler(run.builder.top_stage, run.host),
651-
target: run.target,
652-
backend,
653-
});
654-
}
646+
let backend = backend.cloned().unwrap_or_else(|| {
647+
INTERNER.intern_str("llvm")
648+
});
649+
run.builder.ensure(CodegenBackend {
650+
compiler: run.builder.compiler(run.builder.top_stage, run.host),
651+
target: run.target,
652+
backend,
653+
});
655654
}
656655

657656
fn run(self, builder: &Builder) {

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub struct Config {
7474
pub backtrace_on_ice: bool,
7575

7676
// llvm codegen options
77+
pub llvm_enabled: bool,
7778
pub llvm_assertions: bool,
7879
pub llvm_optimize: bool,
7980
pub llvm_release_debuginfo: bool,
@@ -238,6 +239,7 @@ struct Install {
238239
#[derive(Deserialize, Default)]
239240
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
240241
struct Llvm {
242+
enabled: Option<bool>,
241243
ccache: Option<StringOrBool>,
242244
ninja: Option<bool>,
243245
assertions: Option<bool>,
@@ -339,6 +341,7 @@ impl Config {
339341

340342
pub fn default_opts() -> Config {
341343
let mut config = Config::default();
344+
config.llvm_enabled = true;
342345
config.llvm_optimize = true;
343346
config.llvm_version_check = true;
344347
config.use_jemalloc = true;
@@ -493,6 +496,7 @@ impl Config {
493496
Some(StringOrBool::Bool(false)) | None => {}
494497
}
495498
set(&mut config.ninja, llvm.ninja);
499+
set(&mut config.llvm_enabled, llvm.enabled);
496500
llvm_assertions = llvm.assertions;
497501
set(&mut config.llvm_optimize, llvm.optimize);
498502
set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);

src/bootstrap/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ impl Step for Compiletest {
10961096
cmd.arg("--quiet");
10971097
}
10981098

1099-
if !builder.config.rust_codegen_backends.is_empty() {
1099+
if builder.config.llvm_enabled {
11001100
let llvm_config = builder.ensure(native::Llvm {
11011101
target: builder.config.build,
11021102
emscripten: false,
@@ -1129,7 +1129,7 @@ impl Step for Compiletest {
11291129
}
11301130
}
11311131
}
1132-
if suite == "run-make-fulldeps" && builder.config.rust_codegen_backends.is_empty() {
1132+
if suite == "run-make-fulldeps" && !builder.config.llvm_enabled {
11331133
builder.info(&format!(
11341134
"Ignoring run-make test suite as they generally don't work without LLVM"
11351135
));

src/bootstrap/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ impl<'a> Builder<'a> {
672672
}
673673

674674
fn llvm_bin_path(&self) -> Option<PathBuf> {
675-
if !self.config.rust_codegen_backends.is_empty() && !self.config.dry_run {
675+
if self.config.llvm_enabled && !self.config.dry_run {
676676
let llvm_config = self.ensure(native::Llvm {
677677
target: self.config.build,
678678
emscripten: false,

src/libcore/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,12 @@ 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-
// allow changes to how stdsimd works in stage0 and don't use whithout LLVM
245-
#[cfg(all(not(stage0), codegen_backend="llvm"))]
244+
#[cfg(not(stage0))] // allow changes to how stdsimd works in stage0
246245
mod coresimd;
247246

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

src/librustc/session/config.rs

-12
Original file line numberDiff line numberDiff line change
@@ -1418,18 +1418,6 @@ 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-
}*/
14331421
return ret;
14341422
}
14351423

src/librustc_driver/lib.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -375,20 +375,10 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<CodegenBackend> {
375375
match file {
376376
Some(ref s) => return load_backend_from_dylib(s),
377377
None => {
378-
if !::rustc::session::config::nightly_options::is_nightly_build() {
379-
let err = format!("failed to load default codegen backend for `{}`, \
378+
let err = format!("failed to load default codegen backend for `{}`, \
380379
no appropriate codegen dylib found in `{}`",
381380
backend_name, sysroot.display());
382-
early_error(ErrorOutputType::default(), &err);
383-
} else {
384-
let warn = format!("no codegen-backend `{}`, \
385-
no appropriate dylib in `{}`. \
386-
Falling back to metadata_only codegen backend. \
387-
**This is suitable for dev purposes only**",
388-
backend_name, sysroot.display());
389-
early_warn(ErrorOutputType::default(), &warn);
390-
return rustc_codegen_utils::codegen_backend::MetadataOnlyCodegenBackend::new;
391-
}
381+
early_error(ErrorOutputType::default(), &err);
392382
}
393383
}
394384

src/libstd/lib.rs

+4-4
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), codegen_backend="llvm"))]
526+
#[cfg(all(not(stage0), not(test)))]
527527
mod stdsimd;
528528

529529
// A "fake" module needed by the `stdsimd` module to compile, not actually
530530
// exported though.
531-
#[cfg(all(not(stage0), codegen_backend="llvm"))]
531+
#[cfg(not(stage0))]
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), codegen_backend="llvm"))]
538+
#[cfg(all(not(stage0), not(test)))]
539539
pub use stdsimd::simd;
540540
#[stable(feature = "simd_arch", since = "1.27.0")]
541-
#[cfg(all(not(stage0), not(test), codegen_backend="llvm"))]
541+
#[cfg(all(not(stage0), not(test)))]
542542
pub use stdsimd::arch;
543543

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

0 commit comments

Comments
 (0)