llvm-project
cdc2749d - [Driver][MSVC] Use LLD if DWARF is requested (#198600)

Commit
155 days ago
[Driver][MSVC] Use LLD if DWARF is requested (#198600) Clang can emit DWARF on Windows if requested with `-gdwarf` (or `-gdwarf-N`). The generated object files will then have the `.debug_*` sections. These section names are all larger than eight bytes. This creates an issue in the final executable. PE/COFF executables don't allow section names longer than eight characters. From the [docs](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#section-table-section-headers): > **Name**: An 8-byte, null-padded UTF-8 encoded string. If the string is exactly 8 characters long, there is no terminating null. For longer names, this field contains a slash (/) that is followed by an ASCII representation of a decimal number that is an offset into the string table. Executable images do not use a string table and do not support section names longer than 8 characters. MSVC's linker follows this and will truncate section names in executables. So a `.debug_info` would become `.debug_i`. LLD on the other hand does allow these long section names (with a warning). This makes DWARF work on MinGW. The MSVC toolchain will use the MSVC linker by default (unless `CLANG_DEFAULT_LINKER` specifies a different one). This will truncate the section names. So if one would want to use DWARF, they'd also need to link with LLD. This PR changes the default linker to LLD if DWARF is requested. Otherwise, the old default will be used.
Author
Parents
Loading