Skip to content

Commit 0e31043

Browse files
committed
gcc: let libstdc++ use newlib's __cxa_thread_atexit on the Vita target
libstdc++ only defers thread_local destructor registration to libc when HAVE___CXA_THREAD_ATEXIT is defined at its configure time, and the --with-newlib branch never checks for the symbol: it hardcodes its feature list. Without the define, libsupc++ compiles its own fallback, which keeps the destructor list in a pthread key, only runs it when the prebuilt library sees gthreads as active (a weak pthread_cancel reference, satisfied only by a whole-archive libpthread), and never on a raw kernel thread. Newlib on Vita now provides __cxa_thread_atexit, running the destructors from the thread-exit path on every exit path, so define it for arm-vita-eabi in that branch. Patched in both configure.ac and the generated configure, since the build does not regenerate it. Assisted-by: Claude Fable 5
1 parent 489488b commit 0e31043

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

cmake/recipes/GccCommonArgs.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ set(gcc_patch_series
1313
"${PROJECT_SOURCE_DIR}/patches/gcc/0001-vita-target.patch|1"
1414
"${PROJECT_SOURCE_DIR}/patches/gcc/0002-vita-driver.patch|1"
1515
"${PROJECT_SOURCE_DIR}/patches/gcc/0003-libgomp-vita.patch|1"
16-
"${PROJECT_SOURCE_DIR}/patches/gcc/0004-host-compat.patch|1")
16+
"${PROJECT_SOURCE_DIR}/patches/gcc/0004-host-compat.patch|1"
17+
"${PROJECT_SOURCE_DIR}/patches/gcc/0005-libstdcxx-cxa-thread-atexit.patch|1")
1718
list(JOIN gcc_patch_series "^" gcc_patch_series_arg)
1819
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
1920
# GCC on OSX (Clang in diguise) needs more bracket nesting depth to compile gcc
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--- a/libstdc++-v3/configure.ac
2+
+++ b/libstdc++-v3/configure.ac
3+
@@ -339,6 +339,11 @@
4+
# on a hosted environment.
5+
if test "x${with_newlib}" = "xyes"; then
6+
os_include_dir="os/newlib"
7+
+ case "${host}" in
8+
+ arm-vita-eabi*)
9+
+ AC_DEFINE(HAVE___CXA_THREAD_ATEXIT)
10+
+ ;;
11+
+ esac
12+
AC_DEFINE(HAVE_HYPOT)
13+
14+
# GLIBCXX_CHECK_STDLIB_SUPPORT
15+
--- a/libstdc++-v3/configure
16+
+++ b/libstdc++-v3/configure
17+
@@ -27343,6 +27343,12 @@
18+
# on a hosted environment.
19+
if test "x${with_newlib}" = "xyes"; then
20+
os_include_dir="os/newlib"
21+
+ case "${host}" in
22+
+ arm-vita-eabi*)
23+
+ $as_echo "#define HAVE___CXA_THREAD_ATEXIT 1" >>confdefs.h
24+
+
25+
+ ;;
26+
+ esac
27+
$as_echo "#define HAVE_HYPOT 1" >>confdefs.h
28+
29+

0 commit comments

Comments
 (0)