[MDEV-18677] clang 7 fails to compile innodb Created: 2019-02-21 Updated: 2019-02-21 Resolved: 2019-02-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Compiling, Storage Engine - InnoDB |
| Affects Version/s: | 10.4 |
| Fix Version/s: | 10.4.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladislav Vaintroub | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
C:\PROGRA~1\LLVM\bin\clang-cl.exe /nologo -TP -DBTR_CUR_ADAPT -DBTR_CUR_HASH_ADAPT -DCOMPILER_HINTS -DHAVE_CONFIG_H -DMUTEX_EVENT -DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_WIN32_WINNT=0x0A00 -D_WINDOWS -D_WIN_ -Iinclude -I..\storage\innobase\include -I..\storage\innobase\handler -I..\libbinlogevents\include -I..\include -I..\sql -Ipcre -I..\pcre -I..\extra\yassl\include -I..\extra\yassl\taocrypt\include -I..\zlib -Izlib /DWIN32 /D_WINDOWS /W3 /GR /EHsc -Wno-unused-parameter -Wno-unused-command-line-argument -Wno-pointer-sign -Wno-deprecated-register -Wno-missing-braces -Wno-unused-function -msse4.2 /we4099 /we4700 /we4311 /we4477 /we4302 /we4090 /MD /Z7 /O2 /Ob1 /DNDEBUG -DDBUG_OFF /wd4065 /showIncludes /Fostorage\innobase\CMakeFiles\innobase.dir\sync\sync0rw.cc.obj /Fdstorage\innobase\CMakeFiles\innobase.dir\innobase.pdb -c ..\storage\innobase\sync\sync0rw.cc |
| Comments |
| Comment by Marko Mäkelä [ 2019-02-21 ] | |||||||||||||||||||||||||||||||||||||
|
For what it is worth, I have been successfully using clang 7.0.1 and 8.0.0 on Debian GNU/Linux.
wlad, how does the definition look like in your environment, and what does the standard say about the existence of default constructors and destructors? | |||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2019-02-21 ] | |||||||||||||||||||||||||||||||||||||
|
Why would we use a default constructor in a counter? Do we want counter to be initialized to any value? | |||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2019-02-21 ] | |||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2019-02-21 ] | |||||||||||||||||||||||||||||||||||||
|
marko, that https://github.com/MariaDB/server/commit/f80bfae822b588614bf880887b3bb61adc4185b8 would be my fix. I do not even have to initialize atomic value, but I believe it should be 0 in the given usage. The usage of union was also questionable, why to use padding if there is MY_ALIGN. | |||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-02-21 ] | |||||||||||||||||||||||||||||||||||||
|
The problem seems to be this one:
and the relevant code:
It seems that we would have to define a default constructor for the union type, which we need because we want each element of m_counter to sit in its own cache line. Would the following work? (I only tested that it does not break the build with clang 8; will test with GCC as well.)
| |||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-02-21 ] | |||||||||||||||||||||||||||||||||||||
|
wlad, thanks for your patch. I pushed a variation of that Using struct instead of union is much cleaner. And I am not at all sure if a union is allowed to have a constructor. I only removed the use of the default constructor, because all current usage of this template is for srv_stats and rw_lock_stats, which are allocated statically and should be zero-initialized. I believe that only fairly recent compilers can optimize away zero-initialization of memory that is allocated from the BSS. Because the two global variables in question are large, having the constructor could cause a lot of unnecessary initialization code to be emitted on some platforms. I added a comment that says that the memory is not explicitly initialized and explains that the instantiated objects are guaranteed to be zero-initialized. |