Subject: meson vs. extension builds

From: Robert Haas <[email-masked]>
Date: Tue, 5 Nov 2024 12:30:42 -0500

Hi,

This issue has been bugging me for a while but I haven't gotten around
to reporting it until now. Apologies if this is a duplicate report.
When I try to build an extension such as pg_catcheck against a meson
build, it does not work. If I do the same thing with a configure-based
build, it does work. Here's the failure:

ccache clang -isysroot
/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk
-fno-strict-aliasing -fwrapv -Wall -g -O2 -Wmissing-prototypes
-Wpointer-arith -Werror=vla -Werror=unguarded-availability-new
-Wendif-labels -Wmissing-format-attribute -Wcast-function-type
-Wformat-security -Wdeclaration-after-statement
-Wmissing-variable-declarations -Wno-unused-command-line-argument
-Wno-compound-token-split-by-macro
-I/Users/robert.haas/install/dev/include -I. -I./
-I/Users/robert.haas/install/dev/include/postgresql/server
-I/Users/robert.haas/install/dev/include/postgresql/internal    -c -o
pg_catcheck.o pg_catcheck.c -MMD -MP -MF .deps/pg_catcheck.Po
In file included from pg_catcheck.c:22:
In file included from
/Users/robert.haas/install/dev/include/postgresql/server/postgres_fe.h:25:
/Users/robert.haas/install/dev/include/postgresql/server/c.h:78:10:
fatal error: 'libintl.h' file not found
#include <libintl.h>
         ^~~~~~~~~~~
1 error generated.
make: *** [pg_catcheck.o] Error 1

The problem is that libintl.h is in /opt/local/include. When I run
meson setup, I specify -Dextra_include_dirs=/opt/local/include
-Dextra_lib_dirs=/opt/local/lib. And correspondingly, when I use
configure, I use --with-libraries=/opt/local/lib
--with-includes=/opt/local/include. But it seems that the configure
settings automatically propagate through to where extension builds
also pick them up, and the meson settings don't. Consequently, I am
sad.

Taking a diff of the generated lib/postgresql/pgxs/src/Makefile.global
files, I see, inter alia, this:

240c240
< CPPFLAGS = -isysroot $(PG_SYSROOT)  -I/opt/local/include/libxml2
-I/opt/local/include
---
> CPPFLAGS =
315c315
< LDFLAGS = $(LDFLAGS_INTERNAL) -isysroot $(PG_SYSROOT)
-L/opt/local/lib  -L/opt/local/lib -Wl,-dead_strip_dylibs
---
> LDFLAGS = $(LDFLAGS_INTERNAL) -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -Wl,-no_warn_duplicate_libraries

Which is probably related.

-- 
Robert Haas
EDB: http://www.enterprisedb.com