Bug 262768 - databases/postgis31 does not work on i386: Undefined symbol "_ZNKSt8__detail20_Prime_rehash_policy11_M_next_bktEj"
Summary: databases/postgis31 does not work on i386: Undefined symbol "_ZNKSt8__detail2...
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Some People
Assignee: Loïc Bartoletti
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-24 21:34 UTC by Mark Kane
Modified: 2022-10-06 22:12 UTC (History)
1 user (show)

See Also:
lbartoletti: maintainer-feedback+


Attachments
Fix postgis 3.x i386 (2.21 KB, patch)
2022-07-13 08:42 UTC, Loïc Bartoletti
lbartoletti: maintainer-approval+
Details | Diff
Config log for configure error from patch (259.70 KB, text/plain)
2022-10-06 22:05 UTC, David Stenwall
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Kane 2022-03-24 21:34:33 UTC
databases/postgis31 works perfectly on amd64, however on many i386 machines with either postgresql13-server or postgresql12-server it fails with "Undefined symbol" errors.

postgis31-3.1.5 from official "latest" package repo on a fresh FreeBSD 13.0-RELEASE-p8 i386 install:

----------
postgres=# CREATE DATABASE postgistest;
CREATE DATABASE
postgres=# \c postgistest
You are now connected to database "postgistest" as user "postgres".
postgistest=# CREATE EXTENSION postgis;
ERROR:  could not load library "/usr/local/lib/postgresql/postgis-3.so": /usr/local/lib/postgresql/postgis-3.so: Undefined symbol "_ZNKSt8__detail20_Prime_rehash_policy11_M_next_bktEj"
postgistest=# 
----------

Some searching suggests this might be related to a library mismatch between base and ports. I notice the i386 library that does not work is linking to libgcc_s.so.1 from the gcc10 port:

i386# ldd /usr/local/lib/postgresql/postgis-3.so | grep libgcc
        libgcc_s.so.1 => /usr/local/lib/gcc10/libgcc_s.so.1 (0x207a4000)
i386# 

while the working amd64 machine is linking to base libgcc_s.so.1:

amd64# ldd /usr/local/lib/postgresql/postgis-3.so | grep gcc
	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x80169b000)
amd64#

I have tried playing around with LD_LIBRARY_PATH/LD_PRELOAD but have not found a working combination as postgresql-server itself appears to need the ports gcc10 libgcc_s.so.1.

FYI this also affects databases/postgis32 on i386, although the undefined symbol is different with 3.2:

postgistest=# CREATE EXTENSION postgis;
ERROR:  could not load library "/usr/local/lib/postgresql/postgis-3.so": /usr/local/lib/postgresql/postgis-3.so: Undefined symbol "_ZNSt8ios_base4InitD1Ev"
postgistest=#
Comment 1 Mark Kane 2022-04-01 18:28:11 UTC
Disabling the WAGYU option that is enabled by default allows postgis31 to work correctly on i386.

With WAGYU disabled, postgis-3.so on i386 is now linking against base libgcc_s.so.1 which matches amd64. 

$ ldd /usr/local/lib/postgresql/postgis-3.so | grep libgcc
	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x207a4000)
$
Comment 2 Loïc Bartoletti freebsd_committer freebsd_triage 2022-07-13 06:29:49 UTC
Indeed, Wagyu is a c++ dependency. Can you edit the Makefile like this:


replace USES= `compiler:c++11-lang` by `compiler:gcc-c++1-lib`
Comment 3 Loïc Bartoletti freebsd_committer freebsd_triage 2022-07-13 08:42:50 UTC
Created attachment 235232 [details]
Fix postgis 3.x i386
Comment 4 Loïc Bartoletti freebsd_committer freebsd_triage 2022-07-13 08:43:09 UTC
Here a patch for postgis >= 3.0
Comment 5 David Stenwall 2022-10-06 22:05:23 UTC
Created attachment 237128 [details]
Config log for configure error from patch

Trying to manually apply the patch on postgis 3.2.3

configure: error: *** A compiler with support for C++11 language features is required.
Comment 6 David Stenwall 2022-10-06 22:12:06 UTC
(In reply to David Stenwall from comment #5)
So sorry. gcc noob here. A simple 
pkg install gcc11 
fixed it.

Had just gcc installed and that didn't do the trick.