From patchwork Wed May 8 11:52:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1097006 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-500303-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="xfqcZYD3"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rcjNetSU"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44zZbJ4zVJz9s4V for ; Wed, 8 May 2019 21:52:25 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:cc:content-type; q=dns; s=default; b=lxtJJKMmFe4KV+eU7TUbRqp4MCPIRAI3PBRjQ0jNVvz kDAkMOj0PzBoVksGnfDWGhe9aB0IZEaYfAkfPsll0UJ0WrV47CTFsWp2ni/fNWeh s9PJ0KgoU5AU51yvgrtmMhRcnLGY+uf6fDZW9gICeXXfiIYTE3JGgRXIi/JQ9S0U = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:cc:content-type; s=default; bh=ECv2XQaAvqpKR1kgM3HmqFwTig8=; b=xfqcZYD3Ojy+z/BZX 471xabasETH1EDcyBEdQD/DhBLM7hlH/Fkh395vyaFaB1YMqup9AonYDSIh5DZqk 9vA0sISSc9NijkQET8vY1IQSFU+4fn+CGIKBZJ6xUHT5ZNH6nYLhBzDQLnfypiwn lKK4iEVkxCAJgLNOYEj7zADdME= Received: (qmail 112121 invoked by alias); 8 May 2019 11:52:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 112112 invoked by uid 89); 8 May 2019 11:52:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=hello!, availability, HX-Spam-Relays-External:209.85.166.194, H*RU:209.85.166.194 X-HELO: mail-it1-f194.google.com Received: from mail-it1-f194.google.com (HELO mail-it1-f194.google.com) (209.85.166.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 May 2019 11:52:15 +0000 Received: by mail-it1-f194.google.com with SMTP id q65so3548830itg.2 for ; Wed, 08 May 2019 04:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=F7Og38zx2DUg8KN2dt3SHuybRl6ADv37iQ3Q0OhYoZQ=; b=rcjNetSU5o6TwlXzn6AjKmI+2ayxBxzrpbodfTY9pk01Vdt50R/u1QLyH6Vj5NdwvP Bc+4lR8Pwx7+r0Oc9ydRNSAR1HmK8cFGNizJPhgaF57hHWN72LaLjXt6f3w3wD70Uc6C l3QLvEnJXTPPkz5eUjz25MChmGQKEelMG+126/4qCQF+/4NQlLeFlXXDrkgFoUh9ERd4 +P7HbKOFr+auW9gzF64UhvFbjraFo2Yt+N3dkIz/wuRkkh6uuEXC1Dcd7eUw8r8Ia6FB B5SmodjuveTMw7ae087hT3wtTQnA90UwpAf9UmiZNZzSNCmOgNLXgnd8Fmej7rSjUNRa ipow== MIME-Version: 1.0 From: Uros Bizjak Date: Wed, 8 May 2019 13:52:03 +0200 Message-ID: Subject: [PATCH, d]: Fix PR90261, FAIL: libphobos.phobos/std/file.d on CentOS 5.11, Linux 2.6.18 To: "gcc-patches@gcc.gnu.org" Cc: Iain Buclaw Hello! CentOS 5.11 (glibc 2.5) does not have utimensat function, so there is no nanosecond precision of file times available. Currently, the test fails with: /tmp/cc36u3o7.o: In function `_D3std4file17__T8setTimesTAyaZ8setTimesFAyaS3std8datetime7systime7SysTimeS3std8datetime7systime7SysTimeZ16trustedUtimensatFNbNiNeiPxaKxG2S4core3sys5posix6signal8timespeciZi': /home/uros/git/gcc/libphobos/testsuite/../src/std/file.d:1272: undefined reference to `utimensat' collect2: error: ld returned 1 exit status compiler exited with status 1 Attached patch detects utimensat function during configure time and falls back to utimes in case utimensat is not available. 2019-05-08 Uroš Bizjak PR d/90261 * m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_CLIB): Check for utimensat function. * configure: Regenerate * Makefile.in: Regenerate * libdruntime/gcc/config.d.in: Add Have_Utimensat. * libdruntime/Makefile.in: Regenerate. * libdruntime/core/sys/posix/sys/stat.d [version (CRuntime_Glibc)]: Declare utimensat and futimens only with Have_Utimensat. * src/Makefile.in: Regenerate. * src/std/file.d: Call testTimes with non-zero argument only when utimensat is defined. * testsuite/Makefile.in: Regenerate. BTW: The same fix as applied to CRuntime_Glibc can also be applied to FreeBSD version, which currently reads: // Since FreeBSD 11: version (none) { int utimensat(int dirfd, const char *pathname, ref const(timespec)[2] times, int flags); int futimens(int fd, ref const(timespec)[2] times); } BTW2: The testcase now fails in another place in src/std/file.d on CentOS 5.11 (and probably other non-modern systems): // Tests sub-second precision of querying file times. // Should pass on most modern systems running on modern filesystems. // Exceptions: // - FreeBSD, where one would need to first set the // vfs.timestamp_precision sysctl to a value greater than zero. // - OS X, where the native filesystem (HFS+) stores filesystem // timestamps with 1-second precision. This test should check the availability of utimensat on linux, otherwise the resolution is only in seconds range. Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32} with CentOS 5.11 and Fedora 30. Uros. diff --git a/libphobos/Makefile.in b/libphobos/Makefile.in index 58368c92b492..de5c7d04fee3 100644 --- a/libphobos/Makefile.in +++ b/libphobos/Makefile.in @@ -215,6 +215,7 @@ DCFG_HAVE_64BIT_ATOMICS = @DCFG_HAVE_64BIT_ATOMICS@ DCFG_HAVE_ATOMIC_BUILTINS = @DCFG_HAVE_ATOMIC_BUILTINS@ DCFG_HAVE_LIBATOMIC = @DCFG_HAVE_LIBATOMIC@ DCFG_HAVE_QSORT_R = @DCFG_HAVE_QSORT_R@ +DCFG_HAVE_UTIMENSAT = @DCFG_HAVE_UTIMENSAT@ DCFG_MINFO_BRACKETING = @DCFG_MINFO_BRACKETING@ DCFG_THREAD_MODEL = @DCFG_THREAD_MODEL@ DEFS = @DEFS@ diff --git a/libphobos/configure b/libphobos/configure index 95a2b4232187..a33debdd97b0 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -651,6 +651,7 @@ LIBATOMIC DCFG_HAVE_LIBATOMIC DCFG_HAVE_64BIT_ATOMICS DCFG_HAVE_ATOMIC_BUILTINS +DCFG_HAVE_UTIMENSAT DCFG_HAVE_QSORT_R OS_LINK_SPEC DCFG_DLPI_TLS_MODID @@ -11635,7 +11636,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11638 "configure" +#line 11639 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11741,7 +11742,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11744 "configure" +#line 11745 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14393,6 +14394,13 @@ if test "x$ac_cv_func_qsort_r" = xyes; then : fi + DCFG_HAVE_UTIMENSAT=false + ac_fn_c_check_func "$LINENO" "utimensat" "ac_cv_func_utimensat" +if test "x$ac_cv_func_utimensat" = xyes; then : + DCFG_HAVE_UTIMENSAT=true +fi + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in index 19ee94fc370d..bdcc1979046f 100644 --- a/libphobos/libdruntime/Makefile.in +++ b/libphobos/libdruntime/Makefile.in @@ -547,6 +547,7 @@ DCFG_HAVE_64BIT_ATOMICS = @DCFG_HAVE_64BIT_ATOMICS@ DCFG_HAVE_ATOMIC_BUILTINS = @DCFG_HAVE_ATOMIC_BUILTINS@ DCFG_HAVE_LIBATOMIC = @DCFG_HAVE_LIBATOMIC@ DCFG_HAVE_QSORT_R = @DCFG_HAVE_QSORT_R@ +DCFG_HAVE_UTIMENSAT = @DCFG_HAVE_UTIMENSAT@ DCFG_MINFO_BRACKETING = @DCFG_MINFO_BRACKETING@ DCFG_THREAD_MODEL = @DCFG_THREAD_MODEL@ DEFS = @DEFS@ diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d index 76e4460550df..9161912b8cb9 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/stat.d +++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d @@ -975,9 +975,14 @@ version (CRuntime_Glibc) enum UTIME_NOW = 0x3fffffff; enum UTIME_OMIT = 0x3ffffffe; - int utimensat(int dirfd, const char *pathname, - ref const(timespec)[2] times, int flags); - int futimens(int fd, ref const(timespec)[2] times); + // utimensat was added in glibc in 2.6. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90261 + import gcc.config : Have_Utimensat; + static if (Have_Utimensat) + { + int utimensat(int dirfd, const char *pathname, + ref const(timespec)[2] times, int flags); + int futimens(int fd, ref const(timespec)[2] times); + } } else version (Darwin) { diff --git a/libphobos/libdruntime/gcc/config.d.in b/libphobos/libdruntime/gcc/config.d.in index 9c58af0e4f65..0a3782ff2b47 100644 --- a/libphobos/libdruntime/gcc/config.d.in +++ b/libphobos/libdruntime/gcc/config.d.in @@ -49,3 +49,6 @@ enum GNU_Have_LibAtomic = @DCFG_HAVE_LIBATOMIC@; // Do we have qsort_r function enum Have_Qsort_R = @DCFG_HAVE_QSORT_R@; + +// Do we have utimensat function +enum Have_Utimensat = @DCFG_HAVE_UTIMENSAT@; diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4 index a7aab4dd88be..74f9f040cdf2 100644 --- a/libphobos/m4/druntime/libraries.m4 +++ b/libphobos/m4/druntime/libraries.m4 @@ -236,5 +236,8 @@ AC_DEFUN([DRUNTIME_LIBRARIES_CLIB], DCFG_HAVE_QSORT_R=false AC_CHECK_FUNC(qsort_r, [DCFG_HAVE_QSORT_R=true]) AC_SUBST(DCFG_HAVE_QSORT_R) + DCFG_HAVE_UTIMENSAT=false + AC_CHECK_FUNC(utimensat, [DCFG_HAVE_UTIMENSAT=true]) + AC_SUBST(DCFG_HAVE_UTIMENSAT) AC_LANG_POP([C]) ]) diff --git a/libphobos/src/Makefile.in b/libphobos/src/Makefile.in index 5a46cb9c4bde..27c1391f6103 100644 --- a/libphobos/src/Makefile.in +++ b/libphobos/src/Makefile.in @@ -286,6 +286,7 @@ DCFG_HAVE_64BIT_ATOMICS = @DCFG_HAVE_64BIT_ATOMICS@ DCFG_HAVE_ATOMIC_BUILTINS = @DCFG_HAVE_ATOMIC_BUILTINS@ DCFG_HAVE_LIBATOMIC = @DCFG_HAVE_LIBATOMIC@ DCFG_HAVE_QSORT_R = @DCFG_HAVE_QSORT_R@ +DCFG_HAVE_UTIMENSAT = @DCFG_HAVE_UTIMENSAT@ DCFG_MINFO_BRACKETING = @DCFG_MINFO_BRACKETING@ DCFG_THREAD_MODEL = @DCFG_THREAD_MODEL@ DEFS = @DEFS@ diff --git a/libphobos/src/std/file.d b/libphobos/src/std/file.d index 9ba992944ebd..8c0c85da35ed 100644 --- a/libphobos/src/std/file.d +++ b/libphobos/src/std/file.d @@ -1344,7 +1344,7 @@ if (isConvertibleToString!R) } testTimes(0); - version (linux) + static if (is(typeof(&utimensat))) testTimes(123_456_7); rmdirRecurse(newdir); diff --git a/libphobos/testsuite/Makefile.in b/libphobos/testsuite/Makefile.in index efbd884d7ae7..735a36e426a4 100644 --- a/libphobos/testsuite/Makefile.in +++ b/libphobos/testsuite/Makefile.in @@ -159,6 +159,7 @@ DCFG_HAVE_64BIT_ATOMICS = @DCFG_HAVE_64BIT_ATOMICS@ DCFG_HAVE_ATOMIC_BUILTINS = @DCFG_HAVE_ATOMIC_BUILTINS@ DCFG_HAVE_LIBATOMIC = @DCFG_HAVE_LIBATOMIC@ DCFG_HAVE_QSORT_R = @DCFG_HAVE_QSORT_R@ +DCFG_HAVE_UTIMENSAT = @DCFG_HAVE_UTIMENSAT@ DCFG_MINFO_BRACKETING = @DCFG_MINFO_BRACKETING@ DCFG_THREAD_MODEL = @DCFG_THREAD_MODEL@ DEFS = @DEFS@