Skip to content

Commit 50ffa79

Browse files
committed
Auto merge of #65501 - alexcrichton:remove-emscripten-backend, r=Mark-Simulacrum
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.
2 parents 6576f4b + c7d285b commit 50ffa79

File tree

15 files changed

+36
-109
lines changed

15 files changed

+36
-109
lines changed

Diff for: .gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
[submodule "src/doc/rust-by-example"]
2929
path = src/doc/rust-by-example
3030
url = https://github.com/rust-lang/rust-by-example.git
31-
[submodule "src/llvm-emscripten"]
32-
path = src/llvm-emscripten
33-
url = https://github.com/rust-lang/llvm.git
3431
[submodule "src/stdarch"]
3532
path = src/stdarch
3633
url = https://github.com/rust-lang/stdarch.git

Diff for: config.toml.example

+1-4
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,7 @@
374374

375375
# This is an array of the codegen backends that will be compiled for the rustc
376376
# that's being compiled. The default is to only build the LLVM codegen backend,
377-
# but you can also optionally enable the "emscripten" backend for asm.js or
378-
# make this an empty array (but that probably won't get too far in the
379-
# bootstrap)
380-
# FIXME: remove the obsolete emscripten backend option.
377+
# and currently the only standard option supported is `"llvm"`
381378
#codegen-backends = ["llvm"]
382379

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

Diff for: src/bootstrap/bootstrap.py

-4
Original file line numberDiff line numberDiff line change
@@ -734,10 +734,6 @@ def update_submodules(self):
734734
if module.endswith("llvm-project"):
735735
if self.get_toml('llvm-config') and self.get_toml('lld') != 'true':
736736
continue
737-
if module.endswith("llvm-emscripten"):
738-
backends = self.get_toml('codegen-backends')
739-
if backends is None or not 'emscripten' in backends:
740-
continue
741737
check = self.check_submodule(module, slow_submodules)
742738
filtered_submodules.append((module, check))
743739
submodules_names.append(module)

Diff for: src/bootstrap/compile.rs

+7-20
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ pub fn std_cargo(builder: &Builder<'_>,
210210
// config.toml equivalent) is used
211211
let llvm_config = builder.ensure(native::Llvm {
212212
target: builder.config.build,
213-
emscripten: false,
214213
});
215214
cargo.env("LLVM_CONFIG", llvm_config);
216215
cargo.env("RUSTC_BUILD_SANITIZERS", "1");
@@ -615,36 +614,27 @@ pub fn build_codegen_backend(builder: &Builder<'_>,
615614
compiler: &Compiler,
616615
target: Interned<String>,
617616
backend: Interned<String>) -> String {
618-
let mut features = String::new();
619-
620617
match &*backend {
621-
"llvm" | "emscripten" => {
618+
"llvm" => {
622619
// Build LLVM for our target. This will implicitly build the
623620
// host LLVM if necessary.
624621
let llvm_config = builder.ensure(native::Llvm {
625622
target,
626-
emscripten: backend == "emscripten",
627623
});
628624

629-
if backend == "emscripten" {
630-
features.push_str(" emscripten");
631-
}
632-
633625
builder.info(&format!("Building stage{} codegen artifacts ({} -> {}, {})",
634626
compiler.stage, &compiler.host, target, backend));
635627

636628
// Pass down configuration from the LLVM build into the build of
637629
// librustc_llvm and librustc_codegen_llvm.
638-
if builder.is_rust_llvm(target) && backend != "emscripten" {
630+
if builder.is_rust_llvm(target) {
639631
cargo.env("LLVM_RUSTLLVM", "1");
640632
}
641633

642634
cargo.env("LLVM_CONFIG", &llvm_config);
643-
if backend != "emscripten" {
644-
let target_config = builder.config.target_config.get(&target);
645-
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
646-
cargo.env("CFG_LLVM_ROOT", s);
647-
}
635+
let target_config = builder.config.target_config.get(&target);
636+
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
637+
cargo.env("CFG_LLVM_ROOT", s);
648638
}
649639
// Some LLVM linker flags (-L and -l) may be needed to link librustc_llvm.
650640
if let Some(ref s) = builder.config.llvm_ldflags {
@@ -662,9 +652,7 @@ pub fn build_codegen_backend(builder: &Builder<'_>,
662652
"libstdc++.a");
663653
cargo.env("LLVM_STATIC_STDCPP", file);
664654
}
665-
if builder.config.llvm_link_shared ||
666-
(builder.config.llvm_thin_lto && backend != "emscripten")
667-
{
655+
if builder.config.llvm_link_shared || builder.config.llvm_thin_lto {
668656
cargo.env("LLVM_LINK_SHARED", "1");
669657
}
670658
if builder.config.llvm_use_libcxx {
@@ -676,8 +664,7 @@ pub fn build_codegen_backend(builder: &Builder<'_>,
676664
}
677665
_ => panic!("unknown backend: {}", backend),
678666
}
679-
680-
features
667+
String::new()
681668
}
682669

683670
/// Creates the `codegen-backends` folder for a compiler that's about to be

Diff for: src/bootstrap/config.rs

-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ impl Config {
668668

669669
pub fn llvm_enabled(&self) -> bool {
670670
self.rust_codegen_backends.contains(&INTERNER.intern_str("llvm"))
671-
|| self.rust_codegen_backends.contains(&INTERNER.intern_str("emscripten"))
672671
}
673672
}
674673

Diff for: src/bootstrap/configure.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def v(*args):
5555
o("dist-src", "rust.dist-src", "when building tarballs enables building a source tarball")
5656
o("cargo-native-static", "build.cargo-native-static", "static native libraries in cargo")
5757
o("profiler", "build.profiler", "build the profiler runtime")
58-
o("emscripten", None, "compile the emscripten backend as well as LLVM")
5958
o("full-tools", None, "enable all tools")
6059
o("lld", "rust.lld", "build lld")
6160
o("lldb", "rust.lldb", "build lldb")
@@ -335,10 +334,8 @@ def set(key, value):
335334
set('build.host', value.split(','))
336335
elif option.name == 'target':
337336
set('build.target', value.split(','))
338-
elif option.name == 'emscripten':
339-
set('rust.codegen-backends', ['llvm', 'emscripten'])
340337
elif option.name == 'full-tools':
341-
set('rust.codegen-backends', ['llvm', 'emscripten'])
338+
set('rust.codegen-backends', ['llvm'])
342339
set('rust.lld', True)
343340
set('rust.llvm-tools', True)
344341
set('build.extended', True)

Diff for: src/bootstrap/dist.rs

-4
Original file line numberDiff line numberDiff line change
@@ -826,17 +826,13 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str]
826826

827827
const LLVM_TEST: &[&str] = &[
828828
"llvm-project/llvm/test", "llvm-project\\llvm\\test",
829-
"llvm-emscripten/test", "llvm-emscripten\\test",
830829
];
831830
if LLVM_TEST.iter().any(|path| spath.contains(path)) &&
832831
(spath.ends_with(".ll") ||
833832
spath.ends_with(".td") ||
834833
spath.ends_with(".s")) {
835834
return false
836835
}
837-
if spath.contains("test/emscripten") || spath.contains("test\\emscripten") {
838-
return false
839-
}
840836

841837
let full_path = Path::new(dir).join(path);
842838
if exclude_dirs.iter().any(|excl| full_path == Path::new(excl)) {

Diff for: src/bootstrap/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ pub struct Build {
232232
miri_info: channel::GitInfo,
233233
rustfmt_info: channel::GitInfo,
234234
in_tree_llvm_info: channel::GitInfo,
235-
emscripten_llvm_info: channel::GitInfo,
236235
local_rebuild: bool,
237236
fail_fast: bool,
238237
doc_tests: DocTests,
@@ -351,7 +350,6 @@ impl Build {
351350

352351
// we always try to use git for LLVM builds
353352
let in_tree_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-project"));
354-
let emscripten_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-emscripten"));
355353

356354
let mut build = Build {
357355
initial_rustc: config.initial_rustc.clone(),
@@ -376,7 +374,6 @@ impl Build {
376374
miri_info,
377375
rustfmt_info,
378376
in_tree_llvm_info,
379-
emscripten_llvm_info,
380377
cc: HashMap::new(),
381378
cxx: HashMap::new(),
382379
ar: HashMap::new(),
@@ -553,10 +550,6 @@ impl Build {
553550
self.out.join(&*target).join("llvm")
554551
}
555552

556-
fn emscripten_llvm_out(&self, target: Interned<String>) -> PathBuf {
557-
self.out.join(&*target).join("llvm-emscripten")
558-
}
559-
560553
fn lld_out(&self, target: Interned<String>) -> PathBuf {
561554
self.out.join(&*target).join("lld")
562555
}

Diff for: src/bootstrap/native.rs

+25-50
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use crate::GitRepo;
2828
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
2929
pub struct Llvm {
3030
pub target: Interned<String>,
31-
pub emscripten: bool,
3231
}
3332

3433
impl Step for Llvm {
@@ -40,46 +39,35 @@ impl Step for Llvm {
4039
run.path("src/llvm-project")
4140
.path("src/llvm-project/llvm")
4241
.path("src/llvm")
43-
.path("src/llvm-emscripten")
4442
}
4543

4644
fn make_run(run: RunConfig<'_>) {
47-
let emscripten = run.path.ends_with("llvm-emscripten");
4845
run.builder.ensure(Llvm {
4946
target: run.target,
50-
emscripten,
5147
});
5248
}
5349

5450
/// Compile LLVM for `target`.
5551
fn run(self, builder: &Builder<'_>) -> PathBuf {
5652
let target = self.target;
57-
let emscripten = self.emscripten;
5853

5954
// If we're using a custom LLVM bail out here, but we can only use a
6055
// custom LLVM for the build triple.
61-
if !self.emscripten {
62-
if let Some(config) = builder.config.target_config.get(&target) {
63-
if let Some(ref s) = config.llvm_config {
64-
check_llvm_version(builder, s);
65-
return s.to_path_buf()
66-
}
56+
if let Some(config) = builder.config.target_config.get(&target) {
57+
if let Some(ref s) = config.llvm_config {
58+
check_llvm_version(builder, s);
59+
return s.to_path_buf()
6760
}
6861
}
6962

70-
let (llvm_info, root, out_dir, llvm_config_ret_dir) = if emscripten {
71-
let info = &builder.emscripten_llvm_info;
72-
let dir = builder.emscripten_llvm_out(target);
73-
let config_dir = dir.join("bin");
74-
(info, "src/llvm-emscripten", dir, config_dir)
75-
} else {
76-
let info = &builder.in_tree_llvm_info;
77-
let mut dir = builder.llvm_out(builder.config.build);
78-
if !builder.config.build.contains("msvc") || builder.config.ninja {
79-
dir.push("build");
80-
}
81-
(info, "src/llvm-project/llvm", builder.llvm_out(target), dir.join("bin"))
82-
};
63+
let llvm_info = &builder.in_tree_llvm_info;
64+
let root = "src/llvm-project/llvm";
65+
let out_dir = builder.llvm_out(target);
66+
let mut llvm_config_ret_dir = builder.llvm_out(builder.config.build);
67+
if !builder.config.build.contains("msvc") || builder.config.ninja {
68+
llvm_config_ret_dir.push("build");
69+
}
70+
llvm_config_ret_dir.push("bin");
8371

8472
let build_llvm_config = llvm_config_ret_dir
8573
.join(exe("llvm-config", &*builder.config.build));
@@ -107,8 +95,7 @@ impl Step for Llvm {
10795
}
10896
}
10997

110-
let descriptor = if emscripten { "Emscripten " } else { "" };
111-
builder.info(&format!("Building {}LLVM for {}", descriptor, target));
98+
builder.info(&format!("Building LLVM for {}", target));
11299
let _time = util::timeit(&builder);
113100
t!(fs::create_dir_all(&out_dir));
114101

@@ -123,23 +110,15 @@ impl Step for Llvm {
123110

124111
// NOTE: remember to also update `config.toml.example` when changing the
125112
// defaults!
126-
let llvm_targets = if self.emscripten {
127-
"JSBackend"
128-
} else {
129-
match builder.config.llvm_targets {
130-
Some(ref s) => s,
131-
None => "AArch64;ARM;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;\
132-
Sparc;SystemZ;WebAssembly;X86",
133-
}
113+
let llvm_targets = match &builder.config.llvm_targets {
114+
Some(s) => s,
115+
None => "AArch64;ARM;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;\
116+
Sparc;SystemZ;WebAssembly;X86",
134117
};
135118

136-
let llvm_exp_targets = if self.emscripten {
137-
""
138-
} else {
139-
match builder.config.llvm_experimental_targets {
140-
Some(ref s) => s,
141-
None => "",
142-
}
119+
let llvm_exp_targets = match builder.config.llvm_experimental_targets {
120+
Some(ref s) => s,
121+
None => "",
143122
};
144123

145124
let assertions = if builder.config.llvm_assertions {"ON"} else {"OFF"};
@@ -163,25 +142,23 @@ impl Step for Llvm {
163142
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
164143
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);
165144

166-
if builder.config.llvm_thin_lto && !emscripten {
145+
if builder.config.llvm_thin_lto {
167146
cfg.define("LLVM_ENABLE_LTO", "Thin");
168147
if !target.contains("apple") {
169148
cfg.define("LLVM_ENABLE_LLD", "ON");
170149
}
171150
}
172151

173-
let want_lldb = builder.config.lldb_enabled && !self.emscripten;
174-
175152
// This setting makes the LLVM tools link to the dynamic LLVM library,
176153
// which saves both memory during parallel links and overall disk space
177154
// for the tools. We don't do this on every platform as it doesn't work
178155
// equally well everywhere.
179-
if builder.llvm_link_tools_dynamically(target) && !emscripten {
156+
if builder.llvm_link_tools_dynamically(target) {
180157
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
181158
}
182159

183160
// For distribution we want the LLVM tools to be *statically* linked to libstdc++
184-
if builder.config.llvm_tools_enabled || want_lldb {
161+
if builder.config.llvm_tools_enabled || builder.config.lldb_enabled {
185162
if !target.contains("windows") {
186163
if target.contains("apple") {
187164
cfg.define("CMAKE_EXE_LINKER_FLAGS", "-static-libstdc++");
@@ -209,7 +186,7 @@ impl Step for Llvm {
209186
enabled_llvm_projects.push("compiler-rt");
210187
}
211188

212-
if want_lldb {
189+
if builder.config.lldb_enabled {
213190
enabled_llvm_projects.push("clang");
214191
enabled_llvm_projects.push("lldb");
215192
// For the time being, disable code signing.
@@ -234,10 +211,9 @@ impl Step for Llvm {
234211
}
235212

236213
// http://llvm.org/docs/HowToCrossCompileLLVM.html
237-
if target != builder.config.build && !emscripten {
214+
if target != builder.config.build {
238215
builder.ensure(Llvm {
239216
target: builder.config.build,
240-
emscripten: false,
241217
});
242218
// FIXME: if the llvm root for the build triple is overridden then we
243219
// should use llvm-tblgen from there, also should verify that it
@@ -481,7 +457,6 @@ impl Step for Lld {
481457

482458
let llvm_config = builder.ensure(Llvm {
483459
target: self.target,
484-
emscripten: false,
485460
});
486461

487462
let out_dir = builder.lld_out(target);

Diff for: src/bootstrap/test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ impl Step for Compiletest {
11631163
}).to_string()
11641164
})
11651165
};
1166-
let lldb_exe = if builder.config.lldb_enabled && !target.contains("emscripten") {
1166+
let lldb_exe = if builder.config.lldb_enabled {
11671167
// Test against the lldb that was just built.
11681168
builder.llvm_out(target).join("bin").join("lldb")
11691169
} else {
@@ -1232,7 +1232,6 @@ impl Step for Compiletest {
12321232
if builder.config.llvm_enabled() {
12331233
let llvm_config = builder.ensure(native::Llvm {
12341234
target: builder.config.build,
1235-
emscripten: false,
12361235
});
12371236
if !builder.config.dry_run {
12381237
let llvm_version = output(Command::new(&llvm_config).arg("--version"));

Diff for: src/ci/docker/dist-various-1/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ ENV RUST_CONFIGURE_ARGS \
139139
--musl-root-aarch64=/musl-aarch64 \
140140
--musl-root-mips=/musl-mips \
141141
--musl-root-mipsel=/musl-mipsel \
142-
--enable-emscripten \
143142
--disable-docs
144143

145144
ENV SCRIPT \

Diff for: src/ci/init_repo.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function fetch_github_commit_archive {
4747
rm $cached
4848
}
4949

50-
included="src/llvm-project src/llvm-emscripten src/doc/book src/doc/rust-by-example"
50+
included="src/llvm-project src/doc/book src/doc/rust-by-example"
5151
modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
5252
modules=($modules)
5353
use_git=""

Diff for: src/librustc_codegen_llvm/Cargo.toml

-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,3 @@ test = false
1212

1313
[dependencies]
1414
rustc_llvm = { path = "../librustc_llvm" }
15-
16-
[features]
17-
# This is used to convince Cargo to separately cache builds of `rustc_codegen_llvm`
18-
# when this option is enabled or not. That way we can build two, cache two
19-
# artifacts, and have nice speedy rebuilds.
20-
emscripten = ["rustc_llvm/emscripten"]

Diff for: src/llvm-emscripten

-1
This file was deleted.

0 commit comments

Comments
 (0)