[lld][COFF] Distributed ThinLTO fails with an undefined vector deleting destructor
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
This was found while building clang for windows MSVC using bazel using distributed remote build and distributed ThinLTO feature as provided by hermetic-llvm (the LLVM toolchain used as part of LLVM hermetic bazel config). I am the maintainer of that toolchain.
COFF distributed ThinLTO fails during the final native link with an undefined MSVC vector deleting destructor. The same input links successfully with in-process ThinLTO.
Reproduced with LLVM @ HEAD
```cpp
// repro.cpp
struct A {
virtual ~A();
};
A::~A() = default;
void operator delete(void *, __SIZE_TYPE__) noexcept {}
int main() {
A a;
return 0;
}
```
Compile one COFF ThinLTO object:
```console
$ clang++ --target=x86_64-pc-windows-msvc -O0 -fno-rtti -fno-exceptions \
-flto=thin -c repro.cpp -o repro.obj
```
The in-process link succeeds:
```console
$ lld-link /entry:main /subsystem:console repro.obj /out:in-process.exe
```
Distributed ThinLTO fails:
```console
# Same link, but generate the distributed ThinLTO index
$ lld-link /entry:main /subsystem:console /thinlto-index-only \
repro.obj /out:distributed.exe
# Run the distributed backend
$ clang++ --target=x86_64-pc-windows-msvc -c \
-fthinlto-index=repro.obj.thinlto.bc \
repro.obj -o repro.native.obj
# Final native-only link
# lld-link /entry:main /subsystem:console \
repro.native.obj /out:distributed.exe
```
Observed:
```text
lld-link: error: undefined symbol: public: virtual void * __cdecl A::`vector deleting dtor'(unsigned int)
>>> referenced by repro.native.obj:(const A::`vftable')
```
Expected: the distributed ThinLTO link succeeds like the in-process ThinLTO link.
Contributor guide
Research direction
Start with repro.cpp and reproduce the failure using the listed clang++ and lld-link commands, comparing in-process and distributed ThinLTO. Inspect the COFF ThinLTO distributed backend and final native-only link path to determine why the vector deleting destructor is not emitted or preserved. Done means the distributed final link succeeds without the undefined symbol.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100