From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A3CAB1F463 for ; Sun, 24 Nov 2019 14:06:14 +0000 (UTC) Received: from localhost ([::1]:35708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iYsWj-0001kP-7Y for normalperson@yhbt.net; Sun, 24 Nov 2019 09:06:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50382) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iYsWe-0001kJ-Uu for bug-gnulib@gnu.org; Sun, 24 Nov 2019 09:06:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iYsWd-0002ha-Hk for bug-gnulib@gnu.org; Sun, 24 Nov 2019 09:06:08 -0500 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::4]:12101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iYsWc-0002gV-T2 for bug-gnulib@gnu.org; Sun, 24 Nov 2019 09:06:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1574604364; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=ZYZWjvhL+gukf/TLZ+N0V6vZhFSnZ/Ix6VlvDMDkhRM=; b=KyZM6suMOiGt3ED5jSDCCj6WBOUczoEwb5EDOPl/WuegEtoPYlEt8MI0nbifxZfLhC 0yn/pG/s2hXTpXgcUVp5LEjK1L6tHzoYfqXB+7rdeOKezl4qO17ZBlEx1N0vB0z75bDj 7DySajlH8zZ3tV/LPujzeyNQVCnYgnbRUNG8a0wVKq+1NuomOMqMxTcEEa1HpFyluVOM YPLvKopfpuid76KyNLHmgZXN+gPyTSxyrJS0sUGcCvx9kawRvXV3P5c2SmFeEdXD5/HP wk3KcVjoPM30BKv27yLbQnVokt1ipYsxM0/IeDo7NPCXiB4eo7SEF21CB60tbXaDZCc2 ubtg== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 44.29.0 DYNA|AUTH) with ESMTPSA id g09d55vAOE63clN (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Sun, 24 Nov 2019 15:06:03 +0100 (CET) From: Bruno Haible To: Christian Biesinger Subject: Re: time_r module does not work on MingW Date: Sun, 24 Nov 2019 15:06:02 +0100 Message-ID: <15749310.khYODPqCiS@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <2192288.myS54ITcZ4@omega> References: <1576792.iqhKLmYyPN@omega> <2192288.myS54ITcZ4@omega> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::4 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org, Christian Biesinger Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" This patch introduced a regression: > 2019-11-16 Bruno Haible > > time_r: Fix for mingw. > Reported by Christian Biesinger in > . > * lib/time.in.h: On mingw, include . > * m4/time_r.m4 (gl_TIME_R): On mingw, include before > . Test for localtime_r in a way that works when it is defined > as an inline function. Namely a link error in mktime: ../gllib/libgnu.a(mktime.o): In function `rpl_mktime': /home/bruno/testdir3/build-mingw64/gllib/../../gllib/mktime.c:533: undefined reference to `localtime_r' 2019-11-24 Bruno Haible time_r: Fix for mingw (regression from 2019-11-16). * m4/time_r.m4 (gl_TIME_R): Revert to using AC_CHECK_FUNCS_ONCE. Use the AC_LINK_IFELSE test only if the function does not appear to exist. diff --git a/m4/time_r.m4 b/m4/time_r.m4 index 72cc975..cc4b3e0 100644 --- a/m4/time_r.m4 +++ b/m4/time_r.m4 @@ -30,28 +30,8 @@ AC_DEFUN([gl_TIME_R], HAVE_DECL_LOCALTIME_R=0 fi - dnl We can't use AC_CHECK_FUNC here, because localtime_r() is defined as an - dnl inline function on mingw. - AC_CACHE_CHECK([for localtime_r], [gl_cv_func_localtime_r], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[/* mingw's provides the functions asctime_r, ctime_r, - gmtime_r, localtime_r only if or has - been included before. */ - #if defined __MINGW32__ - # include - #endif - #include - ]], - [[time_t a; - struct tm r; - localtime_r (&a, &r); - ]]) - ], - [gl_cv_func_localtime_r=yes], - [gl_cv_func_localtime_r=no]) - ]) - if test $gl_cv_func_localtime_r = yes; then + AC_CHECK_FUNCS_ONCE([localtime_r]) + if test $ac_cv_func_localtime_r = yes; then HAVE_LOCALTIME_R=1 AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature], [gl_cv_time_r_posix], @@ -84,6 +64,32 @@ AC_DEFUN([gl_TIME_R], fi else HAVE_LOCALTIME_R=0 + dnl On mingw, localtime_r() is defined as an inline function; use through a + dnl direct function call works but the use as a function pointer leads to a + dnl link error. + AC_CACHE_CHECK([whether localtime_r exists as an inline function], + [gl_cv_func_localtime_r_inline], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[/* mingw's provides the functions asctime_r, ctime_r, + gmtime_r, localtime_r only if or has + been included before. */ + #if defined __MINGW32__ + # include + #endif + #include + ]], + [[time_t a; + struct tm r; + localtime_r (&a, &r); + ]]) + ], + [gl_cv_func_localtime_r_inline=yes], + [gl_cv_func_localtime_r_inline=no]) + ]) + if test $gl_cv_func_localtime_r_inline = yes; then + REPLACE_LOCALTIME_R=1 + fi fi ])