pgcentralfoundation / pgrx

Build Postgres Extensions with Rust!
Other
3.68k stars 247 forks source link

v0.12.4 chokes on pg 17 on Mac #1868

Closed ccleve closed 1 month ago

ccleve commented 2 months ago

I can't tell if this is a pgrx issue or a pg17 issue.

Apple just did a drive-by shooting of my XCode install, upgrading it without asking, and of course moving the C compiler. This normally requires a new cargo pgrx init.

I took the opportunity to upgrade Rust and pgrx. Now, after a clean install, cargo pgrx init chokes on pg17:

Error: 
   0: cd "/Users/ccleve/.pgrx/17rc1" && env -u DEBUG -u DYLD_FALLBACK_LIBRARY_PATH -u HOST -u LIBRARY_PATH -u MAKEFLAGS -u MAKELEVEL -u MFLAGS -u NUM_JOBS -u OPT_LEVEL -u OUT_DIR -u PROFILE -u TARGET CPPFLAGS=" -DUSE_ASSERT_CHECKING=1 -DRANDOMIZE_ALLOCATED_MEMORY=1 " PATH="/Users/ccleve/.pgrx/17rc1:/Users/ccleve/.jbang/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/ccleve/.cargo/bin" "/Users/ccleve/.pgrx/17rc1/configure" "--prefix=/Users/ccleve/.pgrx/17rc1/pgrx-install" "--with-pgport=28817" "--enable-debug" "--enable-cassert"

--snip--

      checking whether to build with ICU support... yes
      checking for icu-uc icu-i18n... no
      configure: error: ICU library not found
      If you have ICU already installed, see config.log for details on the
      failure.  It is possible the compiler isn't looking in the proper directory.
      Use --without-icu to disable ICU support.

pg16 and previous versions install fine. It's just 17 that has the problem.

Looking into the config logs, I see this in the pg16 log:

#define CONFIGURE_ARGS " '--prefix=/Users/ccleve/.pgrx/16.4/pgrx-install' '--with-pgport=28816' '--enable-debug' '--enable-cassert' 'CPPFLAGS= -DUSE_ASSERT_CHECKING=1 -DRANDOMIZE_ALLOCATED_MEMORY=1 ' 'PKG_CONFIG_PATH=/opt/homebrew/opt/icu4c/lib/pkgconfig'"

pg16 is correctly finding icu in the homebrew dir.

pg17 has this:

| #define CONFIGURE_ARGS " '--prefix=/Users/ccleve/.pgrx/17rc1/pgrx-install' '--with-pgport=28817' '--enable-debug' '--enable-cassert' 'CPPFLAGS= -DUSE_ASSERT_CHECKING=1 -DRANDOMIZE_ALLOCATED_MEMORY=1 '"

No mention of homebrew.

A little further down in the pg17 log:

configure:8108: checking for icu-uc icu-i18n
configure:8115: $PKG_CONFIG --exists --print-errors "icu-uc icu-i18n"
Package icu-uc was not found in the pkg-config search path.
Perhaps you should add the directory containing `icu-uc.pc'
to the PKG_CONFIG_PATH environment variable
No package 'icu-uc' found

So, I run this on the command line:

export PKG_CONFIG_PATH=/opt/homebrew/opt/icu4c/lib/pkgconfig

and cargo pgrx init runs fine.

Again, I don't know if the problem lies in the pg17 config, or in the way that pgrx is invoking it.

eeeebbbbrrrr commented 2 months ago

This came up in #1828. Same problem.

I asked the OP over there to submit a PR to improve our docs but they have not.

I’m loathe to do it because I don’t use a Mac anymore as my daily development machine and while I was able to follow along on my spare mini to help them out, I’m not confident in writing the exact steps/instructions.

Could I ask you to do that for us, Mr. Cleveland?

ccleve commented 1 month ago

I've done the PR. Unfortunately, I don't have a clean Mac to do the install from scratch, so I'm not sure I've got everything. I suppose I could spin up a Mac in the cloud somewhere...

In any case, documentation isn't a good solution to this problem. We should investigate why ./config is running differently. Is pgrx's invocation of the pg build process any different for pg17? Or did they do something to mess things up?

eeeebbbbrrrr commented 1 month ago

I don’t know why it behaves like this for 17.

We had some serious drama with 16 and its inclusion of some SIMD headers. That took awhile to overcome. Perhaps this is a similar thing.

In all my years of doing Unix software dev I have tried very very hard to not learn a damn thing about make and autoconf and related toolchains. So it’s physically painful for me to dig into this stuff now that I’m old and gray.

Saying “install icu via brew and exposer the pkgcfg path like it tells you you might need” seems reasonable.

We might could teach our build.rs how to snoop around a bit before we call bindgen. That’s the closest to a concept of a plan I’ve got.