OpenBSD support
The patch below fixes problems with OpenBSD and makes llvm-sys usable on this platform.
diff --git a/build.rs b/build.rs
index ab90312..c8252aa 100644
--- a/build.rs
+++ b/build.rs
@@ -296,7 +296,10 @@ fn get_system_libraries(kind: LibraryKind) -> Vec<String> {
} else {
if flag.starts_with("-l") {
// Linker flags style, -lfoo
- return flag[2..].to_owned();
+ // For some reason, on OpenBSD llvm-config sometimes emits
+ // broken linker flags such as "-lz.so.7.0"
+ let dotidx = flag.find(".").unwrap_or(flag.len());
+ return flag[2..dotidx].to_owned();
}
let maybe_lib = Path::new(&flag);
@@ -334,6 +337,8 @@ fn get_system_libcpp() -> Option<&'static str> {
Some("c++")
} else if target_os_is("freebsd") {
Some("c++")
+ } else if target_os_is("openbsd") {
+ Some("c++")
} else if target_env_is("musl") {
// The one built with musl.
Some("c++")
@@ -608,6 +613,9 @@ fn main() {
for name in get_system_libraries(kind) {
println!("cargo:rustc-link-lib={}={}", sys_lib_kind.string(), name);
}
+ if target_os_is("openbsd") {
+ println!("cargo:rustc-link-search=/usr/local/lib");
+ }
let use_debug_msvcrt = env::var_os(&*ENV_USE_DEBUG_MSVCRT).is_some();
if target_env_is("msvc") && (use_debug_msvcrt || is_llvm_debug()) {