BUG #17100: undefined reference to `pg_qsort and pq_xxx

Started by PG Bug reporting formalmost 5 years ago2 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 17100
Logged by: [BuildError][GCC-10.2.x] undefined reference to `pg_qsort in PostrgreSQL
13.3
Email address: anilbommareddy09@gmail.com
PostgreSQL version: 13.3
Operating system: CentoS 8.3
Description:

export CC=gcc
export CXX=g++
Build command:
../configure --prefix=/path/to/pgsql-gcc CFLAGS='-O3 -flto' CXXFLAGS='-O3
-flto'
Error:
-----
<artificial>:(.text.startup+0xc19): undefined reference to `pg_qsort'
<artificial>:(.text.startup+0xe81): undefined reference to `pg_fprintf'
<artificial>:(.text.startup+0xea6): undefined reference to `pg_fprintf'
<artificial>:(.text.startup+0xecb): undefined reference to `pg_fprintf'
<artificial>:(.text.startup+0xef0): undefined reference to `pg_fprintf

I checked that I have these packages installed on the system
[root@xxx ~]# yum install postgresql-devel
Followed the steps as :https://github.com/brianc/node-postgres/issues/124
it not helped to resolve the issue.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PG Bug reporting form (#1)
Re: BUG #17100: undefined reference to `pg_qsort and pq_xxx

PG Bug reporting form <noreply@postgresql.org> writes:

Build command:
../configure --prefix=/path/to/pgsql-gcc CFLAGS='-O3 -flto' CXXFLAGS='-O3
-flto'

When I try that on that platform (well, actually RHEL 8.4, but should
be close enough) I get a lot of complaints like

ar: pgstrsignal.o: plugin needed to handle lto object
ar: pqsignal.o: plugin needed to handle lto object
ar: qsort.o: plugin needed to handle lto object
ar: qsort_arg.o: plugin needed to handle lto object
ar: quotes.o: plugin needed to handle lto object
ar: snprintf.o: plugin needed to handle lto object

so that the later complaints like

/tmp/ccWzhmx0.ltrans29.ltrans.o: In function `_bt_preprocess_array_keys':
<artificial>:(.text+0x2d264): undefined reference to `qsort_arg'
/tmp/ccWzhmx0.ltrans29.ltrans.o: In function `tblspc_desc':
<artificial>:(.text+0xdee): undefined reference to `appendStringInfo'
<artificial>:(.text+0xe0a): undefined reference to `appendStringInfo'

aren't terribly surprising. Those functions should come out of
libpqcommon.a, but seemingly that hasn't been built correctly.

I'd say the conclusion is "don't use -flto, it doesn't really work
yet on this platform". Or possibly there's some not-installed-by-
default infrastructure you need to use it. Either way, this does
not look like a Postgres bug; it's a compiler toolchain problem.

regards, tom lane