This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Add static_assert(sizeof(SymbolUnion) <= 96)
ClosedPublic

Authored by MaskRay on Jul 5 2019, 2:50 AM.

Details

Summary

On Windows, the bitfield layout rule places ussigned Referenced : 1 at
byte offset 40, instead of byte offset 37 on *NIX. The consequence is that
sizeof(SymbolUnion) == 104 on Windows while 96 on *NIX.

To eliminate this difference, change these unsigned bitfields to bool.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Jul 5 2019, 2:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2019, 2:50 AM
ruiu accepted this revision.Jul 8 2019, 12:02 AM

LGTM

This revision is now accepted and ready to land.Jul 8 2019, 12:02 AM
This revision was automatically updated to reflect the committed changes.
aykevl added a subscriber: aykevl.Nov 2 2019, 5:20 AM

FYI: this change caused a build error when including the AVR backend:

[2780/3153] Building CXX object tools/lld/ELF/CMakeFiles/lldELF.dir/Arch/AVR.cpp.obj
FAILED: tools/lld/ELF/CMakeFiles/lldELF.dir/Arch/AVR.cpp.obj 
C:\ProgramData\chocolatey\bin\c++.exe  -DGTEST_HAS_RTTI=0 -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/lld/ELF -ID:/a/1/s/llvm-project/lld/ELF -ID:/a/1/s/llvm-project/lld/include -Itools/lld/include -Iinclude -ID:/a/1/s/llvm-project/llvm/include -Wa,-mbig-obj -Werror=date-time -std=gnu++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment  -O2 -DNDEBUG    -fno-exceptions -fno-rtti -MD -MT tools/lld/ELF/CMakeFiles/lldELF.dir/Arch/AVR.cpp.obj -MF tools\lld\ELF\CMakeFiles\lldELF.dir\Arch\AVR.cpp.obj.d -o tools/lld/ELF/CMakeFiles/lldELF.dir/Arch/AVR.cpp.obj -c D:/a/1/s/llvm-project/lld/ELF/Arch/AVR.cpp
In file included from D:/a/1/s/llvm-project/lld/ELF/Arch/AVR.cpp:29:
D:/a/1/s/llvm-project/lld/ELF/Symbols.h:470:35: error: static assertion failed: SymbolUnion too large
 static_assert(sizeof(SymbolUnion) <= 80, "SymbolUnion too large");
               ~~~~~~~~~~~~~~~~~~~~^~~~~
[2781/3153] Building CXX object tools/lld/COFF/CMakeFiles/lldCOFF.dir/Symbols.cpp.obj
[2782/3153] Building CXX object tools/lld/COFF/CMakeFiles/lldCOFF.dir/Writer.cpp.obj
ninja: build stopped: subcommand failed.
mingw32-make: *** [Makefile:133: llvm-build] Error 1

I will see what can be done about it.

aykevl added a comment.Nov 2 2019, 5:28 AM

Sorry, that was probably https://reviews.llvm.org/D64077 instead.