llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.61k stars 11.35k forks source link

ODR warnings in lldb/include/lldb/Utility/Cloneable.h #83636

Open thesamesam opened 5 months ago

thesamesam commented 5 months ago

When building with -flto -Werror=odr to find possible runtime issues w/ LTO:

/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: error: virtual table of type ‘struct Cloneable’ violates one definition rule [-Werror=odr]
   40 | class Cloneable : public Base {
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: note: the conflicting type defined in another translation unit
   40 | class Cloneable : public Base {
<built-in>: note: virtual method ‘__cxa_pure_virtual’
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Interpreter/OptionValue.h:93:29: note: ought to match virtual method ‘ToJSON’ but does not
   93 |   virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) {
      |                             ^
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: error: virtual table of type ‘struct Cloneable’ violates one definition rule [-Werror=odr]
   40 | class Cloneable : public Base {
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: note: the conflicting type defined in another translation unit
   40 | class Cloneable : public Base {
<built-in>: note: virtual method ‘__cxa_pure_virtual’
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Interpreter/OptionValue.h:93:29: note: ought to match virtual method ‘ToJSON’ but does not
   93 |   virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) {
      |                             ^
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: error: virtual table of type ‘struct Cloneable’ violates one definition rule [-Werror=odr]
   40 | class Cloneable : public Base {
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: note: the conflicting type defined in another translation unit
   40 | class Cloneable : public Base {
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Interpreter/OptionValue.h:93:29: note: virtual method ‘ToJSON’
   93 |   virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) {
      |                             ^
<built-in>: note: ought to match virtual method ‘__cxa_pure_virtual’ but does not
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: error: virtual table of type ‘struct Cloneable’ violates one definition rule [-Werror=odr]
   40 | class Cloneable : public Base {
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: note: the conflicting type defined in another translation unit
   40 | class Cloneable : public Base {
/var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Interpreter/OptionValue.h:93:29: note: virtual method ‘ToJSON’
   93 |   virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) {
      |                             ^
<built-in>: note: ought to match virtual method ‘__cxa_pure_virtual’ but does not
[...]

Originally reported downstream at https://bugs.gentoo.org/858389.

llvmbot commented 5 months ago

@llvm/issue-subscribers-lldb

Author: Sam James (thesamesam)

When building with `-flto -Werror=odr` to find possible runtime issues w/ LTO: ``` /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: error: virtual table of type ‘struct Cloneable’ violates one definition rule [-Werror=odr] 40 | class Cloneable : public Base { /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: note: the conflicting type defined in another translation unit 40 | class Cloneable : public Base { <built-in>: note: virtual method ‘__cxa_pure_virtual’ /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Interpreter/OptionValue.h:93:29: note: ought to match virtual method ‘ToJSON’ but does not 93 | virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) { | ^ /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: error: virtual table of type ‘struct Cloneable’ violates one definition rule [-Werror=odr] 40 | class Cloneable : public Base { /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: note: the conflicting type defined in another translation unit 40 | class Cloneable : public Base { <built-in>: note: virtual method ‘__cxa_pure_virtual’ /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Interpreter/OptionValue.h:93:29: note: ought to match virtual method ‘ToJSON’ but does not 93 | virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) { | ^ /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: error: virtual table of type ‘struct Cloneable’ violates one definition rule [-Werror=odr] 40 | class Cloneable : public Base { /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: note: the conflicting type defined in another translation unit 40 | class Cloneable : public Base { /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Interpreter/OptionValue.h:93:29: note: virtual method ‘ToJSON’ 93 | virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) { | ^ <built-in>: note: ought to match virtual method ‘__cxa_pure_virtual’ but does not /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: error: virtual table of type ‘struct Cloneable’ violates one definition rule [-Werror=odr] 40 | class Cloneable : public Base { /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Utility/Cloneable.h:40: note: the conflicting type defined in another translation unit 40 | class Cloneable : public Base { /var/tmp/portage/dev-debug/lldb-17.0.6/work/lldb/include/lldb/Interpreter/OptionValue.h:93:29: note: virtual method ‘ToJSON’ 93 | virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) { | ^ <built-in>: note: ought to match virtual method ‘__cxa_pure_virtual’ but does not [...] ``` Originally reported downstream at https://bugs.gentoo.org/858389.
xgupta commented 2 months ago

I am using the trunk(ac404632f991fc6e7dc75ef553a99676ba8002ce) and was not able to reproduce the issue/warnings with this cmake command - cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_LINKER=lld -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE -DLLVM_BUILD_TOOLS=ON -DLLVM_ENABLE_PROJECTS="clang;lld;lldb" -DLLVM_BUILD_EXAMPLES=ON -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_FLAGS="-flto -Werror=odr -Werror=strict-aliasing" -DCMAKE_CXX_FLAGS="-flto -Werror=odr -Werror=strict-aliasing"