Bug 284499 - 13.4-RELEASE needs backport of __cxa_call_terminate into libc++ for upcoming GCC14 default ports compiler
Summary: 13.4-RELEASE needs backport of __cxa_call_terminate into libc++ for upcoming ...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.4-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Security Team
URL:
Keywords:
Depends on:
Blocks: 281091 284487
  Show dependency treegraph
 
Reported: 2025-02-01 09:22 UTC by Matthias Andree
Modified: 2025-02-04 11:01 UTC (History)
5 users (show)

See Also:
mandree: maintainer-feedback? (secteam)
mandree: mfc-stable14+
mandree: mfc-stable13+
mandree: needs_errata? (secteam)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Andree freebsd_committer freebsd_triage 2025-02-01 09:22:36 UTC
This is an analysis of an exp-run port compilation failure of C++ based ports on FreeBSD 13.4 with GCC 14.


I understand the issue with GCC 14 breaking some code with linker errors around __cxa_call_terminate now. It only affects 13.4-RELEASE.

TL;DR:

before we can make GCC14 the ports default, we need to issue an erratum after MFH onto releng/13.4 (and only there, supported 14.x and main are good) these changes:

1. the cxxabi.h change to define _LIBCXXRT_NOEXCEPT (see at the end of this comment)

2. adding the __cxa_call_terminate(void *) ABI call (but using _LIBCXXRT_NOEXCEPT so it properly selects nothrow or throw() depending on C++ version)

Or else we break GCC14 compilation and/or compiled code on 13.4. 


Details:

John Baldwin added for GCC/libstdc++14 compatibility a version-mapped ABI function extern "C" __cxa_call_terminate(void*) noexcept (the latter keyword might be #if...ed to throw())  and it's part of current/main, stable/14, releng/14.2, stable/13 (so it should be part of the upcoming releng/13.5) but was not MFH'd to releng/13.4. 

The exp-run was also made with 13.4 (thanks for that) and revealed that.

So making GCC 14 default ports compiler should either:
- be made after we would have issued an erratum notice for 13.4's libc++ and imported this implementation for exception.cc, the binary libc++, Version.map and cxxabi.h, or
- be limited to FreeBSD 14+, or
- wait until 13.4 is out of support, or
- at least be held off until 13.5 will have been released,


What to look for:

libc++ __cxa_call_terminate implementation, in contrib/libcxxrt/exception.cc and lib/libcxxrt/Version.map and Version.map.arm - the symbol is versioned.

main: imported by John Baldwin from upstream:
https://cgit.freebsd.org/src/commit/?id=297a9e552b9a5adf07d195eae9649b0758f395af

stable 14 MFH: (is part of oldest supported 14.x, namely 14.2)
https://cgit.freebsd.org/src/commit/?id=6b5a9d287d03fde3801afa9809b0a9640ec6bf89&h=stable%2F14

stable 13 MFH: (is not part of oldest supported 13.4)
https://cgit.freebsd.org/src/commit/?h=stable/13&id=6b5a9d287d03fde3801afa9809b0a9640ec6bf89

Ed Maste later MFH'd the cxxabi.h from upstream's #define and change-to-use for _LIBCXXRT_NOEXCEPT, see https://cgit.freebsd.org/src/commit/contrib/libcxxrt/cxxabi.h?h=stable/14&id=17a7ea7e3e39cdfb1b367b27c7b38fb0ea6c0806