[PATCH] D113809: [MachO] Fix struct size assertion

Kevin Cadieux via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 22 14:17:03 PST 2021


kevcadieux added a comment.

We are also seeing this in our internal Windows builds. As can be seen below, the size difference in debug is due to the `std::vector<lld::macho::Reloc>` member, which is actually due to the `_Vector_val` internal vector member that uses a different base class in debug mode (`std::_Container_base12` instead of `std::_Container_base0`). Could we simply turn off this static assert for debug builds (e.g. with #ifdef NDEBUG)?

Class layout of ConcatInputSection x64 debug:

  class lld::macho::ConcatInputSection	size(128):
  	+---
   0	| +--- (base class lld::macho::InputSection)
   0	| | {vfptr}
   8	| | parent
  16	| | align
  20.	| | callSiteCount (bitstart=0,nbits=31)
  20.	| | isFinal (bitstart=31,nbits=1)
  24	| | ?$ArrayRef at E data
  40	| | ?$vector at UReloc@macho at lld@@V?$allocator at UReloc@macho at lld@@@std@@ relocs
  72	| | ?$TinyPtrVector at PEAVDefined@macho at lld@@ symbols
  80	| | shared
  	| +---
  88	| replacement
  96	| icfEqClass
  112	| wasCoalesced
  113	| live
    	| <alignment member> (size=6)
  120	| outSecOff
  	+---
  
  class std::vector<struct lld::macho::Reloc,class std::allocator<struct lld::macho::Reloc> >	size(32):
  	+---
   0	| ?$_Compressed_pair at V?$allocator at UReloc@macho at lld@@@std@@V?$_Vector_val at U?$_Simple_types at UReloc@macho at lld@@@std@@@2@$00 _Mypair
  	+---
  
  class std::_Compressed_pair<class std::allocator<struct lld::macho::Reloc>,class std::_Vector_val<struct std::_Simple_types<struct lld::macho::Reloc> >,1>	size(32):
  	+---
   0	| +--- (base class std::allocator<struct lld::macho::Reloc>)
  	| +---
   0	| ?$_Vector_val at U?$_Simple_types at UReloc@macho at lld@@@std@@ _Myval2
  	+---
  class std::_Vector_val<struct std::_Simple_types<struct lld::macho::Reloc> >	size(32):
  	+---
   0	| +--- (base class std::_Container_base12)
   0	| | _Myproxy
  	| +---
   8	| _Myfirst
  16	| _Mylast
  24	| _Myend
  	+---

The same layout for x64 release:

  class lld::macho::ConcatInputSection	size(120):
  	+---
   0	| +--- (base class lld::macho::InputSection)
   0	| | {vfptr}
   8	| | parent
  16	| | align
  20.	| | callSiteCount (bitstart=0,nbits=31)
  20.	| | isFinal (bitstart=31,nbits=1)
  24	| | ?$ArrayRef at E data
  40	| | ?$vector at UReloc@macho at lld@@V?$allocator at UReloc@macho at lld@@@std@@ relocs
  64	| | ?$TinyPtrVector at PEAVDefined@macho at lld@@ symbols
  72	| | shared
  	| +---
  80	| replacement
  88	| icfEqClass
  104	| wasCoalesced
  105	| live
    	| <alignment member> (size=6)
  112	| outSecOff
  	+---
  	
  class std::vector<struct lld::macho::Reloc,class std::allocator<struct lld::macho::Reloc> >	size(24):
  	+---
   0	| ?$_Compressed_pair at V?$allocator at UReloc@macho at lld@@@std@@V?$_Vector_val at U?$_Simple_types at UReloc@macho at lld@@@std@@@2@$00 _Mypair
  	+---
  	
  class std::_Compressed_pair<class std::allocator<struct lld::macho::Reloc>,class std::_Vector_val<struct std::_Simple_types<struct lld::macho::Reloc> >,1>	size(24):
  	+---
   0	| +--- (base class std::allocator<struct lld::macho::Reloc>)
  	| +---
   0	| ?$_Vector_val at U?$_Simple_types at UReloc@macho at lld@@@std@@ _Myval2
  	+---
  	
  class std::_Vector_val<struct std::_Simple_types<struct lld::macho::Reloc> >	size(24):
  	+---
   0	| +--- (base class std::_Container_base0)
  	| +---
   0	| _Myfirst
   8	| _Mylast
  16	| _Myend
  	+---


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113809/new/

https://reviews.llvm.org/D113809



More information about the llvm-commits mailing list