bootstrap: Allow to specify ranlib tool used when compiling C++ code.
This commit is contained in:
parent
758239c9c9
commit
80e27cdd02
4 changed files with 22 additions and 0 deletions
|
@ -388,6 +388,10 @@
|
||||||
# Note: an absolute path should be used, otherwise LLVM build will break.
|
# Note: an absolute path should be used, otherwise LLVM build will break.
|
||||||
#ar = "ar"
|
#ar = "ar"
|
||||||
|
|
||||||
|
# Ranlib to be used to assemble static libraries compiled from C/C++ code.
|
||||||
|
# Note: an absolute path should be used, otherwise LLVM build will break.
|
||||||
|
#ranlib = "ranlib"
|
||||||
|
|
||||||
# Linker to be used to link Rust code. Note that the
|
# Linker to be used to link Rust code. Note that the
|
||||||
# default value is platform specific, and if not specified it may also depend on
|
# default value is platform specific, and if not specified it may also depend on
|
||||||
# what platform is crossing to what platform.
|
# what platform is crossing to what platform.
|
||||||
|
|
|
@ -163,6 +163,7 @@ pub struct Target {
|
||||||
pub cc: Option<PathBuf>,
|
pub cc: Option<PathBuf>,
|
||||||
pub cxx: Option<PathBuf>,
|
pub cxx: Option<PathBuf>,
|
||||||
pub ar: Option<PathBuf>,
|
pub ar: Option<PathBuf>,
|
||||||
|
pub ranlib: Option<PathBuf>,
|
||||||
pub linker: Option<PathBuf>,
|
pub linker: Option<PathBuf>,
|
||||||
pub ndk: Option<PathBuf>,
|
pub ndk: Option<PathBuf>,
|
||||||
pub crt_static: Option<bool>,
|
pub crt_static: Option<bool>,
|
||||||
|
@ -327,6 +328,7 @@ struct TomlTarget {
|
||||||
cc: Option<String>,
|
cc: Option<String>,
|
||||||
cxx: Option<String>,
|
cxx: Option<String>,
|
||||||
ar: Option<String>,
|
ar: Option<String>,
|
||||||
|
ranlib: Option<String>,
|
||||||
linker: Option<String>,
|
linker: Option<String>,
|
||||||
android_ndk: Option<String>,
|
android_ndk: Option<String>,
|
||||||
crt_static: Option<bool>,
|
crt_static: Option<bool>,
|
||||||
|
@ -581,6 +583,7 @@ impl Config {
|
||||||
target.cc = cfg.cc.clone().map(PathBuf::from);
|
target.cc = cfg.cc.clone().map(PathBuf::from);
|
||||||
target.cxx = cfg.cxx.clone().map(PathBuf::from);
|
target.cxx = cfg.cxx.clone().map(PathBuf::from);
|
||||||
target.ar = cfg.ar.clone().map(PathBuf::from);
|
target.ar = cfg.ar.clone().map(PathBuf::from);
|
||||||
|
target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
|
||||||
target.linker = cfg.linker.clone().map(PathBuf::from);
|
target.linker = cfg.linker.clone().map(PathBuf::from);
|
||||||
target.crt_static = cfg.crt_static.clone();
|
target.crt_static = cfg.crt_static.clone();
|
||||||
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
|
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
|
||||||
|
|
|
@ -281,6 +281,7 @@ pub struct Build {
|
||||||
cc: HashMap<Interned<String>, cc::Tool>,
|
cc: HashMap<Interned<String>, cc::Tool>,
|
||||||
cxx: HashMap<Interned<String>, cc::Tool>,
|
cxx: HashMap<Interned<String>, cc::Tool>,
|
||||||
ar: HashMap<Interned<String>, PathBuf>,
|
ar: HashMap<Interned<String>, PathBuf>,
|
||||||
|
ranlib: HashMap<Interned<String>, PathBuf>,
|
||||||
// Misc
|
// Misc
|
||||||
crates: HashMap<Interned<String>, Crate>,
|
crates: HashMap<Interned<String>, Crate>,
|
||||||
is_sudo: bool,
|
is_sudo: bool,
|
||||||
|
@ -406,6 +407,7 @@ impl Build {
|
||||||
cc: HashMap::new(),
|
cc: HashMap::new(),
|
||||||
cxx: HashMap::new(),
|
cxx: HashMap::new(),
|
||||||
ar: HashMap::new(),
|
ar: HashMap::new(),
|
||||||
|
ranlib: HashMap::new(),
|
||||||
crates: HashMap::new(),
|
crates: HashMap::new(),
|
||||||
lldb_version: None,
|
lldb_version: None,
|
||||||
lldb_python_dir: None,
|
lldb_python_dir: None,
|
||||||
|
@ -772,6 +774,11 @@ impl Build {
|
||||||
self.ar.get(&target).map(|p| &**p)
|
self.ar.get(&target).map(|p| &**p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the path to the `ranlib` utility for the target specified.
|
||||||
|
fn ranlib(&self, target: Interned<String>) -> Option<&Path> {
|
||||||
|
self.ranlib.get(&target).map(|p| &**p)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the path to the C++ compiler for the target specified.
|
/// Returns the path to the C++ compiler for the target specified.
|
||||||
fn cxx(&self, target: Interned<String>) -> Result<&Path, String> {
|
fn cxx(&self, target: Interned<String>) -> Result<&Path, String> {
|
||||||
match self.cxx.get(&target) {
|
match self.cxx.get(&target) {
|
||||||
|
|
|
@ -379,6 +379,14 @@ fn configure_cmake(builder: &Builder,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(ranlib) = builder.ranlib(target) {
|
||||||
|
if ranlib.is_absolute() {
|
||||||
|
// LLVM build breaks if `CMAKE_RANLIB` is a relative path, for some reason it
|
||||||
|
// tries to resolve this path in the LLVM build directory.
|
||||||
|
cfg.define("CMAKE_RANLIB", sanitize_cc(ranlib));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if env::var_os("SCCACHE_ERROR_LOG").is_some() {
|
if env::var_os("SCCACHE_ERROR_LOG").is_some() {
|
||||||
cfg.env("RUST_LOG", "sccache=warn");
|
cfg.env("RUST_LOG", "sccache=warn");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue