https://sourceware.org/bugzilla/show_bug.cgi?id=26678
Bug ID: 26678 Summary: construction vtable defined in a discarded section Product: binutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: gold Assignee: ccoutant at gmail dot com Reporter: cassio.neri at gmail dot com CC: ian at airs dot com Target Milestone: --- This might be a compiler bug but I get the felling it's the linker. To reproduce you need g++ and clang++ and a quite strange example spread across 3 files: // a.hpp struct A { int i; ~A() { asm("" : "=r"(i)); } }; struct B : public virtual A { }; struct C : public B { }; struct D { D(C); }; // a.cpp #include "a.hpp" void f(C) { } D::D(C c) { f(c); } // main.cpp #include "a.hpp" int main() { C c; D d(c); } Build with: g++ -O3 -fPIC -c a.cpp clang++ -O3 -fPIC -c main.cpp clang++ -fuse-ld=gold main.o a.o -o main The output is: a.o:a.cpp:function D::D(C) [clone .cold]: error: relocation refers to global symbol "construction vtable for B-in-C", which is defined in a discarded section section group signature: "_ZTV1C" prevailing definition is from main.o clang-10: error: linker command failed with exit code 1 (use -v to see invocation) FWIW: All the ingredients in the example seem relevant (asm, virtual inheritance, levels of indirection, compiler flags) and the issue goes away if any is removed. More notable changes that make the issue go away are: 1. Use the same compiler for all TUs, (It doesn't matter whether g++ or clang++.) 2. Link with ld (i.e., remove -fuse-ld=gold) 3. Compile main.cpp without -O3. 4. Compile main.cpp without -fPIC. 5. Swap a.o and main.o in the linker command line. For more information: https://stackoverflow.com/q/64118757/1137388 -- You are receiving this mail because: You are on the CC list for the bug.