ship LLVM tools with the toolchain
This commit is contained in:
parent
7d576f25fc
commit
5e577b8aee
@ -347,6 +347,10 @@
|
||||
# rustc to execute.
|
||||
#lld = false
|
||||
|
||||
# Indicates whether some LLVM tools, like llvm-objdump, will be made available in the
|
||||
# sysroot.
|
||||
#llvm-tools = false
|
||||
|
||||
# Whether to deny warnings in crates
|
||||
#deny-warnings = true
|
||||
|
||||
|
@ -31,7 +31,7 @@ use filetime::FileTime;
|
||||
use serde_json;
|
||||
|
||||
use util::{exe, libdir, is_dylib, CiEnv};
|
||||
use {Compiler, Mode};
|
||||
use {Compiler, Mode, LLVM_TOOLS};
|
||||
use native;
|
||||
use tool;
|
||||
|
||||
@ -775,6 +775,23 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder,
|
||||
}
|
||||
}
|
||||
|
||||
fn copy_llvm_tools_to_sysroot(builder: &Builder,
|
||||
target_compiler: Compiler) {
|
||||
let target = target_compiler.host;
|
||||
|
||||
let dst = builder.sysroot_libdir(target_compiler, target)
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join("bin");
|
||||
t!(fs::create_dir_all(&dst));
|
||||
|
||||
let src = builder.llvm_out(target).join("bin");
|
||||
for tool in LLVM_TOOLS {
|
||||
let exe = exe(tool, &target);
|
||||
builder.copy(&src.join(&exe), &dst.join(&exe));
|
||||
}
|
||||
}
|
||||
|
||||
fn copy_lld_to_sysroot(builder: &Builder,
|
||||
target_compiler: Compiler,
|
||||
lld_install_root: &Path) {
|
||||
@ -966,6 +983,9 @@ impl Step for Assemble {
|
||||
copy_codegen_backends_to_sysroot(builder,
|
||||
build_compiler,
|
||||
target_compiler);
|
||||
if builder.config.ship_llvm_tools {
|
||||
copy_llvm_tools_to_sysroot(builder, target_compiler);
|
||||
}
|
||||
if let Some(lld_install) = lld_install {
|
||||
copy_lld_to_sysroot(builder, target_compiler, &lld_install);
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ pub struct Config {
|
||||
pub llvm_link_jobs: Option<u32>,
|
||||
|
||||
pub lld_enabled: bool,
|
||||
pub ship_llvm_tools: bool,
|
||||
|
||||
// rust codegen options
|
||||
pub rust_optimize: bool,
|
||||
@ -308,6 +309,7 @@ struct Rust {
|
||||
codegen_backends_dir: Option<String>,
|
||||
wasm_syscall: Option<bool>,
|
||||
lld: Option<bool>,
|
||||
llvm_tools: Option<bool>,
|
||||
deny_warnings: Option<bool>,
|
||||
backtrace_on_ice: Option<bool>,
|
||||
}
|
||||
@ -531,6 +533,7 @@ impl Config {
|
||||
set(&mut config.test_miri, rust.test_miri);
|
||||
set(&mut config.wasm_syscall, rust.wasm_syscall);
|
||||
set(&mut config.lld_enabled, rust.lld);
|
||||
set(&mut config.ship_llvm_tools, rust.llvm_tools);
|
||||
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false);
|
||||
config.rustc_default_linker = rust.default_linker.clone();
|
||||
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
|
||||
|
@ -335,6 +335,7 @@ for key in known_args:
|
||||
elif option.name == 'full-tools':
|
||||
set('rust.codegen-backends', ['llvm', 'emscripten'])
|
||||
set('rust.lld', True)
|
||||
set('rust.llvm-tools', True)
|
||||
set('build.extended', True)
|
||||
elif option.name == 'option-checking':
|
||||
# this was handled above
|
||||
|
@ -26,7 +26,7 @@ use std::process::{Command, Stdio};
|
||||
|
||||
use build_helper::output;
|
||||
|
||||
use {Compiler, Mode};
|
||||
use {Compiler, Mode, LLVM_TOOLS};
|
||||
use channel;
|
||||
use util::{libdir, is_dylib, exe};
|
||||
use builder::{Builder, RunConfig, ShouldRun, Step};
|
||||
@ -503,6 +503,24 @@ impl Step for Rustc {
|
||||
builder.copy(&src, &dst);
|
||||
}
|
||||
|
||||
if builder.config.ship_llvm_tools {
|
||||
let src = builder.sysroot_libdir(compiler, host)
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join("bin");
|
||||
|
||||
let dst = image.join("lib/rustlib")
|
||||
.join(&*host)
|
||||
.join("bin");
|
||||
|
||||
t!(fs::create_dir_all(&dst.parent().unwrap()));
|
||||
|
||||
for tool in LLVM_TOOLS {
|
||||
let exe = exe(tool, &compiler.host);
|
||||
builder.copy(&src.join(&exe), &dst.join(&exe));
|
||||
}
|
||||
}
|
||||
|
||||
// Man pages
|
||||
t!(fs::create_dir_all(image.join("share/man/man1")));
|
||||
let man_src = builder.src.join("src/doc/man");
|
||||
|
@ -199,6 +199,8 @@ use flags::Subcommand;
|
||||
use cache::{Interned, INTERNER};
|
||||
use toolstate::ToolState;
|
||||
|
||||
const LLVM_TOOLS: &[&str] = &["llvm-nm", "llvm-objcopy", "llvm-objdump", "llvm-size"];
|
||||
|
||||
/// A structure representing a Rust compiler.
|
||||
///
|
||||
/// Each compiler has a `stage` that it is associated with and a `host` that
|
||||
|
@ -167,8 +167,11 @@ impl Step for Llvm {
|
||||
// which saves both memory during parallel links and overall disk space
|
||||
// for the tools. We don't distribute any of those tools, so this is
|
||||
// just a local concern. However, it doesn't work well everywhere.
|
||||
if target.contains("linux-gnu") || target.contains("apple-darwin") {
|
||||
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
|
||||
//
|
||||
// If we are shipping llvm tools then we statically link them LLVM
|
||||
if (target.contains("linux-gnu") || target.contains("apple-darwin")) &&
|
||||
!builder.config.ship_llvm_tools {
|
||||
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
|
||||
}
|
||||
|
||||
if target.contains("msvc") {
|
||||
|
Loading…
Reference in New Issue
Block a user