Bug 267550 - databases/postgresql-promscale: Fails to build with "'libintl.h' file not found"
Summary: databases/postgresql-promscale: Fails to build with "'libintl.h' file not found"
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Mark Felder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-03 18:09 UTC by Jony Hudson
Modified: 2022-11-08 15:49 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (feld)


Attachments
Full build log (81.29 KB, text/plain)
2022-11-03 18:09 UTC, Jony Hudson
no flags Details
Full build log against pg13 (81.19 KB, text/plain)
2022-11-03 18:14 UTC, Jony Hudson
no flags Details
Full build log against pg13 (80.90 KB, text/plain)
2022-11-03 18:45 UTC, Jony Hudson
no flags Details
Proposed patch (2.16 KB, patch)
2022-11-06 21:30 UTC, Jony Hudson
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jony Hudson 2022-11-03 18:09:20 UTC
Created attachment 237849 [details]
Full build log

[As a side note: thanks for making this port, as a rather odd coincidence I was just sitting down yesterday evening to do the same thing, and a commit appeared as if by magic!]

I find that the port fails to build due to what looks like a gettext related error. Steps I took to try and get a clean repro:

```
poudriere jail -c -vv -j clean -v 13.1-RELEASE -a amd64
# Because my puny server chokes if it tries to build llvm and rust at the same time.
poudriere bulk -v -j clean lang/rust
poudriere bulk -v -j clean database/postgresql-promscale
tail -n 50  /usr/local/poudriere/data/logs/bulk/latest-per-pkg/postgresql14-promscale/0.7.0/131amd64-default.log 
```

Results in the following failure message:
```
   Compiling color-eyre v0.6.1
   Compiling toml v0.5.9
   Compiling bincode v1.3.3
   Compiling plist v1.3.1
   Compiling serde-xml-rs v0.5.1
   Compiling serde_cbor v0.11.2
   Compiling syntect v5.0.0
   Compiling askama_shared v0.12.2
   Compiling pgx-utils v0.4.5 (/wrkdirs/usr/ports/databases/postgresql-promscale/work/pgx/pgx-utils)
   Compiling askama_derive v0.11.2
   Compiling askama v0.11.1
   Compiling promscale v0.7.0 (/wrkdirs/usr/ports/databases/postgresql-promscale/work/promscale_extension-0.7.0)
   Compiling pgx-pg-sys v0.4.5 (/wrkdirs/usr/ports/databases/postgresql-promscale/work/pgx/pgx-pg-sys)
   Compiling pgx-macros v0.4.5 (/wrkdirs/usr/ports/databases/postgresql-promscale/work/pgx/pgx-macros)
error: failed to run custom build command for `pgx-pg-sys v0.4.5 (/wrkdirs/usr/ports/databases/postgresql-promscale/work/pgx/pgx-pg-sys)`

Caused by:
  process didn't exit successfully: `/wrkdirs/usr/ports/databases/postgresql-promscale/work/promscale_extension-0.7.0/target/release/build/pgx-pg-sys-f1210100d81f0f79/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=PGX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE
  cargo:rerun-if-changed=/wrkdirs/usr/ports/databases/postgresql-promscale/work/.pgx/config.toml
  cargo:rerun-if-changed=include/pg10.h
  cargo:rerun-if-changed=include/pg11.h
  cargo:rerun-if-changed=include/pg12.h
  cargo:rerun-if-changed=include/pg13.h
  cargo:rerun-if-changed=include/pg14.h
  cargo:rerun-if-changed=cshim/pgx-cshim.c
  cargo:rerun-if-changed=cshim/Makefile

  --- stderr
  manifest_dir=/wrkdirs/usr/ports/databases/postgresql-promscale/work/pgx/pgx-pg-sys
  shim_src=/wrkdirs/usr/ports/databases/postgresql-promscale/work/pgx/pgx-pg-sys/cshim
  shim_dst=/wrkdirs/usr/ports/databases/postgresql-promscale/work/promscale_extension-0.7.0/target/release/build/pgx-pg-sys-1a211044f9af3881/out/cshim
  Generating bindings for pg14
  /usr/local/include/postgresql/server/c.h:75:10: fatal error: 'libintl.h' file not found
  /usr/local/include/postgresql/server/c.h:75:10: fatal error: 'libintl.h' file not found, err: true
  thread 'main' panicked at 'Unable to generate bindings for pg14: ()', /wrkdirs/usr/ports/databases/postgresql-promscale/work/pgx/pgx-pg-sys/build.rs:530:13
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
gmake[1]: *** [Makefile:99: package] Error 1
gmake[1]: Leaving directory '/wrkdirs/usr/ports/databases/postgresql-promscale/work/promscale_extension-0.7.0'
*** Error code 2

Stop.
make: stopped in /usr/ports/databases/postgresql-promscale
=>> Cleaning up wrkdir
===>  Cleaning for postgresql14-promscale-0.7.0
build of databases/postgresql-promscale | postgresql14-promscale-0.7.0 ended at Thu Nov  3 14:49:38 GMT 2022
build time: 00:03:03
!!! build failure encountered !!!
```

Full log attached.

I did take a look in the build jail, and the gettext-runtime package was installed, and libintl.h was where it ought to be in /usr/local/include/.

This github bug looks like it might be relevant: https://github.com/timescale/promscale_extension/issues/532 .

I don't know much about rust, so don't have any bright ideas for debugging further.
Comment 1 Jony Hudson 2022-11-03 18:14:01 UTC
Oops, excuse me, quoted and attached the wrong log which is from a previous run building against pg14. The correct log looks much the same, and is attached.
Comment 2 Jony Hudson 2022-11-03 18:14:43 UTC
Created attachment 237850 [details]
Full build log against pg13
Comment 3 Jony Hudson 2022-11-03 18:45:40 UTC
Created attachment 237852 [details]
Full build log against pg13

Apologies for the noise. This is really the correct log now, against pg13 in the "clean" jail, (I think they all have the same content though).
Comment 4 Jony Hudson 2022-11-06 01:20:05 UTC
Stepping through the make and gmake steps with `-n` indicates that this is the command that generates the error:

```
/usr/bin/env MAKE=gmake PATH=/usr/local/libexec/ccache:/wrkdirs/usr/ports/databases/postgresql-promscale/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin:/wrkdirs/usr/ports/databases/postgresql-promscale/work/.cargo/bin XDG_DATA_HOME=/wrkdirs/usr/ports/databases/postgresql-promscale/work XDG_CONFIG_HOME=/wrkdirs/usr/ports/databases/postgresql-promscale/work XDG_CACHE_HOME=/wrkdirs/usr/ports/databases/postgresql-promscale/work/.cache HOME=/wrkdirs/usr/ports/databases/postgresql-promscale/work TMPDIR="/wrkdirs/usr/ports/databases/postgresql-promscale/work" PKG_CONFIG_LIBDIR=/wrkdirs/usr/ports/databases/postgresql-promscale/work/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local LOCALBASE=/usr/local CC="cc" CFLAGS="-O2 -pipe  -fstack-protector-strong -fno-strict-aliasing " CPP="cpp" CPPFLAGS="-I/usr/local/include" LDFLAGS=" -L/usr/local/lib -fstack-protector-strong " LIBS="" CXX="c++" CXXFLAGS="-O2 -pipe -fstack-protector-strong -fno-strict-aliasing  " MANPREFIX="/usr/local" CCACHE_DIR="/root/.ccache" BSD_INSTALL_PROGRAM="install  -s -m 555" BSD_INSTALL_LIB="install  -s -m 0644" BSD_INSTALL_SCRIPT="install  -m 555" BSD_INSTALL_DATA="install  -m 0644" BSD_INSTALL_MAN="install  -m 444" cargo pgx schema pg13 --force-create-or-replace --release > /dev/null
```

Perhaps the `CPPFLAGS="-I/usr/local/include"` somehow doesn't make its way through cargo?
Comment 5 Mark Felder freebsd_committer freebsd_triage 2022-11-06 01:24:31 UTC
Thanks for reporting! I suspect I may have NLS disabled on the tree I built this against and forgot about it.

Also, the real credit goes to the person who ported this to pkgsrc... they saved me a lot of headaches when I was going to give up tricking this thing into building without network access

I'll see if I can get this error reproduced
Comment 6 Jony Hudson 2022-11-06 01:48:38 UTC
It looks like more credit is due to our colleague on pkgsrc! This patch looks relevant: https://github.com/NetBSD/pkgsrc/blob/trunk/databases/postgresql-promscale_extension/patches/patch-pgx_pgx-pg-sys_build.rs .

If I manually edit /wrkdirs/usr/ports/databases/postgresql-promscale/work/pgx/pgx-pg-sys/build.rs in the middle of the broken build (in an interactive poudriere jail, that is), and add a line

.clang_arg("-I/usr/local/include")

below the existing

.clang_arg(&format!("-I{}", includedir_server.display()))

then it seems to build :-)

It's well above my rust pay-grade to know whether that's a reasonable thing to do, but it seems to work.
Comment 7 Jony Hudson 2022-11-06 21:30:10 UTC
Created attachment 237910 [details]
Proposed patch

Here's a patch that fixes the error. I had to do some Makefile gymnastics to get the patch to apply to pgx. It's quite possible that there's a cleaner way to do that that I'm not aware of!
Comment 8 Jony Hudson 2022-11-06 21:44:36 UTC
Just making the connection here that there's an upstream bug on pgx about this already. I've added a comment there with some thoughts: https://github.com/tcdi/pgx/issues/470#issuecomment-1304901237
Comment 9 Mark Felder freebsd_committer freebsd_triage 2022-11-08 15:49:00 UTC
tested, verified, and applied! Thanks!
Comment 10 commit-hook freebsd_committer freebsd_triage 2022-11-08 15:49:35 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2735159edc4ead9807d366b856ef26e546df849b

commit 2735159edc4ead9807d366b856ef26e546df849b
Author:     Mark Felder <feld@FreeBSD.org>
AuthorDate: 2022-11-08 15:47:47 +0000
Commit:     Mark Felder <feld@FreeBSD.org>
CommitDate: 2022-11-08 15:47:47 +0000

    databases/postgresql-promscale: Fix build with NLS

    PR:     267550

 databases/postgresql-promscale/Makefile                      |  6 +++++-
 databases/postgresql-promscale/files/pgx-include-patch (new) | 10 ++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)