[lld] 2f5d6a0 - [MachO] Fix struct size assertion

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 22 15:02:47 PST 2021


Author: Shoaib Meenai
Date: 2021-11-22T15:02:30-08:00
New Revision: 2f5d6a0ea51b8c9ac3d241dbdd05f96e35193a26

URL: https://github.com/llvm/llvm-project/commit/2f5d6a0ea51b8c9ac3d241dbdd05f96e35193a26
DIFF: https://github.com/llvm/llvm-project/commit/2f5d6a0ea51b8c9ac3d241dbdd05f96e35193a26.diff

LOG: [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.)

Added: 
    

Modified: 
    lld/MachO/InputSection.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/InputSection.cpp b/lld/MachO/InputSection.cpp
index 96167b72a724f..d42085737dbb7 100644
--- a/lld/MachO/InputSection.cpp
+++ b/lld/MachO/InputSection.cpp
@@ -26,8 +26,11 @@ using namespace llvm::support;
 using namespace lld;
 using namespace lld::macho;
 
-// Verify ConcatInputSection's size on 64-bit builds.
-static_assert(sizeof(void *) != 8 || sizeof(ConcatInputSection) == 120,
+// Verify ConcatInputSection's size on 64-bit builds. The size of std::vector
+// can 
diff er based on STL debug levels (e.g. iterator debugging on MSVC's STL),
+// so account for that.
+static_assert(sizeof(void *) != 8 ||
+                  sizeof(ConcatInputSection) == sizeof(std::vector<Reloc>) + 96,
               "Try to minimize ConcatInputSection's size, we create many "
               "instances of it");
 


        


More information about the llvm-commits mailing list