From 6f9d82c145696bedb05fe97a3d3d79900349d387 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Sun, 3 Dec 2023 14:05:04 +1100 Subject: [PATCH] Handle OpenBSD quirks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #60, (hopefully) allowing the crate to be used on OpenBSD systems. Suggested-by: Sébastien Bourdeauducq --- build.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index e8a1be8..79a6958 100644 --- a/build.rs +++ b/build.rs @@ -298,6 +298,13 @@ fn get_system_libraries(llvm_config_path: &Path, kind: LibraryKind) -> Vec Vec impl IntoIterator { + if target_os_is("openbsd") { + Some("/usr/local/lib") + } else { + None + } +} + fn target_dylib_extension() -> &'static str { if target_os_is("macos") { ".dylib" @@ -358,7 +379,7 @@ fn get_system_libcpp() -> Option<&'static str> { // latest, at the cost of breaking the build on older OS releases // when LLVM was built against libstdc++. Some("c++") - } else if target_os_is("freebsd") { + } else if target_os_is("freebsd") || target_os_is("openbsd") { Some("c++") } else if target_env_is("musl") { // The one built with musl. @@ -614,6 +635,9 @@ fn main() { // Link LLVM libraries println!("cargo:rustc-link-search=native={}", libdir); + for link_search_dir in get_system_library_dirs() { + println!("cargo:rustc-link-search=native={}", link_search_dir); + } // We need to take note of what kind of libraries we linked to, so that // we can link to the same kind of system libraries let (kind, libs) = get_link_libraries(&llvm_config_path, &preferences); -- GitLab