DISTRHO / Cardinal

Virtual modular synthesizer plugin
https://cardinal.kx.studio/
GNU General Public License v3.0
2.27k stars 155 forks source link

Eigen odr violation #544

Closed iv-m closed 1 year ago

iv-m commented 1 year ago

I'm trying to build freshly-released Cardinal 23.07 with gcc13 and LTO enabled, and I'm getting the following error:

[...]
Creating JACK standalone for Cardinal
g++ ../../build/Cardinal/CardinalPlugin.cpp.o ../../build/Cardinal/CardinalCommon.cpp.o ../../build/Cardinal/CardinalRemote.cpp.o ../../build/Cardinal/common.cpp.o ../../build/Cardinal/CardinalUI.cpp.o ../../build/Cardinal/glfw.cpp.o ../../build/Cardinal/MenuBar.cpp.o ../../build/Cardinal/Window.cpp.o ../../build/Cardinal/DistrhoPluginMain_JACK.cpp.o ../../build/Cardinal/DistrhoUIMain_JACK.cpp.o ../../dpf/build/libdgl-opengl.a -Wall -Wextra -pipe -MD -MP -fno-gnu-unique -g -fPIC -DPIC -DNDEBUG -O2 -ffast-math -fdata-sections -ffunction-sections -fvisibility=hidden -fno-strict-aliasing -flto -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/include -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/include/simd-compat -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/sysroot/include -DCARDINAL_SYSDEPS  -pthread -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src/Rack/dep/simde -DSIMDE_ACCURACY_PREFERENCE=0 -DSIMDE_FAST_CONVERSION_RANGE -DSIMDE_FAST_MATH -DSIMDE_FAST_NANS -DSIMDE_FAST_ROUND_MODE -DSIMDE_FAST_ROUND_TIES -DSIMDE_X86_SSE4_1_H -DSIMDE_X86_SSE4_2_H -Wno-unused-parameter -Wno-unused-variable -DARCH_LIN -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/dpf/dgl/src/nanovg -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/dpf/distrho -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src/Rack/include -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src/Rack/include/dsp -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src/Rack/dep/filesystem/include -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src/Rack/dep/fuzzysearchdatabase/src -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src/Rack/dep/glfw/include -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src/Rack/dep/nanosvg/src -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src/Rack/dep/oui-blendish -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src/Rack/dep/pffft -I/tmp/.private/iv/RPM/BUILD/Cardinal-23.07/src/Rack/dep/tinyexpr -DHAVE_JACK -DHAVE_LIBLO -DHAVE_OPENGL -DDGL_OPENGL -DHAVE_DGL -DHAVE_X11 -DHAVE_XCURSOR -DHAVE_XEXT -DHAVE_XSYNC -DHAVE_XRANDR  -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -DHAVE_DBUS  -DHAVE_X11  -DHAVE_XCURSOR  -DHAVE_XEXT -DHAVE_XSYNC  -DHAVE_XRANDR -DHAVE_CAIRO -DHAVE_OPENGL -DDGL_OPENGL -DHAVE_DGL  -DPRIVATE=  -std=gnu++11 -fvisibility-inlines-hidden -fexceptions -DDISTRHO_NAMESPACE=CardinalDISTRHO -DDGL_NAMESPACE=CardinalDGL -DNVG_DISABLE_SKIPPING_WHITESPACE -DNVG_FONT_TEXTURE_FLAGS=NVG_IMAGE_NEAREST -DDGL_WINDOWS_ICON_ID=401 -DDGL_USE_NANOVG_FBO -fno-finite-math-only -fno-strict-aliasing -U_GLIBCXX_ASSERTIONS -Wp,-U_GLIBCXX_ASSERTIONS -Wno-format-security -faligned-new -Wno-abi -I. -I../../dpf/distrho -I../../dpf/dgl -DCARDINAL_PLUGIN_PREFIX='"/usr"' -fdata-sections -ffunction-sections -Wl,-O1,--as-needed,--gc-sections -fno-strict-aliasing -flto -Werror=odr -Werror=lto-type-mismatch  -Wl,--no-undefined -fexceptions -ldl -pthread -ldl -Wno-alloc-size-larger-than  ../../plugins/plugins.a ../rack.a /tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/surge-build/src/common/libsurge-common.a /tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/surge-build/src/common/libjuce_dsp_rack_sub.a /tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/surge-build/libs/airwindows/libairwindows.a /tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/surge-build/libs/eurorack/libeurorack.a /tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/surge-build/libs/sqlite-3.23.3/libsqlite.a /tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/surge-build/libs/sst/sst-plugininfra/libsst-plugininfra.a /tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/surge-build/libs/sst/sst-plugininfra/libs/filesystem/libfilesystem.a /tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/surge-build/libs/sst/sst-plugininfra/libs/strnatcmp/libstrnatcmp.a /tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/surge-build/libs/sst/sst-plugininfra/libs/tinyxml/libtinyxml.a /tmp/.private/iv/RPM/BUILD/Cardinal-23.07/deps/sysroot/lib/libquickjs.a ../../carla/build/plugin/Release/carla-host-plugin.cpp.o ../../carla/build/modules/Release/carla_engine_plugin.a ../../carla/build/modules/Release/carla_plugin.a ../../carla/build/modules/Release/native-plugins.a ../../carla/build/modules/Release/audio_decoder.a ../../carla/build/modules/Release/jackbridge.min.a ../../carla/build/modules/Release/lilv.a ../../carla/build/modules/Release/rtmempool.a ../../carla/build/modules/Release/water.a ../../carla/build/modules/Release/ysfx.a ../../carla/build/modules/Release/zita-resampler.a -lfmt  -lsndfile -lGL -lX11 -lXcursor -lXext -lXrandr -lGL -lX11 -ldbus-1 -lX11 -lXcursor -lXext -lXrandr -lm  -lsndfile   -llo -lpthread -ldl -lm -lrt  -pthread -lrt -ldl -pthread -lrt  ../../deps/aubio/libaubio.a -lfftw3f -ljansson -larchive -lsamplerate -lspeexdsp -llo -lpthread  -lGL -lX11 -lXcursor -lXext -lXrandr -lGL -lX11 -ldbus-1 -lX11 -lXcursor -lXext -lXrandr -lm  -o ../../bin/Cardinal
../../plugins/Cardinal/src/AIDA-X/RTNeural/modules/Eigen/Eigen/src/Core/util/XprHelper.h:123:39: error: type 'struct variable_if_dynamic' violates the C++ One Definition Rule [-Werror=odr]
  123 | template<typename T, int Value> class variable_if_dynamic
      |                                       ^
../../plugins/ChowDSP/lib/Eigen/src/Core/util/XprHelper.h:106: note: one type needs to be constructed while the other does not
  106 | template<typename T, int Value> class variable_if_dynamic
      | 
../../plugins/Cardinal/src/AIDA-X/RTNeural/modules/Eigen/Eigen/src/Core/util/XprHelper.h:123:39: error: type 'struct variable_if_dynamic' violates the C++ One Definition Rule [-Werror=odr]
  123 | template<typename T, int Value> class variable_if_dynamic
      |                                       ^
../../plugins/ChowDSP/lib/Eigen/src/Core/util/XprHelper.h:106: note: one type needs to be constructed while the other does not
  106 | template<typename T, int Value> class variable_if_dynamic
      | 
../../plugins/Cardinal/src/AIDA-X/RTNeural/modules/Eigen/Eigen/src/Core/Stride.h:54:7: error: type 'struct Stride' violates the C++ One Definition Rule [-Werror=odr]
   54 | class Stride
      |       ^
../../plugins/ChowDSP/lib/Eigen/src/Core/Stride.h:44: note: a different type is defined in another translation unit
   44 | class Stride
      | 
../../plugins/Cardinal/src/AIDA-X/RTNeural/modules/Eigen/Eigen/src/Core/Stride.h:94:68: note: the first difference of corresponding definitions is field 'm_outer'
   94 |     internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer;
      |                                                                    ^
../../plugins/ChowDSP/lib/Eigen/src/Core/Stride.h:83: note: a field of same name but different type is defined in another translation unit
   83 |     internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer;
      | 
../../plugins/Cardinal/src/AIDA-X/RTNeural/modules/Eigen/Eigen/src/Core/util/XprHelper.h:123:39: note: type 'struct variable_if_dynamic' itself violates the C++ One Definition Rule
  123 | template<typename T, int Value> class variable_if_dynamic
      |                                       ^
../../plugins/ChowDSP/lib/Eigen/src/Core/util/XprHelper.h:106: note: the incompatible type is defined here
  106 | template<typename T, int Value> class variable_if_dynamic
      | 
../../plugins/Cardinal/src/AIDA-X/RTNeural/modules/Eigen/Eigen/src/Core/DenseStorage.h:209:74: error: type 'struct DenseStorage' violates the C++ One Definition Rule [-Werror=odr]
  209 | template<typename T, int Size, int Rows_, int Cols_, int Options_> class DenseStorage
      |                                                                          ^
../../plugins/ChowDSP/lib/Eigen/src/Core/DenseStorage.h:183: note: one type needs to be constructed while the other does not
  183 | template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage
      | 
../../plugins/Cardinal/src/AIDA-X/RTNeural/modules/Eigen/Eigen/src/Core/PlainObjectBase.h:100:7: error: type 'struct PlainObjectBase' violates the C++ One Definition Rule [-Werror=odr]
  100 | class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
      |       ^
../../plugins/ChowDSP/lib/Eigen/src/Core/PlainObjectBase.h:98: note: a different type is defined in another translation unit
   98 | class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
      | 
../../plugins/Cardinal/src/AIDA-X/RTNeural/modules/Eigen/Eigen/src/Core/PlainObjectBase.h:133:113: note: the first difference of corresponding definitions is field 'm_storage'
  133 |     DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;
      |                                                                                                                 ^
../../plugins/ChowDSP/lib/Eigen/src/Core/PlainObjectBase.h:139: note: a field of same name but different type is defined in another translation unit
  139 |     DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;
      | 
../../plugins/Cardinal/src/AIDA-X/RTNeural/modules/Eigen/Eigen/src/Core/DenseStorage.h:209:74: note: type 'struct DenseStorage' itself violates the C++ One Definition Rule
  209 | template<typename T, int Size, int Rows_, int Cols_, int Options_> class DenseStorage
      |                                                                          ^
../../plugins/ChowDSP/lib/Eigen/src/Core/DenseStorage.h:183: note: the incompatible type is defined here
  183 | template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage
      | 
../../plugins/Cardinal/src/AIDA-X/RTNeural/modules/Eigen/Eigen/src/Core/Matrix.h:188:7: error: type 'struct Matrix' violates the C++ One Definition Rule [-Werror=odr]
  188 | class Matrix
      |       ^
../../plugins/ChowDSP/lib/Eigen/src/Core/Matrix.h:178: note: a type with different bases is defined in another translation unit
  178 | class Matrix
      | 
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/x86_64-alt-linux-g++ returned 1 exit status
compilation terminated.
ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[2]: *** [../../dpf/Makefile.plugins.mk:483: ../../bin/Cardinal] Error 1
[...]

Apparently, Eigen from ChowDsp conflicts with Eighen from RTNeural brought in by Aida.

iv-m commented 1 year ago

This seems to fix the issue, the build goes on:

--- a/plugins/Makefile
+++ b/plugins/Makefile
@@ -1317,6 +1317,7 @@ RTNEURAL_FLAGS  = -std=gnu++17
 RTNEURAL_FLAGS += -DBiquad=AidaBiquad
 RTNEURAL_FLAGS += -Dconst_blas_data_mapper=Aida_const_blas_data_mapper
 RTNEURAL_FLAGS += -Devaluator=Aida_evaluator
+RTNEURAL_FLAGS += -DEigen=Aida_Eigen
 RTNEURAL_FLAGS += -DSKIP_MINGW_FORMAT
 RTNEURAL_FLAGS += -DRTNEURAL_DEFAULT_ALIGNMENT=16
 RTNEURAL_FLAGS += -DRTNEURAL_USE_EIGEN=1

The idea is to move Aida's Eigen to a different namespace.

falkTX commented 1 year ago

I wonder how come the CI didnt catch this, there is an LTO build to be able to get these kind of errors before a release.

the patch makes sense, I will apply it on the repo. but release is tagged now, so a bit too late now

falkTX commented 1 year ago

Fixed in 5276b1eb919b6f913fe69292f95ca9c0bfd23457 thanks!