On Fri, 20 Mar 2026, 13:31 Tomasz Kaminski, <[email protected]> wrote:
> > > On Tue, Mar 17, 2026 at 5:37 PM Jonathan Wakely <[email protected]> > wrote: > >> libstdc++-v3/ChangeLog: >> >> PR libstdc++/124554 >> * acinclude.m4 (GLIBCXX_CHECK_CSETJMP): Define. >> * config.h.in: Regenerate. >> * configure: Regenerate. >> * configure.ac: Use GLIBCXX_CHECK_CSETJMP. >> * include/c_global/csetjmp: Check new macro. >> --- >> >> For the record, I think something like this would fix PR >> libstdc++/124554 but I'm just going to revert the patch that caused it. >> > You need to also guard exports for longjmp and set_jmp > in libstdc++-v3/src/c++23/std-clib.cc.in. > > Yes, I had noticed that and added it locally. >> libstdc++-v3/acinclude.m4 | 22 +++++++++++++ >> libstdc++-v3/config.h.in | 3 ++ >> libstdc++-v3/configure | 45 +++++++++++++++++++++++++++ >> libstdc++-v3/configure.ac | 3 ++ >> libstdc++-v3/include/c_global/csetjmp | 2 ++ >> 5 files changed, 75 insertions(+) >> >> diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 >> index 8dc9e17b214c..23ffaf789724 100644 >> --- a/libstdc++-v3/acinclude.m4 >> +++ b/libstdc++-v3/acinclude.m4 >> @@ -5902,6 +5902,28 @@ AC_LANG_SAVE >> AC_LANG_RESTORE >> ]) >> >> +dnl >> +dnl Check whether we can define the contents of <csetjmp> >> +dnl >> +dnl Defines: >> +dnl _GLIBCXX_HAVE_JMP_BUF if setjmp and jmp_buf are available. >> +dnl >> +AC_DEFUN([GLIBCXX_CHECK_CSETJMP], [ >> + AC_LANG_SAVE >> + AC_LANG_CPLUSPLUS >> + >> + AC_MSG_CHECKING([for jmp_buf and setjmp in <setjmp.h>]) >> + AC_TRY_COMPILE([#include <setjmp.h>], >> + [using ::jmp_buf; using ::setjmp;], >> + [ac_jmp_buf=yes],[ac_jmp_buf=no]) >> + AC_MSG_RESULT($ac_jmp_buf) >> + if test "$ac_jmp_buf" = yes; then >> + AC_DEFINE(HAVE_JMP_BUF,1,[Define if jmp_buf is defined in >> <setjmp.h>]) >> + fi >> + >> + AC_LANG_RESTORE >> +]) >> + >> >> # Macros from the top-level gcc directory. >> m4_include([../config/gc++filt.m4]) >> diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in >> index 4cfb9ba26be4..83e03ea91ed5 100644 >> --- a/libstdc++-v3/config.h.in >> +++ b/libstdc++-v3/config.h.in >> @@ -203,6 +203,9 @@ >> /* Defined if iswblank exists. */ >> #undef HAVE_ISWBLANK >> >> +/* Define if jmp_buf is defined in <setjmp.h> */ >> +#undef HAVE_JMP_BUF >> + >> /* Define if LC_MESSAGES is available in <locale.h>. */ >> #undef HAVE_LC_MESSAGES >> >> diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure >> index 6713e4504b1c..d05d6befc932 100755 >> --- a/libstdc++-v3/configure >> +++ b/libstdc++-v3/configure >> @@ -55330,6 +55330,51 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu >> >> >> >> +# Whether we can define the contents of <csetjmp> >> + >> + >> + ac_ext=cpp >> +ac_cpp='$CXXCPP $CPPFLAGS' >> +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' >> +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS >> conftest.$ac_ext $LIBS >&5' >> +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu >> + >> + >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jmp_buf and >> setjmp in <setjmp.h>" >&5 >> +$as_echo_n "checking for jmp_buf and setjmp in <setjmp.h>... " >&6; } >> + cat confdefs.h - <<_ACEOF >conftest.$ac_ext >> +/* end confdefs.h. */ >> +#include <setjmp.h> >> +int >> +main () >> +{ >> +using ::jmp_buf; using ::setjmp; >> + ; >> + return 0; >> +} >> +_ACEOF >> +if ac_fn_cxx_try_compile "$LINENO"; then : >> + ac_jmp_buf=yes >> +else >> + ac_jmp_buf=no >> +fi >> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext >> + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_jmp_buf" >&5 >> +$as_echo "$ac_jmp_buf" >&6; } >> + if test "$ac_jmp_buf" = yes; then >> + >> +$as_echo "#define HAVE_JMP_BUF 1" >>confdefs.h >> + >> + fi >> + >> + ac_ext=c >> +ac_cpp='$CPP $CPPFLAGS' >> +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' >> +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS >> conftest.$ac_ext $LIBS >&5' >> +ac_compiler_gnu=$ac_cv_c_compiler_gnu >> + >> + >> + >> # Define documentation rules conditionally. >> >> # See if makeinfo has been installed and is modern enough >> diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac >> index f81dccdeef70..620f6a54f4c2 100644 >> --- a/libstdc++-v3/configure.ac >> +++ b/libstdc++-v3/configure.ac >> @@ -666,6 +666,9 @@ GLIBCXX_CHECK_DEBUGGING >> # For std::print >> GLIBCXX_CHECK_STDIO_LOCKING >> >> +# Whether we can define the contents of <csetjmp> >> +GLIBCXX_CHECK_CSETJMP >> + >> # Define documentation rules conditionally. >> >> # See if makeinfo has been installed and is modern enough >> diff --git a/libstdc++-v3/include/c_global/csetjmp >> b/libstdc++-v3/include/c_global/csetjmp >> index 22311a7ee613..038a5228d91b 100644 >> --- a/libstdc++-v3/include/c_global/csetjmp >> +++ b/libstdc++-v3/include/c_global/csetjmp >> @@ -44,6 +44,7 @@ >> #endif >> >> #include <bits/c++config.h> >> +#if _GLIBCXX_HAVE_JMP_BUF >> #include <setjmp.h> >> >> // Get rid of those macros defined in <setjmp.h> in lieu of real >> functions. >> @@ -60,4 +61,5 @@ namespace std >> using ::longjmp; >> } // namespace std >> >> +#endif // _GLIBCXX_HAVE_JMP_BUF >> #endif >> -- >> 2.53.0 >> >>
