[llvm-bugs] [Bug 45322] New: clang -O2 doesn't export the same symbols as gcc with virtual destructor

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 26 16:13:51 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45322

            Bug ID: 45322
           Summary: clang -O2 doesn't export the same symbols as gcc with
                    virtual destructor
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: sylvestre at debian.org
                CC: llvm-bugs at lists.llvm.org

Happening on a bunch of cases here:
https://clang.debian.net/status.php?version=9.0.1&key=CHANGE_SYM_LIB

Probably not a recent issue

=== a.cpp ===
#include <stddef.h>
namespace pugi {
class xml_writer {
public:
  virtual ~xml_writer() {}
};
class a : xml_writer {
  virtual void b(const void *, size_t);
};
void a::b(const void *, size_t) {}
} // namespace pugi


=== script

ARG="  -O2 -o pugixml.cpp.o -c a.cpp"

CXX=/usr/bin/clang++
$CXX $ARG
mv pugixml.cpp.o clang.o


CXX=/usr/bin/g++-9
$CXX $ARG
mv pugixml.cpp.o gcc.o

nm clang.o |grep -q N4pugi10xml_writerD2Ev
nm gcc.o |grep -q  N4pugi10xml_writerD2Ev

===
Will show:

nm clang.o |grep N4pugi10xml_writerD2Ev
0000000000000000 W _ZN4pugi10xml_writerD2Ev
nm gcc.o |grep  N4pugi10xml_writerD2Ev

=== 
without -O2, gcc will generate the symbol too.

maybe clang should remove too when -O2 is used?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200326/1d345004/attachment.html>


More information about the llvm-bugs mailing list