diff --git a/crates/duckdb/Cargo.toml b/crates/duckdb/Cargo.toml index 7fac1429..b1efd11e 100644 --- a/crates/duckdb/Cargo.toml +++ b/crates/duckdb/Cargo.toml @@ -20,6 +20,7 @@ name = "duckdb" [features] default = [] bundled = ["libduckdb-sys/bundled"] +bundled-android-static-libstdcpp = ["libduckdb-sys/bundled-android-static-libstdcpp"] json = ["libduckdb-sys/json", "bundled"] parquet = ["libduckdb-sys/parquet", "bundled"] vscalar = [] diff --git a/crates/libduckdb-sys/Cargo.toml b/crates/libduckdb-sys/Cargo.toml index 6d805651..3b0254a5 100644 --- a/crates/libduckdb-sys/Cargo.toml +++ b/crates/libduckdb-sys/Cargo.toml @@ -18,6 +18,7 @@ exclude = ["duckdb-sources"] [features] default = ["vcpkg", "pkg-config"] bundled = ["cc"] +bundled-android-static-libstdcpp = ["bundled"] buildtime_bindgen = ["bindgen", "pkg-config", "vcpkg"] json = ["bundled"] parquet = ["bundled"] diff --git a/crates/libduckdb-sys/build.rs b/crates/libduckdb-sys/build.rs index 98a476c1..d1c52c5e 100644 --- a/crates/libduckdb-sys/build.rs +++ b/crates/libduckdb-sys/build.rs @@ -37,6 +37,7 @@ fn main() { mod build_bundled { use std::{ collections::{HashMap, HashSet}, + env, path::Path, }; @@ -152,10 +153,21 @@ mod build_bundled { cfg.cpp(true) .flag_if_supported("-std=c++11") + .flag_if_supported("-stdlib=libc++") .flag_if_supported("/bigobj") .warnings(false) .flag_if_supported("-w"); + // The Android NDK doesn't build with this flag set. + if env::var("CARGO_CFG_TARGET_OS").unwrap() != "android" { + cfg.flag_if_supported("-stdlib=libstdc++"); + } + + #[cfg(feature = "bundled-android-static-libstdcpp")] + if env::var("CARGO_CFG_TARGET_OS").unwrap() == "android" { + cfg.flag_if_supported("-static-libstdc++"); + } + if win_target() { cfg.define("DUCKDB_BUILD_LIBRARY", None); }