Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure bindgen gets all the cppflags it needs (on macOS, anyway) #1247

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions pgrx-pg-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,14 +885,18 @@ fn extra_bindgen_clang_args(pg_config: &PgConfig) -> eyre::Result<Vec<String>> {
// `pgrx-pg-config` crate is implemented, but even if it were not, the
// problem won't be with flags we are interested in.
let flags = shlex::split(&flags.to_string_lossy()).unwrap_or_default();
// Find the `-isysroot` flags -- The rest are `-I` flags that don't seem
// to be needed inside the code (and feel likely to cause bindgen to
// emit bindings for unrelated libraries)
// Just give clang the full flag set, since presumably that's what we're
// getting when we build the C shim anyway.
out.extend(flags.iter().cloned());

// Find the `-isysroot` flags so we can warn about them, so something
// reasonable shows up if/when the build fails.
//
// Eventually we should probably wrangle the sysroot for `cargo pgrx
// init`-installed PGs a bit more aggressively, but for now, whatever.
for pair in flags.windows(2) {
if pair[0] == "-isysroot" {
if std::path::Path::new(&pair[1]).exists() {
out.extend(pair.into_iter().cloned());
} else {
if !std::path::Path::new(&pair[1]).exists() {
// The SDK path doesn't exist. Emit a warning, which they'll
// see if the build ends up failing (it may not fail in all
// cases, so we don't panic here).
Expand Down