Skip to content

Commit 0f8e931

Browse files
committed
rustbuild: allow overriding list of LLVM targets to build
A new option is introduced under the `[llvm]` section of `config.toml`, `targets`, for overriding the list of LLVM targets to build support for. The option is passed through to LLVM configure script. Also notes are added about the implications of (ab)using the option; since the default is not changed, and users of the option are expected to know what they're doing anyway (as every porter should), the impact should be minimal. Fixes #38200.
1 parent 371f4d6 commit 0f8e931

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

Diff for: src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub struct Config {
5454
pub llvm_version_check: bool,
5555
pub llvm_static_stdcpp: bool,
5656
pub llvm_link_shared: bool,
57+
pub llvm_targets: Option<String>,
5758

5859
// rust codegen options
5960
pub rust_optimize: bool,
@@ -152,6 +153,7 @@ struct Llvm {
152153
release_debuginfo: Option<bool>,
153154
version_check: Option<bool>,
154155
static_libstdcpp: Option<bool>,
156+
targets: Option<String>,
155157
}
156158

157159
#[derive(RustcDecodable)]
@@ -285,6 +287,7 @@ impl Config {
285287
set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);
286288
set(&mut config.llvm_version_check, llvm.version_check);
287289
set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
290+
config.llvm_targets = llvm.targets.clone();
288291
}
289292

290293
if let Some(ref rust) = toml.rust {

Diff for: src/bootstrap/config.toml.example

+11
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@
4242
# example.
4343
#ninja = false
4444

45+
# LLVM targets to build support for.
46+
# Note: this is NOT related to Rust compilation targets. However, as Rust is
47+
# dependent on LLVM for code generation, turning targets off here WILL lead to
48+
# the resulting rustc being unable to compile for the disabled architectures.
49+
# Also worth pointing out is that, in case support for new targets are added to
50+
# LLVM, enabling them here doesn't mean Rust is automatically gaining said
51+
# support. You'll need to write a target specification at least, and most
52+
# likely, teach rustc about the C ABI of the target. Get in touch with the
53+
# Rust team and file an issue if you need assistance in porting!
54+
#targets = "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc"
55+
4556
# =============================================================================
4657
# General build configuration options
4758
# =============================================================================

Diff for: src/bootstrap/native.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ pub fn llvm(build: &Build, target: &str) {
7575
(true, true) => "RelWithDebInfo",
7676
};
7777

78+
// NOTE: remember to also update `config.toml.example` when changing the defaults!
79+
let llvm_targets = match build.config.llvm_targets {
80+
Some(ref s) => s,
81+
None => "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc",
82+
};
83+
7884
cfg.target(target)
7985
.host(&build.config.build)
8086
.out_dir(&dst)
8187
.profile(profile)
8288
.define("LLVM_ENABLE_ASSERTIONS", assertions)
83-
.define("LLVM_TARGETS_TO_BUILD",
84-
"X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc")
89+
.define("LLVM_TARGETS_TO_BUILD", llvm_targets)
8590
.define("LLVM_INCLUDE_EXAMPLES", "OFF")
8691
.define("LLVM_INCLUDE_TESTS", "OFF")
8792
.define("LLVM_INCLUDE_DOCS", "OFF")

0 commit comments

Comments
 (0)