Skip to content

Commit b447ad7

Browse files
bootstrap: Allow to specify ranlib tool used when compiling C++ code.
1 parent a8b2da3 commit b447ad7

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/bootstrap/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ pub struct Target {
161161
pub cc: Option<PathBuf>,
162162
pub cxx: Option<PathBuf>,
163163
pub ar: Option<PathBuf>,
164+
pub ranlib: Option<PathBuf>,
164165
pub linker: Option<PathBuf>,
165166
pub ndk: Option<PathBuf>,
166167
pub crt_static: Option<bool>,
@@ -321,6 +322,7 @@ struct TomlTarget {
321322
cc: Option<String>,
322323
cxx: Option<String>,
323324
ar: Option<String>,
325+
ranlib: Option<String>,
324326
linker: Option<String>,
325327
android_ndk: Option<String>,
326328
crt_static: Option<bool>,
@@ -569,6 +571,7 @@ impl Config {
569571
target.cc = cfg.cc.clone().map(PathBuf::from);
570572
target.cxx = cfg.cxx.clone().map(PathBuf::from);
571573
target.ar = cfg.ar.clone().map(PathBuf::from);
574+
target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
572575
target.linker = cfg.linker.clone().map(PathBuf::from);
573576
target.crt_static = cfg.crt_static.clone();
574577
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);

src/bootstrap/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ pub struct Build {
265265
cc: HashMap<Interned<String>, cc::Tool>,
266266
cxx: HashMap<Interned<String>, cc::Tool>,
267267
ar: HashMap<Interned<String>, PathBuf>,
268+
ranlib: HashMap<Interned<String>, PathBuf>,
268269
// Misc
269270
crates: HashMap<Interned<String>, Crate>,
270271
is_sudo: bool,
@@ -366,6 +367,7 @@ impl Build {
366367
cc: HashMap::new(),
367368
cxx: HashMap::new(),
368369
ar: HashMap::new(),
370+
ranlib: HashMap::new(),
369371
crates: HashMap::new(),
370372
lldb_version: None,
371373
lldb_python_dir: None,
@@ -725,6 +727,11 @@ impl Build {
725727
self.ar.get(&target).map(|p| &**p)
726728
}
727729

730+
/// Returns the path to the `ranlib` utility for the target specified.
731+
fn ranlib(&self, target: Interned<String>) -> Option<&Path> {
732+
self.ranlib.get(&target).map(|p| &**p)
733+
}
734+
728735
/// Returns the path to the C++ compiler for the target specified.
729736
fn cxx(&self, target: Interned<String>) -> Result<&Path, String> {
730737
match self.cxx.get(&target) {

src/bootstrap/native.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,14 @@ fn configure_cmake(builder: &Builder,
352352
}
353353
}
354354

355+
if let Some(ranlib) = builder.ranlib(target) {
356+
if ranlib.is_absolute() {
357+
// LLVM build breaks if `CMAKE_RANLIB` is a relative path, for some reason it
358+
// tries to resolve this path in the LLVM build directory.
359+
cfg.define("CMAKE_RANLIB", sanitize_cc(ranlib));
360+
}
361+
}
362+
355363
if env::var_os("SCCACHE_ERROR_LOG").is_some() {
356364
cfg.env("RUST_LOG", "sccache=warn");
357365
}

0 commit comments

Comments
 (0)