<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/134037>134037</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libcxx] linking error with -fno-exceptions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
futog
</td>
</tr>
</table>
<pre>
```
#include <new>
#include <cassert>
#include <cstdlib>
int cnt = 0;
alignas(32) char DummyData[32 * 3];
void* operator new(std::size_t size) {
return DummyData;
}
void operator delete(void*) noexcept {
cnt++;
}
void test_it ( void );
int main() {
test_it();
}
void test_it(void) {
std::nothrow_t cval_nothrow;
void* p = ::operator new(sizeof(int), cval_nothrow);
assert(p == DummyData);
::operator delete(p, cval_nothrow);
assert(cnt == 1);
}
```
built with `fno-exceptions` and linked with a libcxx built with `fno-exceptions`, gives the following error:
```
ld.lld: error: undefined symbol: __start___lcxx_override
>>> referenced by stdlib_new_delete.cpp.o:(operator new(unsigned int, std::nothrow_t const&)) in archive ../libc++abi.a
>>> referenced by stdlib_new_delete.cpp.o:(operator new(unsigned int, std::nothrow_t const&)) in archive ../libc++abi.a
>>> the encapsulation symbol needs to be retained under --gc-sections properly; consider -z nostart-stop-gc (see https://lld.llvm.org/ELF/start-stop-gc)
ld.lld: error: undefined symbol: __stop___lcxx_override
>>> referenced by stdlib_new_delete.cpp.o:(operator new(unsigned int, std::nothrow_t const&)) in archive ../libc++abi.a
>>> referenced by stdlib_new_delete.cpp.o:(operator new(unsigned int, std::nothrow_t const&)) in archive ../libc++abi.a
```
I think the reason is that the `__lcxx_override` section is not referenced anywhere, given the current `fno-exception` implementation of `operator new(unsigned int, std::nothrow_t const&)`
Based https://github.com/llvm/llvm-project/commit/314526557ec66ee627ae8a1c03f6ccc610668fdb, this should not work runtime anyway, but I guess the intention here is not a linking error that is not that easy to decode.
</pre>
<img width="1" height="1" alt="" src="http://email.email.ll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