Skip to content

Commit 07d08f4

Browse files
authored
[libc++] Don't add reference to system_category when exceptions disabled (#67504)
This fixes a size regression in Fuchsia when building a static libc++ multilib with exceptions disabled. Referring to `system_category` in `__throw_system_error` brings in a relatively large amount of additional exception classes into the link without substantially improving the error message.
1 parent 5109cb2 commit 07d08f4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

libcxx/src/system_error.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,15 @@ system_error::~system_error() noexcept
266266
{
267267
}
268268

269-
void __throw_system_error(int ev, const char* what_arg) {
270-
std::__throw_system_error(error_code(ev, system_category()), what_arg);
269+
void
270+
__throw_system_error(int ev, const char* what_arg)
271+
{
272+
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
273+
std::__throw_system_error(error_code(ev, system_category()), what_arg);
274+
#else
275+
// The above could also handle the no-exception case, but for size, avoid referencing system_category() unnecessarily.
276+
_LIBCPP_VERBOSE_ABORT("system_error was thrown in -fno-exceptions mode with error %i and message \"%s\"", ev, what_arg);
277+
#endif
271278
}
272279

273280
_LIBCPP_END_NAMESPACE_STD

0 commit comments

Comments
 (0)