Rainer Orth <r...@cebitec.uni-bielefeld.de> writes: > Hi Andreas, > >> On Apr 11 2025, Rainer Orth wrote: >> >>> This patch uses Autoconf's AC_STRUCT_TIMEZONE to determine its presence >>> and guard the use accordingly. >> >> You cannot use AC_STRUCT_TIMEZONE because it requires a link test (which >> is forbidden in a target module, see PR119550). > > drats. Must have taken this from libstdc++ shortly before it was > replaced. > > I suspect a simple > > AC_CHECK_MEMBER([struct tm.tm_zone],,[#include <time.h>]) > > does the trick. > > Thanks for the hint.
That's what I actually tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu. Ok for trunk and gcc-15 branch? Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University 2025-04-08 Rainer Orth <r...@cebitec.uni-bielefeld.de> libgcobol: * configure.ac: Check for struct tm.tm_zone. * configure, config.h.in: Regenerate. * intrinsic.cc (__gg__formatted_current_date): Guard tm.tm_zone use with HAVE_STRUCT_TM_TM_ZONE.
# HG changeset patch # Parent 2e0b7a6cac052729ce96489827f3f1e03e96d9b1 libgcobol: Check for struct tm tm_zone diff --git a/libgcobol/configure b/libgcobol/configure --- a/libgcobol/configure +++ b/libgcobol/configure @@ -2449,6 +2449,63 @@ eval ac_res=\$$3 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_func + +# ac_fn_cxx_check_member LINENO AGGR MEMBER VAR INCLUDES +# ------------------------------------------------------ +# Tries to find if the field MEMBER exists in type AGGR, after including +# INCLUDES, setting cache variable VAR accordingly. +ac_fn_cxx_check_member () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 +$as_echo_n "checking for $2.$3... " >&6; } +if eval \${$4+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "$4=yes" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (sizeof ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "$4=yes" +else + eval "$4=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$4 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_cxx_check_member cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -11693,7 +11750,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11696 "configure" +#line 11753 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11799,7 +11856,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11802 "configure" +#line 11859 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17426,6 +17483,14 @@ fi +# struct tm tm_zone is a POSIX.1-2024 addition. +ac_fn_cxx_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include <time.h> +" +if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then : + +fi + + if test "${multilib}" = "yes"; then multilib_arg="--enable-multilib" else diff --git a/libgcobol/configure.ac b/libgcobol/configure.ac --- a/libgcobol/configure.ac +++ b/libgcobol/configure.ac @@ -231,6 +231,9 @@ elif test "${ENABLE_LIBQUADMATH_SUPPORT} fi LIBGCOBOL_CHECK_FLOAT128 +# struct tm tm_zone is a POSIX.1-2024 addition. +AC_CHECK_MEMBER([struct tm.tm_zone],,,[#include <time.h>]) + if test "${multilib}" = "yes"; then multilib_arg="--enable-multilib" else diff --git a/libgcobol/intrinsic.cc b/libgcobol/intrinsic.cc --- a/libgcobol/intrinsic.cc +++ b/libgcobol/intrinsic.cc @@ -1490,7 +1490,9 @@ void __gg__clock_gettime(CLOCK_REALTIME, &ts); struct tm tm = {}; +#ifdef HAVE_STRUCT_TM_TM_ZONE tm.tm_zone = "GMT"; +#endif if( is_zulu ) { gmtime_r(&ts.tv_sec, &tm);