Skip to content

Commit 825cf51

Browse files
committed
Auto merge of #71486 - alexcrichton:arm64-lld, r=Mark-Simulacrum
Enable "full tools" option on ARM dist builders This commit switches the `--enable-extended` option on the arm-related dist builders to `--enable-full-tools`. This alias in `config.py` corresponds to enabling a few more options: * `rust.lld = true` - this is the main purpose of this PR, to enable LLD on ARM-related platforms. This means it will effectively unlock compilation of wasm programs from an arm host. * `rust.llvm-tools = true` - it turns out that this option is largely ignored in rustbuild today. This is only read in one location to set some flags for the `llvm-tools` package, but the `llvm-tools` package is already produced on all of these builders. It's predicted that this will have no effect on build times. * `rust.codegen-backends = ['llvm']` - historically this also enabled the emscripten backend, but that has long since been removed. This brings the ARM dist builders in line with the x86_64 dist builders using this flag. The hope is that the extra time spent on CI building LLD will acceptable because it's cached by `sccache`, LLD is a relatively small C++ project, and the dist builders are all clocking well under 3 hours (the slowest of all builders) around 2 hours. There's likely some possible cleanup that can happen with these configure options since it doesn't look like they've aged too too well, but I'm hopeful that possible refactorings, if necessary, could be deferred to future PRs.
2 parents 6470169 + 0546d11 commit 825cf51

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

src/bootstrap/bin/llvm-config-wrapper.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ fn main() {
1010
let mut cmd = Command::new(real_llvm_config);
1111
cmd.args(env::args().skip(1)).stderr(Stdio::piped());
1212
let output = cmd.output().expect("failed to spawn llvm-config");
13-
let stdout = String::from_utf8_lossy(&output.stdout);
13+
let mut stdout = String::from_utf8_lossy(&output.stdout);
14+
15+
if let Ok(to_replace) = env::var("LLVM_CONFIG_SHIM_REPLACE") {
16+
if let Ok(replace_with) = env::var("LLVM_CONFIG_SHIM_REPLACE_WITH") {
17+
stdout = stdout.replace(&to_replace, &replace_with).into();
18+
}
19+
}
20+
1421
print!("{}", stdout.replace("\\", "/"));
1522
io::stdout().flush().unwrap();
1623
process::exit(output.status.code().unwrap_or(1));

src/bootstrap/native.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,29 @@ impl Step for Lld {
479479
let llvm_config_shim = env::current_exe().unwrap().with_file_name("llvm-config-wrapper");
480480
cfg.out_dir(&out_dir)
481481
.profile("Release")
482-
.env("LLVM_CONFIG_REAL", llvm_config)
482+
.env("LLVM_CONFIG_REAL", &llvm_config)
483483
.define("LLVM_CONFIG_PATH", llvm_config_shim)
484484
.define("LLVM_INCLUDE_TESTS", "OFF");
485485

486+
// While we're using this horrible workaround to shim the execution of
487+
// llvm-config, let's just pile on more. I can't seem to figure out how
488+
// to build LLD as a standalone project and also cross-compile it at the
489+
// same time. It wants a natively executable `llvm-config` to learn
490+
// about LLVM, but then it learns about all the host configuration of
491+
// LLVM and tries to link to host LLVM libraries.
492+
//
493+
// To work around that we tell our shim to replace anything with the
494+
// build target with the actual target instead. This'll break parts of
495+
// LLD though which try to execute host tools, such as llvm-tblgen, so
496+
// we specifically tell it where to find those. This is likely super
497+
// brittle and will break over time. If anyone knows better how to
498+
// cross-compile LLD it would be much appreciated to fix this!
499+
if target != builder.config.build {
500+
cfg.env("LLVM_CONFIG_SHIM_REPLACE", &builder.config.build)
501+
.env("LLVM_CONFIG_SHIM_REPLACE_WITH", &target)
502+
.define("LLVM_TABLEGEN_EXE", llvm_config.with_file_name("llvm-tblgen"));
503+
}
504+
486505
cfg.build();
487506

488507
t!(File::create(&done_stamp));

src/ci/docker/dist-aarch64-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ENV CC_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnueabi-gcc \
3333
ENV HOSTS=aarch64-unknown-linux-gnu
3434

3535
ENV RUST_CONFIGURE_ARGS \
36-
--enable-extended \
36+
--enable-full-tools \
3737
--enable-profiler \
3838
--disable-docs
3939
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-arm-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ ENV CC_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-gcc \
2727

2828
ENV HOSTS=arm-unknown-linux-gnueabi
2929

30-
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
30+
ENV RUST_CONFIGURE_ARGS --enable-full-tools --disable-docs
3131
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-armhf-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ ENV CC_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-gcc \
2727

2828
ENV HOSTS=arm-unknown-linux-gnueabihf
2929

30-
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
30+
ENV RUST_CONFIGURE_ARGS --enable-full-tools --disable-docs
3131
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/dist-armv7-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ ENV CC_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-gcc \
2727

2828
ENV HOSTS=armv7-unknown-linux-gnueabihf
2929

30-
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
30+
ENV RUST_CONFIGURE_ARGS --enable-full-tools --disable-docs
3131
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

0 commit comments

Comments
 (0)