提交 c7d285b7 编写于 作者: A Alex Crichton

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.
上级 b7a9c285
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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<String>,
backend: Interned<String>) -> 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
......
......@@ -668,7 +668,6 @@ pub fn very_verbose(&self) -> bool {
pub fn llvm_enabled(&self) -> bool {
self.rust_codegen_backends.contains(&INTERNER.intern_str("llvm"))
|| self.rust_codegen_backends.contains(&INTERNER.intern_str("emscripten"))
}
}
......
......@@ -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)
......
......@@ -826,7 +826,6 @@ fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool {
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 filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool {
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)) {
......
......@@ -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 @@ pub fn new(config: Config) -> 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 @@ pub fn new(config: Config) -> 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 @@ fn llvm_out(&self, target: Interned<String>) -> PathBuf {
self.out.join(&*target).join("llvm")
}
fn emscripten_llvm_out(&self, target: Interned<String>) -> PathBuf {
self.out.join(&*target).join("llvm-emscripten")
}
fn lld_out(&self, target: Interned<String>) -> PathBuf {
self.out.join(&*target).join("lld")
}
......
......@@ -28,7 +28,6 @@
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Llvm {
pub target: Interned<String>,
pub emscripten: bool,
}
impl Step for Llvm {
......@@ -40,46 +39,35 @@ fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
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 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
}
}
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 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
// 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 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
.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 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
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 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
}
// 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 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
let llvm_config = builder.ensure(Llvm {
target: self.target,
emscripten: false,
});
let out_dir = builder.lld_out(target);
......
......@@ -1163,7 +1163,7 @@ fn run(self, builder: &Builder<'_>) {
}).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 @@ fn run(self, builder: &Builder<'_>) {
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"));
......
......@@ -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 \
......
......@@ -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=""
......
......@@ -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"]
Subproject commit 7f23313edff8beccb3fe44b815714269c5124c15
......@@ -46,7 +46,6 @@
fn filter_dirs(path: &Path) -> bool {
let skip = [
"src/llvm-emscripten",
"src/llvm-project",
"src/stdarch",
"src/tools/cargo",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册