Skip to content

Commit 2f5d6a0

Browse files
committed
[MachO] Fix struct size assertion
std::vector can have different sizes depending on the STL's debug level, so account for its size separately. (You could argue that we should be accounting for all the other members separately as well, but that would be very unergonomic, and std::vector is the only one that's caused problems so far.)
1 parent ae5348a commit 2f5d6a0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lld/MachO/InputSection.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ using namespace llvm::support;
2626
using namespace lld;
2727
using namespace lld::macho;
2828

29-
// Verify ConcatInputSection's size on 64-bit builds.
30-
static_assert(sizeof(void *) != 8 || sizeof(ConcatInputSection) == 120,
29+
// Verify ConcatInputSection's size on 64-bit builds. The size of std::vector
30+
// can differ based on STL debug levels (e.g. iterator debugging on MSVC's STL),
31+
// so account for that.
32+
static_assert(sizeof(void *) != 8 ||
33+
sizeof(ConcatInputSection) == sizeof(std::vector<Reloc>) + 96,
3134
"Try to minimize ConcatInputSection's size, we create many "
3235
"instances of it");
3336

0 commit comments

Comments
 (0)