From ae965de7da5e07bff09793bcba53a0b7bbb5b926 Mon Sep 17 00:00:00 2001 From: Guillaume Girol Date: Tue, 19 Dec 2023 12:00:00 +0000 Subject: [PATCH] fix linking with libc++abi on darwin with recent llvm --- build.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 964617d..805421a 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::{path::PathBuf, ffi::OsString}; // SPDX-License-Identifier: LGPL-3.0 fn v(s: &str) -> versions::Versioning { @@ -51,6 +51,12 @@ fn main() { }; eprintln!("building with NIXVER={version}"); builder.define("NIXVER", version.to_string().as_str()); + let compiler = builder.get_compiler(); + let compile_args = compiler.args(); + if compile_args.contains(&OsString::from("-lc++")) { + // required for exception handlind with libc++ + println!("cargo:rustc-link-lib=c++abi"); + } builder.compile("libnix_adapter.a"); let bindings = bindgen::Builder::default()