Yes, file size is a pretty good hint of this problem. The IMAGE_OPTIONAL_HEADER64.SizeOfImage field is a DWORD, suggesting a maximum size of 4 GB. But there is another limit that starts first, the OS loader maps the entire .exe or .dll file to memory using a memory mapped file. View on MMF cannot exceed 2 GB. This is a difficult technical limitation, it even applies to x64. Read more about this issue in this post .
Debugging information is without a doubt the reason why the image file explodes so badly. For comparison, the clang collection, which is part of VS2017, requires 27 MB for the interface and 32 MB for the back of x64. Why -gsplit-dwarf cannot solve your problem can be seen from this project page :
The division is implemented in GCC 4.7 and requires support from the latest versions of objcopy and the gold linker .
MinGW cannot provide you with a gold linker. They did not try to port it, since it can only generate ELF images. Cold hard facts, while you depend on MinGW, then you are driving without a good paddle.
Something decisive is required. I will hesitantly mention Cygwin. Consider another compiler, for example, using Clang to create Clang :) Or MSVC ++. Community Edition - Free Download. Also don't forget to take a look at Clang port , they did a lot of work to make it compatible with ABI.
source share