[Bug 262768] databases/postgis31 does not work on i386: Undefined symbol "_ZNKSt8__detail20_Prime_rehash_policy11_M_next_bktEj"

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 24 Mar 2022 21:34:33 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262768

            Bug ID: 262768
           Summary: databases/postgis31 does not work on i386: Undefined
                    symbol
                    "_ZNKSt8__detail20_Prime_rehash_policy11_M_next_bktEj"
           Product: Ports & Packages
           Version: Latest
          Hardware: i386
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: lbartoletti@FreeBSD.org
          Reporter: mark@kane.mn
             Flags: maintainer-feedback?(lbartoletti@FreeBSD.org)
          Assignee: lbartoletti@FreeBSD.org

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=#

-- 
You are receiving this mail because:
You are the assignee for the bug.