From c7d285b78136a5bccf8419afa4c57428b83b8bec Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Oct 2019 07:04:39 -0700 Subject: [PATCH] Remove `src/llvm-emscripten` submodule With #65251 landed there's no need to build two LLVM backends and ship them with rustc, every target we have now uses the same LLVM backend! This removes the `src/llvm-emscripten` submodule and additionally removes all support from rustbuild for building the emscripten LLVM backend. Multiple codegen backend support is left in place for now, and this is intended to be an easy 10-15 minute win on CI times by avoiding having to build LLVM twice. --- .gitmodules | 3 - config.toml.example | 5 +- src/bootstrap/bootstrap.py | 4 -- src/bootstrap/compile.rs | 27 +++------ src/bootstrap/config.rs | 1 - src/bootstrap/configure.py | 5 +- src/bootstrap/dist.rs | 4 -- src/bootstrap/lib.rs | 7 --- src/bootstrap/native.rs | 75 +++++++++---------------- src/bootstrap/test.rs | 3 +- src/ci/docker/dist-various-1/Dockerfile | 1 - src/ci/init_repo.sh | 2 +- src/librustc_codegen_llvm/Cargo.toml | 6 -- src/llvm-emscripten | 1 - src/tools/tidy/src/lib.rs | 1 - 15 files changed, 36 insertions(+), 109 deletions(-) delete mode 160000 src/llvm-emscripten diff --git a/.gitmodules b/.gitmodules index 3ff5af78097..1dcf9ed319f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,9 +28,6 @@ [submodule "src/doc/rust-by-example"] path = src/doc/rust-by-example url = https://github.com/rust-lang/rust-by-example.git -[submodule "src/llvm-emscripten"] - path = src/llvm-emscripten - url = https://github.com/rust-lang/llvm.git [submodule "src/stdarch"] path = src/stdarch url = https://github.com/rust-lang/stdarch.git diff --git a/config.toml.example b/config.toml.example index 2e3b714f922..be977024426 100644 --- a/config.toml.example +++ b/config.toml.example @@ -374,10 +374,7 @@ # This is an array of the codegen backends that will be compiled for the rustc # that's being compiled. The default is to only build the LLVM codegen backend, -# but you can also optionally enable the "emscripten" backend for asm.js or -# make this an empty array (but that probably won't get too far in the -# bootstrap) -# FIXME: remove the obsolete emscripten backend option. +# and currently the only standard option supported is `"llvm"` #codegen-backends = ["llvm"] # This is the name of the directory in which codegen backends will get installed diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 65129eeeec5..4caf36a6f2a 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -734,10 +734,6 @@ class RustBuild(object): if module.endswith("llvm-project"): if self.get_toml('llvm-config') and self.get_toml('lld') != 'true': continue - if module.endswith("llvm-emscripten"): - backends = self.get_toml('codegen-backends') - if backends is None or not 'emscripten' in backends: - continue check = self.check_submodule(module, slow_submodules) filtered_submodules.append((module, check)) submodules_names.append(module) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 6ea32edfb20..5074b035789 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -210,7 +210,6 @@ pub fn std_cargo(builder: &Builder<'_>, // config.toml equivalent) is used let llvm_config = builder.ensure(native::Llvm { target: builder.config.build, - emscripten: false, }); cargo.env("LLVM_CONFIG", llvm_config); cargo.env("RUSTC_BUILD_SANITIZERS", "1"); @@ -615,36 +614,27 @@ pub fn build_codegen_backend(builder: &Builder<'_>, compiler: &Compiler, target: Interned, backend: Interned) -> String { - let mut features = String::new(); - match &*backend { - "llvm" | "emscripten" => { + "llvm" => { // Build LLVM for our target. This will implicitly build the // host LLVM if necessary. let llvm_config = builder.ensure(native::Llvm { target, - emscripten: backend == "emscripten", }); - if backend == "emscripten" { - features.push_str(" emscripten"); - } - builder.info(&format!("Building stage{} codegen artifacts ({} -> {}, {})", compiler.stage, &compiler.host, target, backend)); // Pass down configuration from the LLVM build into the build of // librustc_llvm and librustc_codegen_llvm. - if builder.is_rust_llvm(target) && backend != "emscripten" { + if builder.is_rust_llvm(target) { cargo.env("LLVM_RUSTLLVM", "1"); } cargo.env("LLVM_CONFIG", &llvm_config); - if backend != "emscripten" { - let target_config = builder.config.target_config.get(&target); - if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { - cargo.env("CFG_LLVM_ROOT", s); - } + let target_config = builder.config.target_config.get(&target); + if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { + cargo.env("CFG_LLVM_ROOT", s); } // Some LLVM linker flags (-L and -l) may be needed to link librustc_llvm. if let Some(ref s) = builder.config.llvm_ldflags { @@ -662,9 +652,7 @@ pub fn build_codegen_backend(builder: &Builder<'_>, "libstdc++.a"); cargo.env("LLVM_STATIC_STDCPP", file); } - if builder.config.llvm_link_shared || - (builder.config.llvm_thin_lto && backend != "emscripten") - { + if builder.config.llvm_link_shared || builder.config.llvm_thin_lto { cargo.env("LLVM_LINK_SHARED", "1"); } if builder.config.llvm_use_libcxx { @@ -676,8 +664,7 @@ pub fn build_codegen_backend(builder: &Builder<'_>, } _ => panic!("unknown backend: {}", backend), } - - features + String::new() } /// Creates the `codegen-backends` folder for a compiler that's about to be diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 52b5cd888df..441bb8d68fa 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -668,7 +668,6 @@ impl Config { pub fn llvm_enabled(&self) -> bool { self.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) - || self.rust_codegen_backends.contains(&INTERNER.intern_str("emscripten")) } } diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 346f0cb2039..76509134f7c 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -55,7 +55,6 @@ o("sanitizers", "build.sanitizers", "build the sanitizer runtimes (asan, lsan, m o("dist-src", "rust.dist-src", "when building tarballs enables building a source tarball") o("cargo-native-static", "build.cargo-native-static", "static native libraries in cargo") o("profiler", "build.profiler", "build the profiler runtime") -o("emscripten", None, "compile the emscripten backend as well as LLVM") o("full-tools", None, "enable all tools") o("lld", "rust.lld", "build lld") o("lldb", "rust.lldb", "build lldb") @@ -335,10 +334,8 @@ for key in known_args: set('build.host', value.split(',')) elif option.name == 'target': set('build.target', value.split(',')) - elif option.name == 'emscripten': - set('rust.codegen-backends', ['llvm', 'emscripten']) elif option.name == 'full-tools': - set('rust.codegen-backends', ['llvm', 'emscripten']) + set('rust.codegen-backends', ['llvm']) set('rust.lld', True) set('rust.llvm-tools', True) set('build.extended', True) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index d9dff77a30e..514ad114449 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -826,7 +826,6 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str] const LLVM_TEST: &[&str] = &[ "llvm-project/llvm/test", "llvm-project\\llvm\\test", - "llvm-emscripten/test", "llvm-emscripten\\test", ]; if LLVM_TEST.iter().any(|path| spath.contains(path)) && (spath.ends_with(".ll") || @@ -834,9 +833,6 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str] spath.ends_with(".s")) { return false } - if spath.contains("test/emscripten") || spath.contains("test\\emscripten") { - return false - } let full_path = Path::new(dir).join(path); if exclude_dirs.iter().any(|excl| full_path == Path::new(excl)) { diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 6fc72fa0b2a..a182405f3b2 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -232,7 +232,6 @@ pub struct Build { miri_info: channel::GitInfo, rustfmt_info: channel::GitInfo, in_tree_llvm_info: channel::GitInfo, - emscripten_llvm_info: channel::GitInfo, local_rebuild: bool, fail_fast: bool, doc_tests: DocTests, @@ -351,7 +350,6 @@ impl Build { // we always try to use git for LLVM builds let in_tree_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-project")); - let emscripten_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-emscripten")); let mut build = Build { initial_rustc: config.initial_rustc.clone(), @@ -376,7 +374,6 @@ impl Build { miri_info, rustfmt_info, in_tree_llvm_info, - emscripten_llvm_info, cc: HashMap::new(), cxx: HashMap::new(), ar: HashMap::new(), @@ -553,10 +550,6 @@ impl Build { self.out.join(&*target).join("llvm") } - fn emscripten_llvm_out(&self, target: Interned) -> PathBuf { - self.out.join(&*target).join("llvm-emscripten") - } - fn lld_out(&self, target: Interned) -> PathBuf { self.out.join(&*target).join("lld") } diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index fb308bc35eb..97cdd256801 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -28,7 +28,6 @@ use crate::GitRepo; #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Llvm { pub target: Interned, - pub emscripten: bool, } impl Step for Llvm { @@ -40,46 +39,35 @@ impl Step for Llvm { run.path("src/llvm-project") .path("src/llvm-project/llvm") .path("src/llvm") - .path("src/llvm-emscripten") } fn make_run(run: RunConfig<'_>) { - let emscripten = run.path.ends_with("llvm-emscripten"); run.builder.ensure(Llvm { target: run.target, - emscripten, }); } /// Compile LLVM for `target`. fn run(self, builder: &Builder<'_>) -> PathBuf { let target = self.target; - let emscripten = self.emscripten; // If we're using a custom LLVM bail out here, but we can only use a // custom LLVM for the build triple. - if !self.emscripten { - if let Some(config) = builder.config.target_config.get(&target) { - if let Some(ref s) = config.llvm_config { - check_llvm_version(builder, s); - return s.to_path_buf() - } + if let Some(config) = builder.config.target_config.get(&target) { + if let Some(ref s) = config.llvm_config { + check_llvm_version(builder, s); + return s.to_path_buf() } } - let (llvm_info, root, out_dir, llvm_config_ret_dir) = if emscripten { - let info = &builder.emscripten_llvm_info; - let dir = builder.emscripten_llvm_out(target); - let config_dir = dir.join("bin"); - (info, "src/llvm-emscripten", dir, config_dir) - } else { - let info = &builder.in_tree_llvm_info; - let mut dir = builder.llvm_out(builder.config.build); - if !builder.config.build.contains("msvc") || builder.config.ninja { - dir.push("build"); - } - (info, "src/llvm-project/llvm", builder.llvm_out(target), dir.join("bin")) - }; + let llvm_info = &builder.in_tree_llvm_info; + let root = "src/llvm-project/llvm"; + let out_dir = builder.llvm_out(target); + let mut llvm_config_ret_dir = builder.llvm_out(builder.config.build); + if !builder.config.build.contains("msvc") || builder.config.ninja { + llvm_config_ret_dir.push("build"); + } + llvm_config_ret_dir.push("bin"); let build_llvm_config = llvm_config_ret_dir .join(exe("llvm-config", &*builder.config.build)); @@ -107,8 +95,7 @@ impl Step for Llvm { } } - let descriptor = if emscripten { "Emscripten " } else { "" }; - builder.info(&format!("Building {}LLVM for {}", descriptor, target)); + builder.info(&format!("Building LLVM for {}", target)); let _time = util::timeit(&builder); t!(fs::create_dir_all(&out_dir)); @@ -123,23 +110,15 @@ impl Step for Llvm { // NOTE: remember to also update `config.toml.example` when changing the // defaults! - let llvm_targets = if self.emscripten { - "JSBackend" - } else { - match builder.config.llvm_targets { - Some(ref s) => s, - None => "AArch64;ARM;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;\ - Sparc;SystemZ;WebAssembly;X86", - } + let llvm_targets = match &builder.config.llvm_targets { + Some(s) => s, + None => "AArch64;ARM;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;\ + Sparc;SystemZ;WebAssembly;X86", }; - let llvm_exp_targets = if self.emscripten { - "" - } else { - match builder.config.llvm_experimental_targets { - Some(ref s) => s, - None => "", - } + let llvm_exp_targets = match builder.config.llvm_experimental_targets { + Some(ref s) => s, + None => "", }; let assertions = if builder.config.llvm_assertions {"ON"} else {"OFF"}; @@ -163,25 +142,23 @@ impl Step for Llvm { .define("LLVM_TARGET_ARCH", target.split('-').next().unwrap()) .define("LLVM_DEFAULT_TARGET_TRIPLE", target); - if builder.config.llvm_thin_lto && !emscripten { + if builder.config.llvm_thin_lto { cfg.define("LLVM_ENABLE_LTO", "Thin"); if !target.contains("apple") { cfg.define("LLVM_ENABLE_LLD", "ON"); } } - let want_lldb = builder.config.lldb_enabled && !self.emscripten; - // This setting makes the LLVM tools link to the dynamic LLVM library, // which saves both memory during parallel links and overall disk space // for the tools. We don't do this on every platform as it doesn't work // equally well everywhere. - if builder.llvm_link_tools_dynamically(target) && !emscripten { + if builder.llvm_link_tools_dynamically(target) { cfg.define("LLVM_LINK_LLVM_DYLIB", "ON"); } // For distribution we want the LLVM tools to be *statically* linked to libstdc++ - if builder.config.llvm_tools_enabled || want_lldb { + if builder.config.llvm_tools_enabled || builder.config.lldb_enabled { if !target.contains("windows") { if target.contains("apple") { cfg.define("CMAKE_EXE_LINKER_FLAGS", "-static-libstdc++"); @@ -209,7 +186,7 @@ impl Step for Llvm { enabled_llvm_projects.push("compiler-rt"); } - if want_lldb { + if builder.config.lldb_enabled { enabled_llvm_projects.push("clang"); enabled_llvm_projects.push("lldb"); // For the time being, disable code signing. @@ -234,10 +211,9 @@ impl Step for Llvm { } // http://llvm.org/docs/HowToCrossCompileLLVM.html - if target != builder.config.build && !emscripten { + if target != builder.config.build { builder.ensure(Llvm { target: builder.config.build, - emscripten: false, }); // FIXME: if the llvm root for the build triple is overridden then we // should use llvm-tblgen from there, also should verify that it @@ -481,7 +457,6 @@ impl Step for Lld { let llvm_config = builder.ensure(Llvm { target: self.target, - emscripten: false, }); let out_dir = builder.lld_out(target); diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 0b7aa0750a1..7ed67c6c7c5 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1163,7 +1163,7 @@ impl Step for Compiletest { }).to_string() }) }; - let lldb_exe = if builder.config.lldb_enabled && !target.contains("emscripten") { + let lldb_exe = if builder.config.lldb_enabled { // Test against the lldb that was just built. builder.llvm_out(target).join("bin").join("lldb") } else { @@ -1232,7 +1232,6 @@ impl Step for Compiletest { if builder.config.llvm_enabled() { let llvm_config = builder.ensure(native::Llvm { target: builder.config.build, - emscripten: false, }); if !builder.config.dry_run { let llvm_version = output(Command::new(&llvm_config).arg("--version")); diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile index 10579119462..fab3824a20a 100644 --- a/src/ci/docker/dist-various-1/Dockerfile +++ b/src/ci/docker/dist-various-1/Dockerfile @@ -139,7 +139,6 @@ ENV RUST_CONFIGURE_ARGS \ --musl-root-aarch64=/musl-aarch64 \ --musl-root-mips=/musl-mips \ --musl-root-mipsel=/musl-mipsel \ - --enable-emscripten \ --disable-docs ENV SCRIPT \ diff --git a/src/ci/init_repo.sh b/src/ci/init_repo.sh index c7c3b0a5fbf..92c6e546a38 100755 --- a/src/ci/init_repo.sh +++ b/src/ci/init_repo.sh @@ -47,7 +47,7 @@ function fetch_github_commit_archive { rm $cached } -included="src/llvm-project src/llvm-emscripten src/doc/book src/doc/rust-by-example" +included="src/llvm-project src/doc/book src/doc/rust-by-example" modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)" modules=($modules) use_git="" diff --git a/src/librustc_codegen_llvm/Cargo.toml b/src/librustc_codegen_llvm/Cargo.toml index 98efa6a5804..867bbd22cfb 100644 --- a/src/librustc_codegen_llvm/Cargo.toml +++ b/src/librustc_codegen_llvm/Cargo.toml @@ -12,9 +12,3 @@ test = false [dependencies] rustc_llvm = { path = "../librustc_llvm" } - -[features] -# This is used to convince Cargo to separately cache builds of `rustc_codegen_llvm` -# when this option is enabled or not. That way we can build two, cache two -# artifacts, and have nice speedy rebuilds. -emscripten = ["rustc_llvm/emscripten"] diff --git a/src/llvm-emscripten b/src/llvm-emscripten deleted file mode 160000 index 7f23313edff..00000000000 --- a/src/llvm-emscripten +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7f23313edff8beccb3fe44b815714269c5124c15 diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index c76cc4cff7f..d9db68ff66e 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -46,7 +46,6 @@ pub mod error_codes_check; fn filter_dirs(path: &Path) -> bool { let skip = [ - "src/llvm-emscripten", "src/llvm-project", "src/stdarch", "src/tools/cargo",