#6166 closed defect (invalid)
multiple definition errors when compiling with gcc 10 or 11
Reported by: | Andy Alt | Owned by: | |
---|---|---|---|
Priority: | Should Have | Milestone: | |
Component: | Core engine | Keywords: | |
Cc: | Patch: |
Description
A change in gcc 10
GCC now defaults to-fno-common. As a result, global variable accesses are more efficient on various targets. In C, global variables with multiple tentative definitions now result in linker errors. With -fcommon such definitions are silently merged during linking
Tail end of the output when I recently tried compiling with gcc 11:
{{{ precompiled.cpp Linking Collada ==== Building pyrogenesis (release) ==== Creating obj/pyrogenesis_Release main.cpp Linking pyrogenesis /usr/bin/ld: /usr/bin/ld: DWARF error: can't find .debug_ranges section. ../../../binaries/system/libengine.a(Rect.o): in function `CRect::CRect()': Rect.cpp:(.text+0x0): multiple definition of `CRect::CRect()'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:22: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::CRect()': Rect.cpp:(.text+0x0): multiple definition of `CRect::CRect()'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:22: first defined here /usr/bin/ld: /usr/bin/ld: DWARF error: can't find .debug_ranges section. ../../../binaries/system/libengine.a(Rect.o): in function `CRect::CRect(CRect const&)': Rect.cpp:(.text+0x40): multiple definition of `CRect::CRect(CRect const&)'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:27: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::CRect(CRect const&)': Rect.cpp:(.text+0x40): multiple definition of `CRect::CRect(CRect const&)'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:27: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::CRect(float, float, float, float)': Rect.cpp:(.text+0x1b0): multiple definition of `CRect::CRect(float, float, float, float)'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:52: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::CRect(float, float, float, float)': Rect.cpp:(.text+0x1b0): multiple definition of `CRect::CRect(float, float, float, float)'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:52: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::operator=(CRect const&)': Rect.cpp:(.text+0x1f0): multiple definition of `CRect::operator=(CRect const&)'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:58: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::operator==(CRect const&) const': Rect.cpp:(.text+0x230): multiple definition of `CRect::operator==(CRect const&) const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:67: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::operator!=(CRect const&) const': Rect.cpp:(.text+0x2a0): multiple definition of `CRect::operator!=(CRect const&) const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:75: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::operator-() const': Rect.cpp:(.text+0x320): multiple definition of `CRect::operator-() const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:80: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::operator+() const': Rect.cpp:(.text+0x360): multiple definition of `CRect::operator+() const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:85: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::operator+(CRect const&) const': Rect.cpp:(.text+0x3a0): multiple definition of `CRect::operator+(CRect const&) const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:90: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::operator-(CRect const&) const': Rect.cpp:(.text+0x480): multiple definition of `CRect::operator-(CRect const&) const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:105: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::operator+=(CRect const&)': Rect.cpp:(.text+0x560): multiple definition of `CRect::operator+=(CRect const&)'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:120: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::operator-=(CRect const&)': Rect.cpp:(.text+0x640): multiple definition of `CRect::operator-=(CRect const&)'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:144: first defined here /usr/bin/ld: /usr/bin/ld: DWARF error: found dwarf version '1042', this reader only handles version 2, 3, 4 and 5 information ../../../binaries/system/libengine.a(Rect.o): in function `CRect::GetWidth() const': Rect.cpp:(.text+0x720): multiple definition of `CRect::GetWidth() const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:168: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::GetHeight() const': Rect.cpp:(.text+0x760): multiple definition of `CRect::GetHeight() const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:173: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::GetSize() const': Rect.cpp:(.text+0x7a0): multiple definition of `CRect::GetSize() const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:178: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::TopLeft() const': Rect.cpp:(.text+0x800): multiple definition of `CRect::TopLeft() const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:183: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::TopRight() const': Rect.cpp:(.text+0x840): multiple definition of `CRect::TopRight() const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:188: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::BottomLeft() const': Rect.cpp:(.text+0x880): multiple definition of `CRect::BottomLeft() const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:193: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::BottomRight() const': Rect.cpp:(.text+0x8c0): multiple definition of `CRect::BottomRight() const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:198: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::CenterPoint() const': Rect.cpp:(.text+0x900): multiple definition of `CRect::CenterPoint() const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:203: first defined here /usr/bin/ld: ../../../binaries/system/libengine.a(Rect.o): in function `CRect::Scale(float, float) const': Rect.cpp:(.text+0x9b0): multiple definition of `CRect::Scale(float, float) const'; ../../../binaries/system/libengine.a(Shapes.o):/home/andy/src/0ad-svn/build/workspaces/gcc/../../../source/ps/Shapes.cpp:216: first defined here collect2: error: ld returned 1 exit status make[1]: *** [pyrogenesis.make:81: ../../../binaries/system/pyrogenesis] Error 1 make: *** [Makefile:71: pyrogenesis] Error 2 make: Leaving directory '/home/andy/src/0ad-svn/build/workspaces/gcc' }}}
Change History (4)
comment:1 by , 3 years ago
comment:3 by , 3 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:4 by , 3 years ago
Milestone: | Backlog |
---|
Note:
See TracTickets
for help on using tickets.
Andy, you'll need to run
make clean
(or deletebinaries/system/libengine.a
) and try again.(
ps/Shapes.cpp
was renamed tomaths/Rect.cpp
on March 30th - r25165.)