From 0f8e931475b1f7864504f509b389d28e1ffbc93a Mon Sep 17 00:00:00 2001 From: Wang Xuerui Date: Thu, 29 Dec 2016 02:23:38 +0800 Subject: [PATCH] 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. --- src/bootstrap/config.rs | 3 +++ src/bootstrap/config.toml.example | 11 +++++++++++ src/bootstrap/native.rs | 9 +++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 6b86e537b7d22..7e576175c3541 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -54,6 +54,7 @@ pub struct Config { pub llvm_version_check: bool, pub llvm_static_stdcpp: bool, pub llvm_link_shared: bool, + pub llvm_targets: Option, // rust codegen options pub rust_optimize: bool, @@ -152,6 +153,7 @@ struct Llvm { release_debuginfo: Option, version_check: Option, static_libstdcpp: Option, + targets: Option, } #[derive(RustcDecodable)] @@ -285,6 +287,7 @@ impl Config { set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo); set(&mut config.llvm_version_check, llvm.version_check); set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp); + config.llvm_targets = llvm.targets.clone(); } if let Some(ref rust) = toml.rust { diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index 5fc095137c793..25f668f6e473e 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -42,6 +42,17 @@ # example. #ninja = false +# LLVM targets to build support for. +# Note: this is NOT related to Rust compilation targets. However, as Rust is +# dependent on LLVM for code generation, turning targets off here WILL lead to +# the resulting rustc being unable to compile for the disabled architectures. +# Also worth pointing out is that, in case support for new targets are added to +# LLVM, enabling them here doesn't mean Rust is automatically gaining said +# support. You'll need to write a target specification at least, and most +# likely, teach rustc about the C ABI of the target. Get in touch with the +# Rust team and file an issue if you need assistance in porting! +#targets = "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc" + # ============================================================================= # General build configuration options # ============================================================================= diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 09dbd9f8220b0..d3fa54e417ac2 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -75,13 +75,18 @@ pub fn llvm(build: &Build, target: &str) { (true, true) => "RelWithDebInfo", }; + // NOTE: remember to also update `config.toml.example` when changing the defaults! + let llvm_targets = match build.config.llvm_targets { + Some(ref s) => s, + None => "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc", + }; + cfg.target(target) .host(&build.config.build) .out_dir(&dst) .profile(profile) .define("LLVM_ENABLE_ASSERTIONS", assertions) - .define("LLVM_TARGETS_TO_BUILD", - "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc") + .define("LLVM_TARGETS_TO_BUILD", llvm_targets) .define("LLVM_INCLUDE_EXAMPLES", "OFF") .define("LLVM_INCLUDE_TESTS", "OFF") .define("LLVM_INCLUDE_DOCS", "OFF")