Opened 5 years ago

Closed 5 years ago

#4408 closed defect (fixed)

can't compile --with-wagyu under mingw64

Reported by: robe Owned by: Algunenano
Priority: blocker Milestone: PostGIS 3.0.0
Component: postgis Version: master
Keywords: Cc:

Description

../deps/wagyu/libwagyu.la(lwgeom_wagyu.o):lwgeom_wagyu.cpp:(.rdata$_ZTISt13runtime_error[_ZTISt13runtime_error]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../deps/wagyu/libwagyu.la(lwgeom_wagyu.o):lwgeom_wagyu.cpp:(.rdata$_ZTISt9exception[_ZTISt9exception]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
../deps/wagyu/libwagyu.la(lwgeom_wagyu.o):lwgeom_wagyu.cpp:(.rdata$.refptr._ZSt7nothrow[.refptr._ZSt7nothrow]+0x0): undefined reference to `std::nothrow'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [C:/MING64~1/projects/POSTGR~1/rel/PG12W6~2/lib/pgxs/src/MAKEFI~1/../../src/Makefile.shlib:386: postgis-3.dll] Error 1

This is using gcc 8.1

gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0

Change History (13)

comment:1 by Algunenano, 5 years ago

Owner: changed from pramsey to Algunenano
Version: 2.4.xtrunk

Thanks for testing it.

I guess that it is failing when linking postgis-3.so, but I'm not certain. Can you share the final command that led to this error, please?

Also, can you include the output of ./configure --with-wagyu?. Does it warn with something like Could not find a C++ standard library? I'm using a very basic detection system (which was needed for OSX) which might require an extra option for mingw.

comment:2 by robe, 5 years ago

here is the error including the command prior

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O2   -shared -static-libgcc -o postgis-3.dll  postgis_module.o lwgeom_accum.o lwgeom_spheroid.o lwgeom_ogc.o lwgeom_functions_analytic.o lwgeom_inout.o lwgeom_functions_basic.o lwgeom_btree.o lwgeom_box.o lwgeom_box3d.o lwgeom_geos.o lwgeom_sfcgal.o lwgeom_geos_prepared.o lwgeom_geos_clean.o lwgeom_geos_relatematch.o lwgeom_export.o lwgeom_in_gml.o lwgeom_in_kml.o lwgeom_in_geohash.o lwgeom_in_geojson.o lwgeom_in_encoded_polyline.o lwgeom_triggers.o lwgeom_dump.o lwgeom_dumppoints.o lwgeom_functions_lrs.o lwgeom_functions_temporal.o lwgeom_rectree.o long_xact.o lwgeom_sqlmm.o lwgeom_rtree.o lwgeom_transform.o lwgeom_window.o gserialized_typmod.o gserialized_gist_2d.o gserialized_gist_nd.o gserialized_supportfn.o gserialized_spgist_2d.o gserialized_spgist_3d.o gserialized_spgist_nd.o brin_2d.o brin_nd.o brin_common.o gserialized_estimate.o geography_inout.o geography_btree.o geography_centroid.o geography_measurement.o geography_measurement_trees.o geometry_inout.o postgis_libprotobuf.o vector_tile.pb-c.o geobuf.pb-c.o mvt.o lwgeom_out_mvt.o geobuf.o lwgeom_out_geobuf.o lwgeom_out_geojson.o postgis_legacy.o -LC:/MING64~1/projects/POSTGR~1/rel/PG12W6~2/lib  -L/projects/zlib/rel-zlib-1.2.11w64gcc81/lib -L/projects/libxml/rel-libxml2-2.7.8w64gcc81/lib -Wl,--allow-multiple-definition -Wl,--disable-auto-import -L/projects/libxml/rel-libxml2-2.7.8w64gcc81/lib  -Wl,--as-needed   ../deps/wagyu/libwagyu.la -lstdc++ ../libpgcommon/libpgcommon.a ../liblwgeom/.libs/liblwgeom.a  -LC:/ming64gcc81/projects/geos/rel-3.8w64gcc81/lib -lgeos_c -L/projects/proj/rel-6.0.0w64gcc81/lib -lproj  -L/projects/protobuf/rel-3.2.0w64gcc81/lib -lprotobuf-c -L/projects/libxml/rel-libxml2-2.7.8w64gcc81/lib -lxml2 -lws2_32 -L/projects/CGAL/rel-sfcgal-1.3.2w64gcc81/lib -lSFCGAL -Wl,--exclude-libs,ALL  -L/projects/CGAL/rel-sfcgal-1.3.2w64gcc81/lib -lSFCGAL -LC:/MING64~1/projects/POSTGR~1/rel/PG12W6~2/lib -lpostgres -lpgcommon -lpgport -lxml2 -lz -lws2_32 -lm  -lws2_32 -Wl,--export-all-symbols -Wl,--out-implib=libpostgis-3.a
../deps/wagyu/libwagyu.la(lwgeom_wagyu.o):lwgeom_wagyu.cpp:(.rdata$_ZTISt13runtime_error[_ZTISt13runtime_error]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../deps/wagyu/libwagyu.la(lwgeom_wagyu.o):lwgeom_wagyu.cpp:(.rdata$_ZTISt9exception[_ZTISt9exception]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
../deps/wagyu/libwagyu.la(lwgeom_wagyu.o):lwgeom_wagyu.cpp:(.rdata$.refptr._ZSt7nothrow[.refptr._ZSt7nothrow]+0x0): undefined reference to `std::nothrow'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [C:/MING64~1/projects/POSTGR~1/rel/PG12W6~2/lib/pgxs/src/MAKEFI~1/../../src/Makefile.shlib:386: postgis-3.dll] Error 1
make[1]: Leaving directory '/projects/postgis/branches/3.0/postgis'
make: *** [GNUmakefile:20: all] Error 1

in config.log - no warning just a

configure:18519: result: none required
configure:18595: result: WAGYU: Wagyu usage requested
configure:18726: checking for C++ compiler version
configure:18735: gcc --version >&5
gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0

and configure out shows this

-------------- Compiler Info -------------
  C compiler:           x86_64-w64-mingw32-gcc -std=gnu99 -g -O2 -fno-math-errno -fno-signed-zeros
  C++ compiler (Wagyu): gcc -std=c++11 -x c++
  CPPFLAGS:              -IC:/ming64gcc81/projects/geos/rel-3.8w64gcc81/include -I/projects/proj/rel-6.0.0w64gcc81/include -I/projects/protobuf/rel-3.2.0w64gcc81/include -I/projects/libxml/rel-libxml2-2.7.8w64gcc81/include/libxml2 -I/projects/CGAL/rel-sfcgal-1.3.2w64gcc81/include -I/projects/json-c/rel-0.12w64gcc81/include/json-c
  SQL preprocessor:     /mingw/bin/cpp -traditional-cpp -w -P
 -------------- Additional Info -------------
  Interrupt Tests:   DISABLED use: --with-interrupt-tests to enable

 -------------- Dependencies --------------
  GEOS config:          /projects/geos/rel-3.8w64gcc81/bin/geos-config
  GEOS version:         3.8.0
  GDAL config:          /projects/gdal/rel-2.3.1w64gcc81/bin/gdal-config
  GDAL version:         2.3.1
  SFCGAL config:        /projects/CGAL/rel-sfcgal-1.3.2w64gcc81/bin/sfcgal-config
  SFCGAL version:       1.3.2
  PostgreSQL config:    /projects/postgresql/rel/pg12w64gcc81/bin/pg_config
  PostgreSQL version:   PostgreSQL 12beta1
  PROJ4 version:        60
  Libxml2 config:       /projects/libxml/rel-libxml2-2.7.8w64gcc81/bin/xml2-config
  Libxml2 version:      2.7.8
  JSON-C support:       no
  protobuf-c support:   yes
  PCRE support:         no
  Perl:                 /bin/perl
  Wagyu:                yes

 --------------- Extensions ---------------
  PostGIS Raster:                     enabled


I'm going to go ahead and turn on winnie's wagyu — she's still building with an older compiler but sometimes that one for whatever reason doesn't run into the same issues my newer one does.

comment:3 by robe, 5 years ago

In 17450:

reorder wagyu line in bessie regress
configure winnie to test with wagyu to better troubleshoot issue
References #4408

comment:4 by robe, 5 years ago

Sadly winnie has same issue

https://winnie.postgis.net:444/job/PostGIS_EDB_Regress_winnie/9078/consoleFull

../deps/wagyu/libwagyu.la(lwgeom_wagyu.o):lwgeom_wagyu.cpp:(.text$_ZSt20get_temporary_bufferIPN6mapbox8geometry5wagyu13local_minimumIiEEESt4pairIPT_xEx[_ZSt20get_temporary_bufferIPN6mapbox8geometry5wagyu13local_minimumIiEEESt4pairIPT_xEx]+0x4c): undefined reference to `std::nothrow'
../deps/wagyu/libwagyu.la(lwgeom_wagyu.o):lwgeom_wagyu.cpp:(.text$_ZSt23return_temporary_bufferIPN6mapbox8geometry5wagyu13local_minimumIiEEEvPT_[_ZSt23return_temporary_bufferIPN6mapbox8geometry5wagyu13local_minimumIiEEEvPT_]+0xf): undefined reference to `std::nothrow'
C:/ming64gcc48/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64-mingw32/bin/ld.exe: ../deps/wagyu/libwagyu.la(lwgeom_wagyu.o): bad reloc address 0xf in section `.text$_ZSt23return_temporary_bufferIPN6mapbox8geometry5wagyu13local_minimumIiEEEvPT_[_ZSt23return_temporary_bufferIPN6mapbox8geometry5wagyu13local_minimumIiEEEvPT_]'
collect2.exe: error: ld returned 1 exit status
E:/jenkins/postgresql/rel/pg11w64gcc48/lib/pgxs/src/makefiles/../../src/Makefile.shlib:381: recipe for target 'postgis-3.dll' failed
make[1]: *** [postgis-3.dll] Error 1
make[1]: Leaving directory '/projects/postgis/branches/3.0/postgis'
GNUmakefile:20: recipe for target 'all' failed
make: *** [all] Error 1

comment:5 by Algunenano, 5 years ago

The c++ std library seems to be detected correctly (-lstdc++) but Winnie seems to be using Gcc 4.8.3 to build the extension (using whatever was used to build postgres), not 8.1.

Is that right?

comment:6 by robe, 5 years ago

Sorry I should have explained.

Locally I am running mingw64 gcc 8.1.0 and everything I have is compiled against 8.1.0 including PostgreSQL.

Winnie is running gcc 4.8.3 and everything she has is compiled against gcc 4.8.3 (4.8.1 for her 32-bit runs).

gcc 4.8.3 should be c++ 11 compliant as well.

Anyway we both seem to have the same issue.

Here is her output:

-------------- Compiler Info ------------- 
  C compiler:           x86_64-w64-mingw32-gcc -std=gnu99 -g -O2 -fno-math-errno -fno-signed-zeros
  C++ compiler (Wagyu): gcc -std=c++11 -x c++ 
  CPPFLAGS:              -IE:/jenkins/geos/rel-3.8w64gcc48/include -I/projects/proj/rel-4.9.3w64gcc48/include -I/projects/protobuf/rel-3.2.0w64gcc48/include -I/projects/libxml/rel-libxml2-2.7.8w64gcc48/include/libxml2 -I/projects/CGAL/rel-sfcgal-1.3.2w64gcc48/include -I/projects/json-c/rel-0.12w64gcc48/include/json-c -I/projects/pcre/rel-8.33w64gcc48/include 
  SQL preprocessor:     /mingw/bin/cpp -traditional-cpp -w -P

 -------------- Additional Info ------------- 
  Interrupt Tests:   DISABLED use: --with-interrupt-tests to enable

 -------------- Dependencies -------------- 
  GEOS config:          /projects/geos/rel-3.8w64gcc48/bin/geos-config
  GEOS version:         3.8.0
  GDAL config:          /projects/gdal/rel-2.2.4w64gcc48/bin/gdal-config
  GDAL version:         2.2.4
  SFCGAL config:        /projects/CGAL/rel-sfcgal-1.3.2w64gcc48/bin/sfcgal-config
  SFCGAL version:       1.3.2
  PostgreSQL config:    /projects/postgresql/rel/pg11w64gcc48/bin/pg_config
  PostgreSQL version:   PostgreSQL 11.0
  PROJ4 version:        49
  Libxml2 config:       /projects/libxml/rel-libxml2-2.7.8w64gcc48/bin/xml2-config
  Libxml2 version:      2.7.8
  JSON-C support:       no
  protobuf-c support:   yes
  PCRE support:         yes
  Perl:                 /bin/perl
  Wagyu:                yes

 --------------- Extensions --------------- 
  PostGIS Raster:                     enabled
  PostGIS Topology:                   enabled
  SFCGAL support:                     enabled
  Address Standardizer support:       enabled

 -------- Documentation Generation -------- 
  xsltproc:             /projects/xsltproc/xsltproc
  xsl style sheets:     /projects/docbook/docbook-xsl-1.76.1
  dblatex:              
  convert:              /c/Windows/system32/convert
  mathml2.dtd:          http://www.w3.org/Math/DTD/mathml2/mathml2.dtd

comment:7 by robe, 5 years ago

I wonder if it has to do with the mix of C in std=gnu99 mode and the C++ being in std=c++11

comment:8 by Algunenano, 5 years ago

I think that the issue comes from the linker being gcc and not g++.

In my Linux machine this wasn't an issue (modern GCC/Clang), for OSX I added a small detection utility so now it adds -lstdc++ or -lc++, but it looks like this isn't enough it the mingw setup.

Can you try running the last command changing gcc for g++:

g++ -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O2   -shared -static-libgcc -o postgis-3.dll  postgis_module.o lwgeom_accum.o lwgeom_spheroid.o lwgeom_ogc.o lwgeom_functions_analytic.o lwgeom_inout.o lwgeom_functions_basic.o lwgeom_btree.o lwgeom_box.o lwgeom_box3d.o lwgeom_geos.o lwgeom_sfcgal.o lwgeom_geos_prepared.o lwgeom_geos_clean.o lwgeom_geos_relatematch.o lwgeom_export.o lwgeom_in_gml.o lwgeom_in_kml.o lwgeom_in_geohash.o lwgeom_in_geojson.o lwgeom_in_encoded_polyline.o lwgeom_triggers.o lwgeom_dump.o lwgeom_dumppoints.o lwgeom_functions_lrs.o lwgeom_functions_temporal.o lwgeom_rectree.o long_xact.o lwgeom_sqlmm.o lwgeom_rtree.o lwgeom_transform.o lwgeom_window.o gserialized_typmod.o gserialized_gist_2d.o gserialized_gist_nd.o gserialized_supportfn.o gserialized_spgist_2d.o gserialized_spgist_3d.o gserialized_spgist_nd.o brin_2d.o brin_nd.o brin_common.o gserialized_estimate.o geography_inout.o geography_btree.o geography_centroid.o geography_measurement.o geography_measurement_trees.o geometry_inout.o postgis_libprotobuf.o vector_tile.pb-c.o geobuf.pb-c.o mvt.o lwgeom_out_mvt.o geobuf.o lwgeom_out_geobuf.o lwgeom_out_geojson.o postgis_legacy.o -LC:/MING64~1/projects/POSTGR~1/rel/PG12W6~2/lib  -L/projects/zlib/rel-zlib-1.2.11w64gcc81/lib -L/projects/libxml/rel-libxml2-2.7.8w64gcc81/lib -Wl,--allow-multiple-definition -Wl,--disable-auto-import -L/projects/libxml/rel-libxml2-2.7.8w64gcc81/lib  -Wl,--as-needed   ../deps/wagyu/libwagyu.la -lstdc++ ../libpgcommon/libpgcommon.a ../liblwgeom/.libs/liblwgeom.a  -LC:/ming64gcc81/projects/geos/rel-3.8w64gcc81/lib -lgeos_c -L/projects/proj/rel-6.0.0w64gcc81/lib -lproj  -L/projects/protobuf/rel-3.2.0w64gcc81/lib -lprotobuf-c -L/projects/libxml/rel-libxml2-2.7.8w64gcc81/lib -lxml2 -lws2_32 -L/projects/CGAL/rel-sfcgal-1.3.2w64gcc81/lib -lSFCGAL -Wl,--exclude-libs,ALL  -L/projects/CGAL/rel-sfcgal-1.3.2w64gcc81/lib -lSFCGAL -LC:/MING64~1/projects/POSTGR~1/rel/PG12W6~2/lib -lpostgres -lpgcommon -lpgport -lxml2 -lz -lws2_32 -lm  -lws2_32 -Wl,--export-all-symbols -Wl,--out-implib=libpostgis-3.a

If that works I can confirm that the aim is correct and I'll investigate further to see what extra flags we'd need to add to link the C++ code correctly.

comment:9 by robe, 5 years ago

Changing gcc to g++ didn't help.

However I was able to get it to compile by removing the

-Wl,--disable-auto-import

So my final working is below using g++ vs. gcc doesn't seem to make any difference

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O2   -shared -static-libgcc -o postgis-3.dll  postgis_module.o lwgeom_accum.o lwgeom_spheroid.o lwgeom_ogc.o lwgeom_functions_analytic.o lwgeom_inout.o lwgeom_functions_basic.o lwgeom_btree.o lwgeom_box.o lwgeom_box3d.o lwgeom_geos.o lwgeom_sfcgal.o lwgeom_geos_prepared.o lwgeom_geos_clean.o lwgeom_geos_relatematch.o lwgeom_export.o lwgeom_in_gml.o lwgeom_in_kml.o lwgeom_in_geohash.o lwgeom_in_geojson.o lwgeom_in_encoded_polyline.o lwgeom_triggers.o lwgeom_dump.o lwgeom_dumppoints.o lwgeom_functions_lrs.o lwgeom_functions_temporal.o lwgeom_rectree.o long_xact.o lwgeom_sqlmm.o lwgeom_rtree.o lwgeom_transform.o lwgeom_window.o gserialized_typmod.o gserialized_gist_2d.o gserialized_gist_nd.o gserialized_supportfn.o gserialized_spgist_2d.o gserialized_spgist_3d.o gserialized_spgist_nd.o brin_2d.o brin_nd.o brin_common.o gserialized_estimate.o geography_inout.o geography_btree.o geography_centroid.o geography_measurement.o geography_measurement_trees.o geometry_inout.o postgis_libprotobuf.o vector_tile.pb-c.o geobuf.pb-c.o mvt.o lwgeom_out_mvt.o geobuf.o lwgeom_out_geobuf.o lwgeom_out_geojson.o postgis_legacy.o -LC:/MING64~1/projects/POSTGR~1/rel/PG12W6~2/lib  -L/projects/zlib/rel-zlib-1.2.11w64gcc81/lib -L/projects/libxml/rel-libxml2-2.7.8w64gcc81/lib -Wl,--allow-multiple-definition -L/projects/libxml/rel-libxml2-2.7.8w64gcc81/lib  -Wl,--as-needed   ../deps/wagyu/libwagyu.la -lstdc++ ../libpgcommon/libpgcommon.a ../liblwgeom/.libs/liblwgeom.a  -LC:/ming64gcc81/projects/geos/rel-3.8w64gcc81/lib -lgeos_c -LC:/ming64gcc81/projects/proj/rel-6.0.0w64gcc81/lib -lproj   -LC:/ming64gcc81/projects/json-c/rel-0.12w64gcc81/lib -ljson-c   -LC:/ming64gcc81/projects/protobuf/rel-3.2.0w64gcc81/lib -lprotobuf-c   -L/projects/libxml/rel-libxml2-2.7.8w64gcc81/lib -lxml2 -lws2_32 -L/projects/CGAL/rel-sfcgal-1.3.2w64gcc81/lib -lSFCGAL -Wl,--exclude-libs,ALL  -L/projects/CGAL/rel-sfcgal-1.3.2w64gcc81/lib -lSFCGAL -LC:/MING64~1/projects/POSTGR~1/rel/PG12W6~2/lib -lpostgres -lpgcommon -lpgport -lxml2 -lz -lws2_32 -lm  -lws2_32 -Wl,--export-all-symbols -Wl,--out-implib=libpostgis-3.a

comment:10 by robe, 5 years ago

I vaguely remember having this issue before and I think it had to do with the order of libs in SHLIB. I see you have WAYGU lib in front. I'm experimenting to moving it to the end to see if that fixes the issue.

comment:11 by robe, 5 years ago

sadly changing order of things doesn't make a difference, so I think I just got to get rid of the -Wl,—disable-auto-import

I was hunting to see where this is set, but I don't have it set.

I suspect it may be brought in via PostgreSQL, as they have this for win32 and maybe it's being pulled in by PGXS

In the past I've fiddled with that because it caused compilation problems, but then after 9.4 it seemed to not be an issue.

This is what PostgreSQL 12 win32 template has:

# src/template/win32

# --allow-multiple-definition is required to link pg_dump because it finds
# pg_toupper() etc. in both libpq and pgport
# --disable-auto-import is to ensure we get MSVC-like linking behavior
LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition -Wl,--disable-auto-import"

anyway trying to override it in postgis by setting the LDFLAGS with —enable-auto-import doesn't seem to work. So I'll just disable it for now on winnie until we have this sorted out.

I also noticed that —with-wagyu turned on (when I manually compile) my postgis-3.so now has a direct dependency to libstdc++ where as I don't think it did before. I'm not sure if that is going to be an issue or not.

comment:12 by robe, 5 years ago

actually I think I may have had a typo and was able to overwrite the setting. Going thru my steps now and will check to make sure all pass before I make the change to winnie.

comment:13 by robe, 5 years ago

Resolution: fixed
Status: newclosed

In 17456:

Force —enable-auto-import, also get rid of other flag settings not needed with pkgconfig usage.
This is needed for some reason to get wagyu to link (before —disable-auto-import was being dragged in)
Closes #4408

Note: See TracTickets for help on using tickets.