Skip to content

Commit dc2fffe

Browse files
authored
Add LLDB_LIB_PATH for overriding --libdir (#23)
Some systems are note FHS compliant and therefore do not store liblldb.so in llvm-config's libdir folder. This commit allows users to override the libdir path when searching for the library.
1 parent a52a88a commit dc2fffe

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

build.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,22 @@ fn get_compiler_config() -> Build {
4646
// We use the `llvm-config` utility to get the include and library paths
4747
// as well as the name of the shared library.
4848
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
49+
println!("cargo:rerun-if-env-changed=LLDB_LIB_PATH");
4950
println!("cargo:rerun-if-env-changed=LLDB_ADDITIONAL_INCLUDE_DIRS");
5051
let llvm_headers_path = get_llvm_output("--includedir");
5152
let llvm_lib_path = get_llvm_output("--libdir");
52-
let lib_name = fs::read_dir(&llvm_lib_path)
53+
54+
// Some systems (ex. NixOS) do not have liblldb.so in llvm-config's libdir.
55+
// As a workaround, allow users to specifiy path to search
56+
// for the aforementioned library.
57+
let lldb_lib_path = match std::env::var_os("LLDB_LIB_PATH") {
58+
Some(path) => &path
59+
.into_string()
60+
.expect("LLDB_LIB_PATH contains invalid Unicode data"),
61+
None => &llvm_lib_path,
62+
};
63+
64+
let lib_name = fs::read_dir(lldb_lib_path)
5365
.expect("failed to stat libdir from llvm-config")
5466
.filter_map(|entry| match_libname(entry.unwrap().file_name().to_str().unwrap()))
5567
.next()

0 commit comments

Comments
 (0)