From patchwork Fri Oct 4 15:08:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1171894 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-510269-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WsyXumDz"; 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 46lCtf17WRz9sNw for ; Sat, 5 Oct 2019 01:08:24 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=I0qNGGKgAOR+omQKBiUwmtlH/4u5OS93iInnWuP+haGMoMoitzL/g tOGXJJ9Am8tf4NFyD64gFA7qZH+rGSFo6HO4XfuqRvFSjPtB4i4rzcvF2uZffNa0 DkXAbKSin5EJv3ICxX3G6zu1MCMjT8h26FilCX4BlgPVKNXu5QNMIw= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=FzKKoDZLvAisbdAhBmYy3c3OTgA=; b=WsyXumDzOZQaIsMfA9lu mYBlTDBiMZXVmqZs36LR/J2EfOYy7At4DqPYWHghHDVFGHoEZAwaU1CcCAdxPYEX mLFExd6mbBbXBlPUCoRe8kNp1yCqt47MvFgyccT1koeJGOPFaknIZzBI/pPPqCHs +d76ZrAMYBFcrDtrbIYkOjc= Received: (qmail 28389 invoked by alias); 4 Oct 2019 15:08:17 -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 28373 invoked by uid 89); 4 Oct 2019 15:08:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=inode, 91947, 9517, file_size X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 Oct 2019 15:08:07 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D0D3A30A5A54; Fri, 4 Oct 2019 15:08:05 +0000 (UTC) Received: from localhost (unknown [10.33.36.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6422A60C5D; Fri, 4 Oct 2019 15:08:05 +0000 (UTC) Date: Fri, 4 Oct 2019 16:08:04 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] Build filesystem library with large file support Message-ID: <20191004150804.GA16335@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.12.1 (2019-06-15) Enable AC_SYS_LARGEFILE to set the macros needed for large file APIs to be used by default. We do not want to define those macros in the public headers that users include. The values of the macros are copied to a separate file that is only included by the filesystem sources during the build, and then the macros in are renamed so that they don't have any effect in user code including our headers. Also use larger type for result of filesystem::file_size to avoid truncation of large values on 32-bit systems (PR 91947). PR libstdc++/81091 PR libstdc++/91947 * configure.ac: Use AC_SYS_LARGEFILE to enable 64-bit file APIs. * config.h.in: Regenerate: * configure: Regenerate: * include/Makefile.am (${host_builddir}/largefile-config.h): New target to generate config header for filesystem library. (${host_builddir}/c++config.h): Rename macros for large file support. * include/Makefile.in: Regenerate. * src/c++17/fs_dir.cc: Include new config header. * src/c++17/fs_ops.cc: Likewise. (filesystem::file_size): Use uintmax_t for size. * src/filesystem/dir.cc: Include new config header. * src/filesystem/ops.cc: Likewise. (experimental::filesystem::file_size): Use uintmax_t for size. Tested x86_64-linux, i686-linux, powerpv64le-linux. I've verified that a 10gb file has its size correctly reported on 32-bit x86 now. Committed to trunk. commit c483318c3948a91086e6cf978dd58eafc78564c3 Author: Jonathan Wakely Date: Wed Oct 2 15:16:51 2019 +0100 Build filesystem library with large file support Enable AC_SYS_LARGEFILE to set the macros needed for large file APIs to be used by default. We do not want to define those macros in the public headers that users include. The values of the macros are copied to a separate file that is only included by the filesystem sources during the build, and then the macros in are renamed so that they don't have any effect in user code including our headers. Also use larger type for result of filesystem::file_size to avoid truncation of large values on 32-bit systems (PR 91947). PR libstdc++/81091 PR libstdc++/91947 * configure.ac: Use AC_SYS_LARGEFILE to enable 64-bit file APIs. * config.h.in: Regenerate: * configure: Regenerate: * include/Makefile.am (${host_builddir}/largefile-config.h): New target to generate config header for filesystem library. (${host_builddir}/c++config.h): Rename macros for large file support. * include/Makefile.in: Regenerate. * src/c++17/fs_dir.cc: Include new config header. * src/c++17/fs_ops.cc: Likewise. (filesystem::file_size): Use uintmax_t for size. * src/filesystem/dir.cc: Include new config header. * src/filesystem/ops.cc: Likewise. (experimental::filesystem::file_size): Use uintmax_t for size. diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index ad4ae0c3b7d..154819acefe 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -83,6 +83,8 @@ AC_PROG_CC AC_PROG_CXX CXXFLAGS="$save_CXXFLAGS" +AC_SYS_LARGEFILE + # Runs configure.host, and assorted other critical bits. Sets # up critical shell variables. GLIBCXX_CONFIGURE diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index b8b786d9260..3e9540ca047 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -1014,6 +1014,7 @@ allstamped = \ # catenation. allcreated = \ ${host_builddir}/c++config.h \ + ${host_builddir}/largefile-config.h \ ${thread_host_headers} \ ${pch_build} @@ -1237,10 +1238,29 @@ stamp-float128: echo 'undef _GLIBCXX_USE_FLOAT128' > stamp-float128 endif +# This header is not installed, it's only used to build libstdc++ itself. +${host_builddir}/largefile-config.h: ${CONFIG_HEADER} \ + ${glibcxx_srcdir}/include/bits/c++config + @echo '#if defined _GLIBCXX_CXX_CONFIG_H || defined _FEATURES_H' > $@ + @echo '# error "This file must be included before any others"' >> $@ + @echo '#endif' >> $@ + @echo >> $@ + @echo '/* Enable large inode numbers on Mac OS X 10.5. */' >> $@ + @echo '#ifndef _DARWIN_USE_64_BIT_INODE' >> $@ + @echo '# define _DARWIN_USE_64_BIT_INODE 1' >> $@ + @echo '#endif' >> $@ + @echo >> $@ + @echo '/* Number of bits in a file offset, on hosts where this is settable. */' >> $@ + @grep '_FILE_OFFSET_BITS' ${CONFIG_HEADER} >> $@ + @echo >> $@ + @echo '/* Define for large files, on AIX-style hosts. */' >> $@ + @grep '_LARGE_FILES' ${CONFIG_HEADER} >> $@ + # NB: The non-empty default ldbl_compat works around an AIX sed # oddity, see libstdc++/31957 for details. ${host_builddir}/c++config.h: ${CONFIG_HEADER} \ ${glibcxx_srcdir}/include/bits/c++config \ + ${host_builddir}/largefile-config.h \ stamp-${host_alias} \ ${toplevel_srcdir}/gcc/DATESTAMP \ stamp-namespace-version \ @@ -1278,6 +1298,9 @@ ${host_builddir}/c++config.h: ${CONFIG_HEADER} \ -e 's/PACKAGE/_GLIBCXX_PACKAGE/g' \ -e 's/VERSION/_GLIBCXX_VERSION/g' \ -e 's/WORDS_/_GLIBCXX_WORDS_/g' \ + -e 's/_DARWIN_USE_64_BIT_INODE/_GLIBCXX_DARWIN_USE_64_BIT_INODE/g' \ + -e 's/_FILE_OFFSET_BITS/_GLIBCXX_FILE_OFFSET_BITS/g' \ + -e 's/_LARGE_FILES/_GLIBCXX_LARGE_FILES/g' \ -e 's/ICONV_CONST/_GLIBCXX_ICONV_CONST/g' \ -e '/[ ]_GLIBCXX_LONG_DOUBLE_COMPAT[ ]/d' \ < ${CONFIG_HEADER} >> $@ ;\ diff --git a/libstdc++-v3/src/c++17/fs_dir.cc b/libstdc++-v3/src/c++17/fs_dir.cc index d8c48f6d6d8..bcbcd7ba6b3 100644 --- a/libstdc++-v3/src/c++17/fs_dir.cc +++ b/libstdc++-v3/src/c++17/fs_dir.cc @@ -26,6 +26,7 @@ # define _GLIBCXX_USE_CXX11_ABI 1 #endif +#include #include #include #include diff --git a/libstdc++-v3/src/c++17/fs_ops.cc b/libstdc++-v3/src/c++17/fs_ops.cc index d8064819d36..2541530e784 100644 --- a/libstdc++-v3/src/c++17/fs_ops.cc +++ b/libstdc++-v3/src/c++17/fs_ops.cc @@ -28,6 +28,7 @@ # define NEED_DO_SPACE #endif +#include #include #include #include @@ -950,7 +951,7 @@ fs::file_size(const path& p, error_code& ec) noexcept S(const stat_type& st) : type(make_file_type(st)), size(st.st_size) { } S() : type(file_type::not_found) { } file_type type; - size_t size; + uintmax_t size; }; auto s = do_stat(p, ec, [](const auto& st) { return S{st}; }, S{}); if (s.type == file_type::regular) diff --git a/libstdc++-v3/src/filesystem/dir.cc b/libstdc++-v3/src/filesystem/dir.cc index 3e6e598fa64..ac3bd3aafb3 100644 --- a/libstdc++-v3/src/filesystem/dir.cc +++ b/libstdc++-v3/src/filesystem/dir.cc @@ -26,6 +26,7 @@ # define _GLIBCXX_USE_CXX11_ABI 1 #endif +#include #include #ifndef _GLIBCXX_HAVE_DIRENT_H diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc index 36b5d2c24f6..8687fcdc297 100644 --- a/libstdc++-v3/src/filesystem/ops.cc +++ b/libstdc++-v3/src/filesystem/ops.cc @@ -28,6 +28,7 @@ # define NEED_DO_SPACE #endif +#include #include #include #include @@ -806,7 +807,7 @@ fs::file_size(const path& p, error_code& ec) noexcept S(const stat_type& st) : type(make_file_type(st)), size(st.st_size) { } S() : type(file_type::not_found) { } file_type type; - size_t size; + uintmax_t size; }; auto s = do_stat(p, ec, [](const auto& st) { return S{st}; }, S{}); if (s.type == file_type::regular)