[llvm-bugs] [Bug 41858] New: Spurious “has different definitions in different modules” error

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 13 07:17:38 PDT 2019


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

            Bug ID: 41858
           Summary: Spurious “has different definitions in different
                    modules” error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Modules
          Assignee: unassignedclangbugs at nondot.org
          Reporter: steinar+llvm at gunderson.no
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 21943
  --> https://bugs.llvm.org/attachment.cgi?id=21943&action=edit
Patch on top of MySQL for prototype module support/use

Hi,

I'm trying to convert MySQL to modules as an experiment (both to learn about
modules, and to see if it could help with things like compile times), but I
keep running into error messages that are either wrong or just seem wrong (and
thus should be reworded somehow).

I don't know how to make a minimal sample with anything involving modules (you
can't really give preprocessed files, and this bug seems to involve the
interaction between several build steps), so I'm going to give a small HOWTO on
how to reproduce instead. FWIW, I'm starting on Debian buster, with clang++-9
from experimental (9.0.0-svn358327-1~exp1) and cmake installed.

git clone https://github.com/mysql/mysql-server  # current SHA is 124c7ab1
cd mysql-server
patch -p1 -d . < ~/mysql-module-hacks.diff  # attached to bug
mkdir obj
cd obj
cmake .. -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp/boost -DWITH_ROUTER=0
-DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9
-DCMAKE_CXX_FLAGS="-O2 -fmodules -fmodules-ts"
make -j20 -k  # -k is needed to ignore some issues with code that uses reserved
words etc.

Given some patience, you will eventually get this error:

In module 'MEM_ROOT' imported from
/home/sesse/nmu/mysql-server/sql/sql_class.h:44:
/home/sesse/nmu/mysql-server/include/my_alloc.h:373:13: warning: inline
function 'destroy<list_node>' is not defined [-Wundefined-inline]
inline void destroy(T *ptr) {
            ^
/home/sesse/nmu/mysql-server/sql/sql_list.h:212:5: note: used here
    destroy(*prev);
    ^

However, it's certainly defined; it's defined right there where the compiler
puts the diagnostic! Is this a bug or just a very confusing warning? (It
doesn't happen without modules.) If I remove the inline keyword, it compiles
but then later gives this:

In file included from /home/sesse/nmu/mysql-server/sql/error_handler.h:32:
/home/sesse/nmu/mysql-server/sql/sql_error.h:254:3: error: 'ErrConvString' has
different definitions in different modules; first difference is defined here
found constructor with 1st parameter of type 'const MYSQL_TIME *'
  ErrConvString(const MYSQL_TIME *ltime, uint dec);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sesse/nmu/mysql-server/sql/sql_error.h:254:3: note: but in 'thd' found
constructor with 1st parameter of type 'const MYSQL_TIME *'
  ErrConvString(const MYSQL_TIME *ltime, uint dec);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

These declarations look identical to me; they're even from the same line in the
same file. The only thing I can imagine is that MYSQL_TIME has a different
declaration, but if so, the error really needs to show the difference(s)
between the two more specifically. (I've seen similar issues with GCC and LTO,
where different compilation units specified subtly different definitions of a
struct and caused ODR warnings, and they eventually made these warnings a lot
clearer.) Again, this is either a compiler bug or an unhelpful diagnostic.

Similarly:

In file included from ../sql/create_field.h:32:
../sql/sql_list.h:479:6: error: 'List' has different definitions in different
modules; first difference is defined here found method 'operator[]' with body
  T *operator[](uint index) const {
  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../sql/sql_list.h:479:6: note: but in 'thd' found method 'operator[]' with
different body
  T *operator[](uint index) const {
  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Again, the body is exactly the same as far as I can tell. I thought adding
“config_macros DBUG_OFF, NDEBUG” to all the modules in the module map would
make the error go away, but evidently, it doesn't; there's _something_ about
the DBUG_ASSERT macro, but it's not clear what. I guess the warning in itself
could still be a lot more friendly; in particular, it could list differences in
the active preprocessor flags in the two contexts when giving such an error.

I don't know if this is zero, one, two or three bugs; feel free to split. :-)

-- 
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/20190513/7141624d/attachment.html>


More information about the llvm-bugs mailing list