<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/67129>67129</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Unable to cought exception when using lld with lto=thin on MacOS ARM64
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
WojciechMazur
</td>
</tr>
</table>
<pre>
Hey, I have a problem where my exception is never cought when using lld, but it's only present when combined with lto=thin
Code snippet:
```cpp
// test.cpp
#include <exception>
#include <stdio.h>
int main(int argc, char **argv) {
try {
throw std::exception();
} catch (const std::exception &e) {
printf("Cought %s\n", e.what());
}
return 0;
}
```
compiled with:
```bash
clang++ -flto=thin -fuse-ld=lld test.cpp
```
results in:
```bash
> ./a.out
libc++abi: terminating due to uncaught exception of type std::exception: std::exception
[1] 3622 abort ./a.out
```
When compiled without either lto=thin or use-ld=lld it works correctly:
```bash
> clang++ test.cpp -flto=thin && ./a.out
Cought std::exception
> clang++ test.cpp -fuse-ld=lld && ./a.out
Cought std::exception
```
LLVM version:
```bash
clang version 16.0.6
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-16/bin
```
Also affected in Homebrew distribution under the same version
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVd-P4kYM_muGF2ujxIEAD3lgl0N30q0qtdfe8_wwZK6TmWjGWZb-9VVCFtgt13a1CsGesf19n41lSvbgiWqxeBSL7Uz23IRYfw8_tCXdPMu_-jhTwZzqz3QS-ARfoJEvBBK6GJSjFo4NRYL2BPSqqWMbPNgEnl4ogg79oeHhiIc-WX8A58wQRfUMlgUuEwTvTtBFSuSnkzq0ynoycLTcgOMgyi031ot8K_LN7fMpGILkbdcRi3IDk6_Kz_-66yYL7gTugClxdjVOrtJ67XpDIMqnCwZRfrrnT2xsyJqrd3xaz9BK6wWuhlcZD3oAqRsZQe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