Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with LTO (odr violations) #1054

Open
eli-schwartz opened this issue Mar 14, 2024 · 0 comments
Open

Build fails with LTO (odr violations) #1054

eli-schwartz opened this issue Mar 14, 2024 · 0 comments

Comments

@eli-schwartz
Copy link

I tried to build with the following *FLAGS to optimize the build: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

Note the -Werror=* flags are used to help detect cases where the compiler tries to optimize by assuming UB cannot exist in the source code -- if it does exist, ordinarily the code would be miscompiled, and this says to make the miscompilation a fatal error.

I got this error:

FAILED: lib/libgeos_c.so.1.18.1 
: && /usr/bin/x86_64-pc-linux-gnu-g++ -fPIC -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security  -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -shared -Wl,-soname,libgeos_c.so.1 -o lib/libgeos_c.so.1.18.1 CMakeFiles/geos_c.dir/capi/geos_c.cpp.o CMakeFiles/geos_c.dir/capi/geos_ts_c.cpp.o  -Wl,-rpath,/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/lib:  lib/libgeos.so.3.12.1 && :
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:665:31: error: ‘GEOSBufferWithParams_r’ violates the C++ One Definition Rule [-Werror=odr]
  665 | extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams_r(
      |                               ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:4033:5: note: type mismatch in parameter 3
 4033 |     GEOSBufferWithParams_r(GEOSContextHandle_t extHandle, const Geometry* g1, const BufferParameters* bp, double width)
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:4033:5: note: type name ‘geos::operation::buffer::BufferParameters’ should match type name ‘GEOSBufParams_t’
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:4033:5: note: ‘GEOSBufferWithParams_r’ was previously declared here
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:659:21: error: ‘GEOSBufferParams_setSingleSided_r’ violates the C++ One Definition Rule [-Werror=odr]
  659 | extern int GEOS_DLL GEOSBufferParams_setSingleSided_r(
      |                     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:4023:5: note: type mismatch in parameter 2
 4023 |     GEOSBufferParams_setSingleSided_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/include/geos/operation/buffer/BufferParameters.h:56:16: note: type name ‘geos::operation::buffer::BufferParameters’ should match type name ‘GEOSBufParams_t’
   56 | class GEOS_DLL BufferParameters {
      |                ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:4023:5: note: ‘GEOSBufferParams_setSingleSided_r’ was previously declared here
 4023 |     GEOSBufferParams_setSingleSided_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:653:21: error: ‘GEOSBufferParams_setQuadrantSegments_r’ violates the C++ One Definition Rule [-Werror=odr]
  653 | extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments_r(
      |                     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:4013:5: note: type mismatch in parameter 2
 4013 |     GEOSBufferParams_setQuadrantSegments_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/include/geos/operation/buffer/BufferParameters.h:56:16: note: type name ‘geos::operation::buffer::BufferParameters’ should match type name ‘GEOSBufParams_t’
   56 | class GEOS_DLL BufferParameters {
      |                ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:4013:5: note: ‘GEOSBufferParams_setQuadrantSegments_r’ was previously declared here
 4013 |     GEOSBufferParams_setQuadrantSegments_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:647:21: error: ‘GEOSBufferParams_setMitreLimit_r’ violates the C++ One Definition Rule [-Werror=odr]
  647 | extern int GEOS_DLL GEOSBufferParams_setMitreLimit_r(
      |                     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:4003:5: note: type mismatch in parameter 2
 4003 |     GEOSBufferParams_setMitreLimit_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/include/geos/operation/buffer/BufferParameters.h:56:16: note: type name ‘geos::operation::buffer::BufferParameters’ should match type name ‘GEOSBufParams_t’
   56 | class GEOS_DLL BufferParameters {
      |                ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:4003:5: note: ‘GEOSBufferParams_setMitreLimit_r’ was previously declared here
 4003 |     GEOSBufferParams_setMitreLimit_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:641:21: error: ‘GEOSBufferParams_setJoinStyle_r’ violates the C++ One Definition Rule [-Werror=odr]
  641 | extern int GEOS_DLL GEOSBufferParams_setJoinStyle_r(
      |                     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:3989:5: note: type mismatch in parameter 2
 3989 |     GEOSBufferParams_setJoinStyle_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/include/geos/operation/buffer/BufferParameters.h:56:16: note: type name ‘geos::operation::buffer::BufferParameters’ should match type name ‘GEOSBufParams_t’
   56 | class GEOS_DLL BufferParameters {
      |                ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:3989:5: note: ‘GEOSBufferParams_setJoinStyle_r’ was previously declared here
 3989 |     GEOSBufferParams_setJoinStyle_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:635:21: error: ‘GEOSBufferParams_setEndCapStyle_r’ violates the C++ One Definition Rule [-Werror=odr]
  635 | extern int GEOS_DLL GEOSBufferParams_setEndCapStyle_r(
      |                     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:3976:5: note: type mismatch in parameter 2
 3976 |     GEOSBufferParams_setEndCapStyle_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/include/geos/operation/buffer/BufferParameters.h:56:16: note: type name ‘geos::operation::buffer::BufferParameters’ should match type name ‘GEOSBufParams_t’
   56 | class GEOS_DLL BufferParameters {
      |                ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:3976:5: note: ‘GEOSBufferParams_setEndCapStyle_r’ was previously declared here
 3976 |     GEOSBufferParams_setEndCapStyle_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:630:22: error: ‘GEOSBufferParams_destroy_r’ violates the C++ One Definition Rule [-Werror=odr]
  630 | extern void GEOS_DLL GEOSBufferParams_destroy_r(
      |                      ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:3969:5: note: type mismatch in parameter 2
 3969 |     GEOSBufferParams_destroy_r(GEOSContextHandle_t extHandle, BufferParameters* p)
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/include/geos/operation/buffer/BufferParameters.h:56:16: note: type name ‘geos::operation::buffer::BufferParameters’ should match type name ‘GEOSBufParams_t’
   56 | class GEOS_DLL BufferParameters {
      |                ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:3969:5: note: ‘GEOSBufferParams_destroy_r’ was previously declared here
 3969 |     GEOSBufferParams_destroy_r(GEOSContextHandle_t extHandle, BufferParameters* p)
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:626:35: error: ‘GEOSBufferParams_create_r’ violates the C++ One Definition Rule [-Werror=odr]
  626 | extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create_r(
      |                                   ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:3961:5: note: return value type mismatch
 3961 |     GEOSBufferParams_create_r(GEOSContextHandle_t extHandle)
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/include/geos/operation/buffer/BufferParameters.h:56:16: note: type name ‘geos::operation::buffer::BufferParameters’ should match type name ‘GEOSBufParams_t’
   56 | class GEOS_DLL BufferParameters {
      |                ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:3961:5: note: ‘GEOSBufferParams_create_r’ was previously declared here
 3961 |     GEOSBufferParams_create_r(GEOSContextHandle_t extHandle)
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:1478:31: error: ‘GEOSMakeValidWithParams_r’ violates the C++ One Definition Rule [-Werror=odr]
 1478 | extern GEOSGeometry GEOS_DLL *GEOSMakeValidWithParams_r(
      |                               ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2203:5: note: type mismatch in parameter 3
 2203 |     GEOSMakeValidWithParams_r(
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2203:5: note: type name ‘GEOSMakeValidParams’ should match type name ‘GEOSMakeValidParams_t’
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2203:5: note: ‘GEOSMakeValidWithParams_r’ was previously declared here
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:1461:21: error: ‘GEOSMakeValidParams_setKeepCollapsed_r’ violates the C++ One Definition Rule [-Werror=odr]
 1461 | extern int GEOS_DLL GEOSMakeValidParams_setKeepCollapsed_r(
      |                     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2183:5: note: type mismatch in parameter 2
 2183 |     GEOSMakeValidParams_setKeepCollapsed_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:138:3: note: type name ‘GEOSMakeValidParams’ should match type name ‘GEOSMakeValidParams_t’
  138 | } GEOSMakeValidParams;
      |   ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2183:5: note: ‘GEOSMakeValidParams_setKeepCollapsed_r’ was previously declared here
 2183 |     GEOSMakeValidParams_setKeepCollapsed_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:1467:21: error: ‘GEOSMakeValidParams_setMethod_r’ violates the C++ One Definition Rule [-Werror=odr]
 1467 | extern int GEOS_DLL GEOSMakeValidParams_setMethod_r(
      |                     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2193:5: note: type mismatch in parameter 2
 2193 |     GEOSMakeValidParams_setMethod_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:138:3: note: type name ‘GEOSMakeValidParams’ should match type name ‘GEOSMakeValidParams_t’
  138 | } GEOSMakeValidParams;
      |   ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2193:5: note: ‘GEOSMakeValidParams_setMethod_r’ was previously declared here
 2193 |     GEOSMakeValidParams_setMethod_r(GEOSContextHandle_t extHandle,
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:1456:22: error: ‘GEOSMakeValidParams_destroy_r’ violates the C++ One Definition Rule [-Werror=odr]
 1456 | extern void GEOS_DLL GEOSMakeValidParams_destroy_r(
      |                      ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2176:5: note: type mismatch in parameter 2
 2176 |     GEOSMakeValidParams_destroy_r(GEOSContextHandle_t extHandle, GEOSMakeValidParams* parms)
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:138:3: note: type name ‘GEOSMakeValidParams’ should match type name ‘GEOSMakeValidParams_t’
  138 | } GEOSMakeValidParams;
      |   ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2176:5: note: ‘GEOSMakeValidParams_destroy_r’ was previously declared here
 2176 |     GEOSMakeValidParams_destroy_r(GEOSContextHandle_t extHandle, GEOSMakeValidParams* parms)
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1_build/capi/geos_c.h:1452:38: error: ‘GEOSMakeValidParams_create_r’ violates the C++ One Definition Rule [-Werror=odr]
 1452 | extern GEOSMakeValidParams GEOS_DLL *GEOSMakeValidParams_create_r(
      |                                      ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2165:5: note: return value type mismatch
 2165 |     GEOSMakeValidParams_create_r(GEOSContextHandle_t extHandle)
      |     ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:138:3: note: type name ‘GEOSMakeValidParams’ should match type name ‘GEOSMakeValidParams_t’
  138 | } GEOSMakeValidParams;
      |   ^
/var/tmp/portage/sci-libs/geos-3.12.1/work/geos-3.12.1/capi/geos_ts_c.cpp:2165:5: note: ‘GEOSMakeValidParams_create_r’ was previously declared here
 2165 |     GEOSMakeValidParams_create_r(GEOSContextHandle_t extHandle)
      |     ^
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-g++ returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Previously reported downstream: https://bugs.gentoo.org/862702
Full build log: build.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant