First of all, thanks to everyone who's given me feedback on the patches I've posted recently! I really appreciate you taking the time to review my code.
For context, I work on Amazon Lumberyard, and my current goal is to get the entire engine and toolset to build on Windows with Clang and LLD as an alternative to MSVC. So far I've made a ton of progress; I've fixed a few bugs in LLVM, and fixed an uncountable number of bugs and warnings in our codebase that slipped past other compilers.
The most recent issue I've run into is quite perplexing. When building our largest legacy DLL, I see the following behavior:
- The .obj files produced by Clang are about half the size of the corresponding MSVC objects (719 files, 17.2GB from MSVC, 8.9GB from Clang)
- Linking the MSVC set of object files with both linkers with or without /DEBUG is successful
- Linking the Clang set of object files with LLD without /DEBUG is successful
- Linking the Clang set of object files with MSVC's link.exe with or without /DEBUG and with LLD with /DEBUG results in a "binary too large" error.
Here's a table of linker, Debug or No Debug, and resulting binary size for the Clang object files:
link.exe D: 4297254686 (reported)
link.exe ND: 4295125179 (reported)
lld-link D: 5558142976 (reported)
lld-link ND: 77908000 (on disk)
MAX SIZE: 4294967295
And here's the results for the MSVC object files:
link.exe D: 135228416 (on disk)
link.exe ND: 109041152 (on disk)
lld-link D: 109095424 (on disk)
lld-link ND: 84219904 (on disk)
Clang and LLD are built from trunk, and I'm running both linkers with the following options:
/MACHINE:x64 /MANIFEST /LARGEADDRESSAWARE /DEFAULTLIB:msvcrtd /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBCMTD.lib /DLL /TIME /ignore:4099 [/DEBUG]
I'm going to start poking around object files to see what I can learn, but does anyone have any tips on debugging something like this? I honestly don't really know where to start.
If this turns out to be extra troublesome, I can work on getting legal approval to share my compiled objects to help you repro it. That can be a tricky process, so I'd like to just debug vicariously if possible.