pgcentralfoundation / pgrx

Build Postgres Extensions with Rust!
Other
3.55k stars 237 forks source link

0.12 has a "failed to parse generated bindings" error #1822

Open workingjubilee opened 3 weeks ago

workingjubilee commented 3 weeks ago

multiple errors like this

       Using DefaultFeature("pg13") and `pg_config` from /home/ubuntu/.pgrx/13.11/pgrx-install/bin/pg_config
CARGO_TARGET_DIR="/home/ubuntu/ris_avails_r_ext/target" PGRX_ALL_FEATURES="false" PGRX_BUILD_PROFILE="dev" PGRX_FEATURES="pg13 pg_test" PGRX_NO_DEFAULT_FEATURES="true" PGRX_NO_SCHEMA="false" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo" "test" "--features" "pg13 pg_test" "--no-default-features"
   Compiling pgrx-pg-sys v0.12.0
error: failed to run custom build command for `pgrx-pg-sys v0.12.0`

Caused by:
  process didn't exit successfully: `/home/ubuntu/ris_avails_r_ext/target/debug/build/pgrx-pg-sys-d09c9452236bbdcb/build-script-bindgen` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=PGRX_BUILD_VERBOSE
  cargo:rerun-if-env-changed=PGRX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE
  cargo:rerun-if-env-changed=PGRX_PG_CONFIG_PATH
  cargo:rerun-if-env-changed=PGRX_PG_CONFIG_AS_ENV
  cargo:rerun-if-env-changed=LLVM_CONFIG_PATH
  cargo:rerun-if-env-changed=LIBCLANG_PATH
  cargo:rerun-if-env-changed=LIBCLANG_STATIC_PATH
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=PGRX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE
  cargo:rerun-if-changed=include
  cargo:rerun-if-changed=cshim
  cargo:rerun-if-changed=/home/ubuntu/.pgrx/config.toml
  cargo:rerun-if-env-changed=PGRX_TARGET_INFO_PATH_PG13_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PGRX_TARGET_INFO_PATH_PG13
  cargo:rerun-if-env-changed=PGRX_BINDGEN_NO_DETECT_INCLUDES_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PGRX_BINDGEN_NO_DETECT_INCLUDES
  cargo:rerun-if-env-changed=PGRX_INCLUDEDIR_SERVER_PG13_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PGRX_INCLUDEDIR_SERVER_PG13
  cargo:rerun-if-env-changed=PGRX_INCLUDEDIR_SERVER_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PGRX_INCLUDEDIR_SERVER
  cargo:rerun-if-env-changed=PGRX_PG_SYS_EXTRA_OUTPUT_PATH

  --- stderr
  build_paths=BuildPaths { manifest_dir: "/home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.12.0", out_dir: "/home/ubuntu/ris_avails_r_ext/target/debug/build/pgrx-pg-sys-f886f3e2945f3d25/out", src_dir: "/home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.12.0/src/include", shim_src: "/home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.12.0/cshim", shim_dst: "/home/ubuntu/ris_avails_r_ext/target/debug/build/pgrx-pg-sys-f886f3e2945f3d25/out/cshim" }
  Generating bindings for pg13
  pg_config --configure CLANG = None
  Bindgen found clang version 10.0.0-4ubuntu1 
  found libclang at /usr/lib/llvm-10/lib/libclang-10.0.0.so
  Found include dirs ["/usr/lib/llvm-10/lib/clang/10.0.0/include"]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/port.h:185:70: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/port.h:187:55: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/port.h:189:58: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/port.h:191:43: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:157:40: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:158:49: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:161:30: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:161:56: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:163:43: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:164:52: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:166:47: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:170:31: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:170:57: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:173:30: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:173:56: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:175:41: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:189:48: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:221:54: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/elog.h:437:47: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/palloc.h:155:44: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/utils/palloc.h:156:80: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/lib/stringinfo.h:96:67: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  clang diag: /home/ubuntu/.pgrx/13.11/pgrx-install/include/postgresql/server/lib/stringinfo.h:107:78: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
  Error: bindgen failed for pg13

  Caused by:
     0: failed to parse generated bindings
     1: expected identifier or `_`

  Location:
      /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-bindgen-0.12.0/src/build.rs:743:40
burmecia commented 2 weeks ago

I had the same issue for 0.12.1 and pg15.

workingjubilee commented 2 weeks ago

@burmecia This won't be resolved unless it becomes reproducible.

workingjubilee commented 2 weeks ago

To be clear, I don't really know how to resolve this because it's deeply dependent on your installation particulars. It took me a week at least of full-time work to run down things to make the build even as resilient as it is now. There's no way I'm going to manage without a reproducer.

workingjubilee commented 2 weeks ago

The issue is probably that you have too many clangs installed and should uninstall all of them except one.

burmecia commented 2 weeks ago

I didn't install multiple clangs and I can reproduce it on Arm64 platform with Ubuntu 20.04 LTS. I tested on both of my local Mac M1 (with Multipass) and Google Cloud. Here are the steps I've used:

  1. Create a new VM using Multipass or Google Clould Compute with spec below:

Arch: Arm64 OS: Ubuntu 20.04 LTS vCPU: 4 Mem: 16G Storage: 60G

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
$ uname -a
Linux bo-test 5.15.0-1066-gcp #74~20.04.1-Ubuntu SMP Fri Jul 26 09:28:24 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
  1. run below commands sequentially,
# install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"

# install clang
sudo apt-get update
sudo apt-get install libclang-dev

# install dependencies
sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache pkg-config

# install pgrx and pg15
cargo install --force --locked cargo-pgrx --version 0.12.1
cargo pgrx init --pg15 download

# start a new project
cargo pgrx new my_extension
cd my_extension/

# run the project
cargo pgrx run --features pg15

and error is like below:

image
workingjubilee commented 2 weeks ago

"I didn't install"... note the verb use there... "multiple clangs" does not mean there are not multiple clangs on your system, i.e. that multiple clangs could have been installed. This is in fact the most likely result if someone else first installed clang on that image.

workingjubilee commented 2 weeks ago

Though I see you're also using Ubuntu 20.04, and also the libclang from libclangs less than 10 seems to have mysteriously regressed. Possibly one of the bindings we now include was not correctly parsed by earlier clangs.