[postgis-tickets] [PostGIS] #3869: PostGIS fails to link with the gold linker due to underlinking

PostGIS trac at osgeo.org
Fri Sep 29 08:12:06 PDT 2017


#3869: PostGIS fails to link with the gold linker due to underlinking
---------------------+---------------------------
 Reporter:  mjo      |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  medium   |  Milestone:  PostGIS 2.3.4
Component:  postgis  |    Version:  trunk
 Keywords:           |
---------------------+---------------------------
 "gold" is a modern linker intended to (eventually) replace the traditional
 "BFD" linker:

 https://en.wikipedia.org/wiki/Gold_%28linker%29

 However, gold is more strict about underlinking than the BFD linker was,
 and unused symbols are omitted from the resulting binary. This causes a
 problem for PostGIS, where something -- probably liblwgeom.so -- is using
 symbols from the math library but is not linking it in with "-lm". I've
 reported this on the Gentoo bug tracker along with a full build log:

   https://bugs.gentoo.org/show_bug.cgi?id=632354

 The fix is most likely simple, to add "-lm" to the linker command of any
 binary that uses the math functions. I've confirmed that this affects the
 latest SVN revision, and would be happy to test a patch.

 For convenience, I'll reproduce the error message here:

 {{{
 libtool: link: x86_64-pc-linux-gnu-gcc -I ../liblwgeom -march=native -O2
 -pipe -fPIC -DPIC -Wall -Wmissing-prototypes shpopen.o dbfopen.o getopt.o
 shpcommon.o safileio.o shp2pgsql-core.o shp2pgsql-cli.o -o .libs/shp2pgsql
 -Wl,-O1 -Wl,-rpath -Wl,/usr/lib64/postgresql-9.4/lib64 -Wl,--enable-new-
 dtags ../liblwgeom/.libs/liblwgeom.so -L/usr/lib64 -lgeos_c -lproj
 -ljson-c -L/usr/lib64/postgresql-9.4/lib64 -Wl,--as-needed -lc
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'sqrt'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'atan'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'floor'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'atan2'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'sincos'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'remainder'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'acos'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'asin'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'sin'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'cos'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'log10'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'log'
 ../liblwgeom/.libs/liblwgeom.so: error: undefined reference to 'tan'
 collect2: error: ld returned 1 exit status
 make[1]: *** [Makefile:103: shp2pgsql] Error 1
 make[1]: Leaving directory '/var/tmp/portage/dev-
 db/postgis-2.1.8-r1/work/postgis-2.1.8/loader'
 }}}

 (Adding "-lm" to the linker command above fixes the problem, but that may
 not be the best place to do it if liblwgeom is the one trying to use the
 math functions.)

--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3869>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list