Clang debug build created using MinGW on Windows 10 cannot be started

I created Clang with MinGW on Windows with the target triple x86_64-w64-windows-gnu. The executables clang.exe and clang ++ exe work as expected if I create them in release mode (they compile programs without errors), but when I create them in debug mode I cannot start them and get this error - "This application cannot work on your pc. " Other executables from the same assembly, such as clang-check.exe, do not display this error and work correctly.

It seems like this could be a file size issue for both clang.exe and clang ++. exe have a size> 2 GB, while other executable files are smaller, but I got the impression that the file size limit on 64-bit Windows is 4 GB.

Does anyone else encounter a similar problem? If file size is a problem, can LLVM be put debugging symbols in a separate file to reduce the size of the executable?

EDIT: I tried to reduce the size of the executable by dropping debugging characters into a separate file using the -gsplit-dwarf flag when creating LLVM, but it has no effect.

+5
source share
1 answer

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.

+4
source

Source: https://habr.com/ru/post/1271646/


All Articles