2

I'm trying to build elements library after few recent changes and can not make it link.

My toolchain:

  • GCC 9.2.1 with MCF threads
  • CMake 3.16.4

The commit that breaks the build: https://github.com/cycfi/elements/commit/104cef3cc19bf6f568b233a29679135a2c1f06ca

Relevant issue: https://github.com/cycfi/elements/issues/69

compiler flags: -DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_UNICODE @CMakeFiles/Buttons.dir/includes_CXX.rsp -O3 -DNDEBUG -flto -fno-fat-lto-objects -std=gnu++17

error message:

[ 68%] Linking CXX executable Buttons.exe
cd /d D:\Files\C++\workspace_windows\elements_fork\build_fork\examples\buttons && "C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\Buttons.dir\link.txt --verbose=1
"C:\Program Files\CMake\bin\cmake.exe" -E remove -f CMakeFiles\Buttons.dir/objects.a
C:\mingw64\mingw64\bin\gcc-ar.exe cr CMakeFiles\Buttons.dir/objects.a @CMakeFiles\Buttons.dir\objects1.rsp
C:\mingw64\mingw64\bin\g++.exe -O3 -DNDEBUG -flto -fno-fat-lto-objects  -mwindows -Wl,--whole-archive CMakeFiles\Buttons.dir/objects.a -Wl,--no-whole-archive  -o Buttons.exe -Wl,--out-implib,libButtons.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles\Buttons.dir\linklibs.rsp
C:/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.1/../../../../x86_64-w64-mingw32/bin/ld.exe: radio_button.cpp.obj (symbol from plugin):(.gnu.linkonce.t._ZN5cycfi8elements18basic_radio_buttonD1Ev[_ZThn208_N5cycfi8elements18basic_radio_buttonD1Ev]+0x0): multiple definition of `cycfi::elements::basic_radio_button::~basic_radio_button()'; main.cpp.obj (symbol from plugin):(.gnu.linkonce.t._ZN5cycfi8elements18basic_radio_buttonD1Ev[_ZThn24_N5cycfi8elements18basic_radio_buttonD1Ev]+0x0): first defined here
C:/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.1/../../../../x86_64-w64-mingw32/bin/ld.exe: radio_button.cpp.obj (symbol from plugin):(.gnu.linkonce.t._ZN5cycfi8elements18basic_radio_buttonD1Ev[_ZThn208_N5cycfi8elements18basic_radio_buttonD1Ev]+0x0): multiple definition of `non-virtual thunk to cycfi::elements::basic_radio_button::~basic_radio_button()'; main.cpp.obj (symbol from plugin):(.gnu.linkonce.t._ZN5cycfi8elements18basic_radio_buttonD1Ev[_ZThn24_N5cycfi8elements18basic_radio_buttonD1Ev]+0x0): first defined here
C:/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.1/../../../../x86_64-w64-mingw32/bin/ld.exe: radio_button.cpp.obj (symbol from plugin):(.gnu.linkonce.t._ZN5cycfi8elements18basic_radio_buttonD1Ev[_ZThn208_N5cycfi8elements18basic_radio_buttonD1Ev]+0x0): multiple definition of `non-virtual thunk to cycfi::elements::basic_radio_button::~basic_radio_button()'; main.cpp.obj (symbol from plugin):(.gnu.linkonce.t._ZN5cycfi8elements18basic_radio_buttonD1Ev[_ZThn24_N5cycfi8elements18basic_radio_buttonD1Ev]+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

Current observations:

Xeverous
  • 973
  • 1
  • 12
  • 25
  • 1
    LTO is generally non-functional for MinGW targets due to issues like this. I would save yourself the trouble and disable it. The version of you linker will also be relevant to figuring out what is going wrong here. What version of binutils are you using? – rubenvb Mar 09 '20 at 12:42
  • I reproduced this both with GCC 8.3.1 + GNU ld 2.30 and GCC 9.2.1 + GNU ld 2.33.1. Not sure where I would check the binutils version. – Xeverous Mar 09 '20 at 13:17
  • The `ld` version is the binutils version. So at least it still occurs with version 2.33.1. I would consider reporting a binutils bug. This would require some simple repro case though. You can probably throw away everything in your code except the symbols it's complaining about and use that. – rubenvb Mar 09 '20 at 13:24
  • Threw away all other classes, stripped the library to roughly 10-15 classes, does not reproduce. I guess optimization-related reproduction is going to be really hard to hit given error case considering inlining and other optimizations that behave differently on different code sizes. Got any other ideas? – Xeverous Mar 09 '20 at 21:46
  • Well, I guess a big repro is better than none. Perhaps the binutils folks have a better idea how to figure this out. Just don't hold your breath, MinGW isn't a high-activity development target. – rubenvb Mar 10 '20 at 09:00

0 Answers0