<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122435>122435</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MinGW] [libunwind] undefined __gxx_personality_seh0 when build libunwind with LTO+Exceptions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Andarwinux
</td>
</tr>
</table>
<pre>
See #121819 for background context
This may become a problem in the future, but for now it won't actually happen unless libunwind does switch to using `-fexceptions` to compile the whole library
To build a libunwind that reproduces this problem, we need to hack the build system:
```
-DLIBUNWIND_ENABLE_SHARED=OFF
-DCXX_SUPPORTS_FNO_EXCEPTIONS_FLAG=OFF
-DCMAKE_C_FLAGS=“-flto=thin”
-DCMAKE_CXX_FLAGS=“-flto=thin”
```
Then use `-flto=thin` to compile any source and link them with libunwind.a:
```
x86_64-w64-mingw32-clang -flto=thin test.c --static
lld-link: error: undefined symbol: __gxx_personality_seh0
>>> referenced by llvm-project/libunwind/src/libunwind.cpp
>>> libunwind.a(libunwind.cpp.obj)
```
[report.zip](https://github.com/user-attachments/files/18374405/report.zip) (lld reproduce)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVFFvozgQ_jXOy4gIDKTwwENSwl513bbadLV9Q8aeBO8aG9lmSe7XnyC9LdGdToss2Rp7vpnvm2GYc_KkEQuS7khartjgW2OLrRbMjlIP51VjxKU4IAKhcUSjLMrhaCw0jP84WTNoAdxoj2dPwi0Jt6-tdNCxCzTITYfAoLemUdiB1OBbhOPgB4uE3kMz-BlKmxGkh9FoQu88MO4HptQFWtb3qGHQCp0DJZtBj1ILEAYduFF63oI3MDipT0A2YXDEM8feS6Md2YTTHTddLxXOgcfWKJxgLLOX92QNNINUAtgC3rfMg8XeGjFwdOAnRu8kprRHBI0oJviW8R8z9hXFXZzHjsQTNNmE7yvcBuXjw-7r07eHp7LeP213j_v68Mf2y74kcflcVfOL-7e3-vD15eX5y-uhrp6e6_3b_f7l9eH56VBXj9tPy6eft3_u6_vZfCBxSfaUZCHJ74Oj8obEpW-l_sdYLl3e3n7faUlgrutUCodXoRcut0IzfQFnBsunowAl9SxQB6P07YfIa_au0m2cc7apN0kwbpKgk_o0xjTgiukTLCOCR-fXHILAeeYlv8IoJYIpGom3gNYaOx0GLfAoNU6l6RqjJltdn87nukfrjGZK-kvtsJ1JxvvrAotHtKg5CmguoNTPLuit-Y7cE1r94kBo5SxfWta872-Abr8le5rdeK1N853Q_N-yk3RnsTfWr_-SPUlLQrPW-95N8tGK0OokfTs0a246QqvBoQ2Y94y3HWrvCK2OUuG0R1l8lyRhSmi1AKQ5TKko8dHwhOYrUcQij3O2wiK6izdpGEc0WbXFZoM5zTYhDbOIH9O7KBcYCpqgEFkumnAlCxrSNIyiMMzTLEnW_IiRiO44jXkcNawhSYgdk2o9qbo29rSSzg1YRJQmcbpSrEHl5mFEqcYR5ltC6TSbbDGXohlOjiShks67DxgvvZqn2GepP30jaQkk3X3UKi0XzfDfLQDj1OLXP_ljGsx9-_j6TOhu_2u6rAariv-pw5TV-7bonJnLXIsr2Z8F_TsAAP__Bbe__Q">