From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23049 invoked by alias); 6 Jan 2019 22:36:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 22922 invoked by uid 89); 6 Jan 2019 22:36:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=sk:_znst10, sk:_ZNSt10, beg, 356 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; Sun, 06 Jan 2019 22:36:34 +0000 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A73C7394D59; Sun, 6 Jan 2019 22:36:33 +0000 (UTC) Received: from localhost (unknown [10.33.36.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAB2819C7C; Sun, 6 Jan 2019 22:36:32 +0000 (UTC) Date: Sun, 06 Jan 2019 22:36:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] PR libstdc++/86756 Move rest of std::filesystem to libstdc++.so Message-ID: <20190106223631.GM15627@redhat.com> References: <20190106223506.GA21904@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="OaZoDhBhXzo6bW1J" Content-Disposition: inline In-Reply-To: <20190106223506.GA21904@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2019-01/txt/msg00253.txt.bz2 --OaZoDhBhXzo6bW1J Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 1003 Move std::filesystem directory iterators and operations from libstdc++fs.a to main libstdc++ library. These components have many dependencies on OS support, which is not available on all targets. Some additional autoconf checks and conditional compilation is needed to ensure the files will build for all targets. Previously this code was not compiled without --enable-libstdcxx-filesystem-ts but the C++17 components should be available for all hosted builds. The tests for these components no longer need to link to libstdc++fs.a, but are not expected to pass on all targets. To avoid numerous failures on targets which are not expected to pass the tests (due to missing OS functionality) leave the dg-require-filesystem-ts directives in place for now. This will ensure the tests only run for builds where the filesystem-ts library is built, which presumably means some level of OS support is present. Tested x86_64-linux (old/new string ABIs, 32/64 bit), x86_64-w64-mingw32. Committed to trunk. --OaZoDhBhXzo6bW1J Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 55926 commit e83709b79c339f92fbcee748bbe755bf40825210 Author: Jonathan Wakely Date: Sun Jan 6 17:45:40 2019 +0000 PR libstdc++/86756 Move rest of std::filesystem to libstdc++.so Move std::filesystem directory iterators and operations from libstdc++fs.a to main libstdc++ library. These components have many dependencies on OS support, which is not available on all targets. Some additional autoconf checks and conditional compilation is needed to ensure the files will build for all targets. Previously this code was not compiled without --enable-libstdcxx-filesystem-ts but the C++17 components should be available for all hosted builds. The tests for these components no longer need to link to libstdc++fs.a, but are not expected to pass on all targets. To avoid numerous failures on targets which are not expected to pass the tests (due to missing OS functionality) leave the dg-require-filesystem-ts directives in place for now. This will ensure the tests only run for builds where the filesystem-ts library is built, which presumably means some level of OS support is present. PR libstdc++/86756 * acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for utime and lstat and define _GLIBCXX_USE_UTIME and _GLIBCXX_USE_LSTAT. * config.h.in: Regenerate. * config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Export symbols for remaining std::filesystem types and functions. * configure: Regenerate. * src/c++17/Makefile.am: Add C++17 filesystem sources. * src/c++17/Makefile.in: Regenerate. * src/c++17/cow-fs_dir.cc: Move src/filesystem/cow-std-dir.cc to here, and change name of included file. * src/c++17/cow-fs_ops.cc: Move src/filesystem/cow-std-ops.cc to here, and change name of included file. * src/c++17/fs_dir.cc: Move src/filesystem/std-dir.cc to here. Change path to dir-common.h. * src/c++17/fs_ops.cc: Move src/filesystem/std-ops.cc to here. Change path to ops-common.h. Disable -Wunused-parameter warnings. (internal_file_clock): Define unconditionally. [!_GLIBCXX_HAVE_SYS_STAT_H] (internal_file_clock::from_stat): Do not define. (do_copy_file, do_space): Move definitions to ops.common.h. (copy, file_size, hard_link_count, last_write_time, space): Only perform operation when _GLIBCXX_HAVE_SYS_STAT_H is defined, otherwise report an error. (last_write_time, read_symlink): Remove unused attributes from parameters. * src/filesystem/Makefile.am: Remove C++17 filesystem sources. * src/filesystem/Makefile.in: Regenerate. * src/filesystem/cow-std-dir.cc: Move to src/c++17/cow-fs_dir.cc. * src/filesystem/cow-std-ops.cc: Move to src/c++17/cow-fs_ops.cc. * src/filesystem/std-dir.cc: Move to src/c++17/fs_dir.cc. * src/filesystem/std-ops.cc: Move to src/c++17/fs_ops.cc. * src/filesystem/dir-common.h [!_GLIBCXX_HAVE_DIRENT_H]: Define dummy types and functions instead of using #error. * src/filesystem/dir.cc [!_GLIBCXX_HAVE_DIRENT_H]: Use #error. * src/filesystem/ops-common.h [!_GLIBCXX_USE_LSTAT] (lstat): Define in terms of stat. [!_GLIBCXX_HAVE_UNISTD_H]: Define dummy types and functions. (do_copy_file, do_space): Move definitions here from std-ops.cc. * src/filesystem/ops.cc: Adjust calls to do_copy_file and do_space to account for new namespace. * testsuite/27_io/filesystem/directory_entry/86597.cc: Remove -lstdc++fs from dg-options. * testsuite/27_io/filesystem/directory_entry/lwg3171.cc: Likewise. * testsuite/27_io/filesystem/file_status/1.cc: Likewise. * testsuite/27_io/filesystem/filesystem_error/cons.cc: Likewise. * testsuite/27_io/filesystem/filesystem_error/copy.cc: Likewise. * testsuite/27_io/filesystem/iterators/directory_iterator.cc: Likewise. * testsuite/27_io/filesystem/iterators/pop.cc: Likewise. * testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc: Likewise. * testsuite/27_io/filesystem/operations/absolute.cc: Likewise. * testsuite/27_io/filesystem/operations/canonical.cc: Likewise. * testsuite/27_io/filesystem/operations/copy.cc: Likewise. * testsuite/27_io/filesystem/operations/copy_file.cc: Likewise. * testsuite/27_io/filesystem/operations/create_directories.cc: Likewise. * testsuite/27_io/filesystem/operations/create_directory.cc: Likewise. * testsuite/27_io/filesystem/operations/create_symlink.cc: Likewise. * testsuite/27_io/filesystem/operations/current_path.cc: Likewise. * testsuite/27_io/filesystem/operations/equivalent.cc: Likewise. * testsuite/27_io/filesystem/operations/exists.cc: Likewise. * testsuite/27_io/filesystem/operations/file_size.cc: Likewise. * testsuite/27_io/filesystem/operations/is_empty.cc: Likewise. * testsuite/27_io/filesystem/operations/last_write_time.cc: Likewise. * testsuite/27_io/filesystem/operations/permissions.cc: Likewise. * testsuite/27_io/filesystem/operations/proximate.cc: Likewise. * testsuite/27_io/filesystem/operations/read_symlink.cc: Likewise. * testsuite/27_io/filesystem/operations/relative.cc: Likewise. * testsuite/27_io/filesystem/operations/remove.cc: Likewise. * testsuite/27_io/filesystem/operations/remove_all.cc: Likewise. * testsuite/27_io/filesystem/operations/space.cc: Likewise. * testsuite/27_io/filesystem/operations/status.cc: Likewise. * testsuite/27_io/filesystem/operations/symlink_status.cc: Likewise. * testsuite/27_io/filesystem/operations/temp_directory_path.cc: Likewise. * testsuite/27_io/filesystem/operations/weakly_canonical.cc: Likewise. diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 6bcd29dc8c3..ce91e495fab 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -4451,6 +4451,40 @@ dnl AC_DEFINE(_GLIBCXX_USE_UTIMENSAT, 1, [Define if utimensat and UTIME_OMIT are available in and AT_FDCWD in .]) fi AC_MSG_RESULT($glibcxx_cv_utimensat) +dnl + AC_MSG_CHECKING([for utime]) + AC_CACHE_VAL(glibcxx_cv_utime, [dnl + GCC_TRY_COMPILE_OR_LINK( + [ + #include + ], + [ + struct utimbuf t = { 1, 1 }; + int i = utime("path", &t); + ], + [glibcxx_cv_utime=yes], + [glibcxx_cv_utime=no]) + ]) + if test $glibcxx_cv_utime = yes; then + AC_DEFINE(_GLIBCXX_USE_UTIME, 1, [Define if utime is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_utime) +dnl + AC_MSG_CHECKING([for lstat]) + AC_CACHE_VAL(glibcxx_cv_lstat, [dnl + GCC_TRY_COMPILE_OR_LINK( + [ #include ], + [ + struct stat st; + int i = lstat("path", &st); + ], + [glibcxx_cv_lstat=yes], + [glibcxx_cv_lstat=no]) + ]) + if test $glibcxx_cv_lstat = yes; then + AC_DEFINE(_GLIBCXX_USE_LSTAT, 1, [Define if lstat is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_lstat) dnl AC_MSG_CHECKING([for struct stat.st_mtim.tv_nsec]) AC_CACHE_VAL(glibcxx_cv_st_mtim, [dnl diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index f83d2b1cca9..20325bf7a33 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -2167,6 +2167,58 @@ GLIBCXX_3.4.26 { _ZNSt10filesystem7__cxx114pathpLERKS1_; _ZT[IV]NSt10filesystem7__cxx1116filesystem_errorE; + _ZNSt10filesystem10equivalent*; + _ZNSt10filesystem10remove_all*; + _ZNSt10filesystem11permissions*; + _ZNSt10filesystem12current_path*; + _ZNSt10filesystem12read_symlink*; + _ZNSt10filesystem14create_symlink*; + _ZNSt10filesystem14symlink_status*; + _ZNSt10filesystem15last_write_time*; + _ZNSt10filesystem16create_directory*; + _ZNSt10filesystem16create_hard_link*; + _ZNSt10filesystem16weakly_canonical*; + _ZNSt10filesystem18create_directories*; + _ZNSt10filesystem19temp_directory_path*; + _ZNSt10filesystem24create_directory_symlink*; + _ZNSt10filesystem4copy*; + _ZNSt10filesystem5space*; + _ZNSt10filesystem6remove*; + _ZNSt10filesystem6status*; + _ZNSt10filesystem8absolute*; + _ZNSt10filesystem8is_empty*; + _ZNSt10filesystem8relative*; + _ZNSt10filesystem9canonical*; + _ZNSt10filesystem9copy_file*; + _ZNSt10filesystem9file_size*; + _ZNSt10filesystem9proximate*; + + _ZNKSt10filesystem18directory_iteratordeEv; + _ZNKSt10filesystem28recursive_directory_iterator5depthEv; + _ZNKSt10filesystem28recursive_directory_iteratordeEv; + _ZNSt10filesystem18directory_iteratorC[12]ERKNS_4pathENS_17directory_optionsEPSt10error_code; + _ZNSt10filesystem18directory_iteratorppEv; + _ZNSt10filesystem28recursive_directory_iterator3popERSt10error_code; + _ZNSt10filesystem28recursive_directory_iterator3popEv; + _ZNSt10filesystem28recursive_directory_iterator9incrementERSt10error_code; + _ZNSt10filesystem28recursive_directory_iteratorC[12]ERKNS_4pathENS_17directory_optionsEPSt10error_code; + _ZNSt10filesystem28recursive_directory_iteratorD[12]Ev; + _ZNSt10filesystem28recursive_directory_iteratoraSEOS0_; + _ZNSt10filesystem28recursive_directory_iteratorppEv; + + _ZNKSt10filesystem7__cxx1118directory_iteratordeEv; + _ZNKSt10filesystem7__cxx1128recursive_directory_iterator5depthEv; + _ZNKSt10filesystem7__cxx1128recursive_directory_iteratordeEv; + _ZNSt10filesystem7__cxx1118directory_iteratorC[12]ERKNS0_4pathENS_17directory_optionsEPSt10error_code; + _ZNSt10filesystem7__cxx1118directory_iteratorppEv; + _ZNSt10filesystem7__cxx1128recursive_directory_iterator3popERSt10error_code; + _ZNSt10filesystem7__cxx1128recursive_directory_iterator3popEv; + _ZNSt10filesystem7__cxx1128recursive_directory_iterator9incrementERSt10error_code; + _ZNSt10filesystem7__cxx1128recursive_directory_iteratorC[12]ERKNS0_4pathENS_17directory_optionsEPSt10error_code; + _ZNSt10filesystem7__cxx1128recursive_directory_iteratorD[12]Ev; + _ZNSt10filesystem7__cxx1128recursive_directory_iteratoraSEOS1_; + _ZNSt10filesystem7__cxx1128recursive_directory_iteratorppEv; + } GLIBCXX_3.4.25; # Symbols in the support library (libsupc++) have their own tag. diff --git a/libstdc++-v3/src/c++17/Makefile.am b/libstdc++-v3/src/c++17/Makefile.am index 85883c33f2d..4200f7f8259 100644 --- a/libstdc++-v3/src/c++17/Makefile.am +++ b/libstdc++-v3/src/c++17/Makefile.am @@ -29,7 +29,10 @@ headers = if ENABLE_DUAL_ABI extra_string_inst_sources = cow-string-inst.cc -extra_fs_sources = cow-fs_path.cc +extra_fs_sources = \ + cow-fs_dir.cc \ + cow-fs_ops.cc \ + cow-fs_path.cc else extra_string_inst_sources = extra_fs_sources = @@ -45,6 +48,8 @@ inst_sources = endif sources = \ + fs_dir.cc \ + fs_ops.cc \ fs_path.cc \ memory_resource.cc \ string-inst.cc \ diff --git a/libstdc++-v3/src/filesystem/cow-std-dir.cc b/libstdc++-v3/src/c++17/cow-fs_dir.cc similarity index 98% rename from libstdc++-v3/src/filesystem/cow-std-dir.cc rename to libstdc++-v3/src/c++17/cow-fs_dir.cc +++ b/libstdc++-v3/src/c++17/cow-fs_dir.cc @@ -23,4 +23,4 @@ // . #define _GLIBCXX_USE_CXX11_ABI 0 -#include "std-dir.cc" +#include "fs_dir.cc" diff --git a/libstdc++-v3/src/filesystem/cow-std-ops.cc b/libstdc++-v3/src/c++17/cow-fs_ops.cc similarity index 98% rename from libstdc++-v3/src/filesystem/cow-std-ops.cc rename to libstdc++-v3/src/c++17/cow-fs_ops.cc +++ b/libstdc++-v3/src/c++17/cow-fs_ops.cc @@ -23,4 +23,4 @@ // . #define _GLIBCXX_USE_CXX11_ABI 0 -#include "std-ops.cc" +#include "fs_ops.cc" diff --git a/libstdc++-v3/src/filesystem/std-dir.cc b/libstdc++-v3/src/c++17/fs_dir.cc similarity index 99% rename from libstdc++-v3/src/filesystem/std-dir.cc rename to libstdc++-v3/src/c++17/fs_dir.cc +++ b/libstdc++-v3/src/c++17/fs_dir.cc @@ -27,14 +27,13 @@ #endif #include -#include #include #include #include #include #define _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM namespace filesystem { #define _GLIBCXX_END_NAMESPACE_FILESYSTEM } -#include "dir-common.h" +#include "../filesystem/dir-common.h" namespace fs = std::filesystem; namespace posix = std::filesystem::__gnu_posix; diff --git a/libstdc++-v3/src/filesystem/std-ops.cc b/libstdc++-v3/src/c++17/fs_ops.cc similarity index 84% rename from libstdc++-v3/src/filesystem/std-ops.cc rename to libstdc++-v3/src/c++17/fs_ops.cc +++ b/libstdc++-v3/src/c++17/fs_ops.cc @@ -29,11 +29,9 @@ #endif #include -#include #include #include #include -#include #include #include #include @@ -47,9 +45,6 @@ #ifdef _GLIBCXX_HAVE_SYS_STATVFS_H # include // statvfs #endif -#ifdef _GLIBCXX_USE_SENDFILE -# include // sendfile -#endif #if !_GLIBCXX_USE_UTIMENSAT && _GLIBCXX_HAVE_UTIME_H # include // utime #endif @@ -59,7 +54,9 @@ #define _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM namespace filesystem { #define _GLIBCXX_END_NAMESPACE_FILESYSTEM } -#include "ops-common.h" +#include "../filesystem/ops-common.h" + +#pragma GCC diagnostic ignored "-Wunused-parameter" namespace fs = std::filesystem; namespace posix = std::filesystem::__gnu_posix; @@ -274,8 +271,6 @@ namespace std::filesystem } } -#ifdef _GLIBCXX_HAVE_SYS_STAT_H - namespace { struct internal_file_clock : fs::__file_clock @@ -283,6 +278,7 @@ namespace using __file_clock::_S_to_sys; using __file_clock::_S_from_sys; +#ifdef _GLIBCXX_HAVE_SYS_STAT_H static fs::file_time_type from_stat(const fs::stat_type& st, std::error_code& ec) noexcept { @@ -291,209 +287,15 @@ namespace return fs::file_time_type::min(); return _S_from_sys(sys_time); } +#endif }; } -#ifdef NEED_DO_COPY_FILE -bool -fs::do_copy_file(const path::value_type* from, const path::value_type* to, - copy_options_existing_file options, - stat_type* from_st, stat_type* to_st, - std::error_code& ec) noexcept -{ - stat_type st1, st2; - fs::file_status t, f; - - if (to_st == nullptr) - { - if (posix::stat(to, &st1)) - { - const int err = errno; - if (!is_not_found_errno(err)) - { - ec.assign(err, std::generic_category()); - return false; - } - } - else - to_st = &st1; - } - else if (to_st == from_st) - to_st = nullptr; - - if (to_st == nullptr) - t = fs::file_status{fs::file_type::not_found}; - else - t = make_file_status(*to_st); - - if (from_st == nullptr) - { - if (posix::stat(from, &st2)) - { - ec.assign(errno, std::generic_category()); - return false; - } - else - from_st = &st2; - } - f = make_file_status(*from_st); - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 2712. copy_file() has a number of unspecified error conditions - if (!is_regular_file(f)) - { - ec = std::make_error_code(std::errc::not_supported); - return false; - } - - if (exists(t)) - { - if (!is_regular_file(t)) - { - ec = std::make_error_code(std::errc::not_supported); - return false; - } - - if (to_st->st_dev == from_st->st_dev - && to_st->st_ino == from_st->st_ino) - { - ec = std::make_error_code(std::errc::file_exists); - return false; - } - - if (options.skip) - { - ec.clear(); - return false; - } - else if (options.update) - { - const auto from_mtime = internal_file_clock::from_stat(*from_st, ec); - if (ec) - return false; - if ((from_mtime <= internal_file_clock::from_stat(*to_st, ec)) || ec) - return false; - } - else if (!options.overwrite) - { - ec = std::make_error_code(std::errc::file_exists); - return false; - } - else if (!is_regular_file(t)) - { - ec = std::make_error_code(std::errc::not_supported); - return false; - } - } - - struct CloseFD { - ~CloseFD() { if (fd != -1) posix::close(fd); } - bool close() { return posix::close(std::exchange(fd, -1)) == 0; } - int fd; - }; - - CloseFD in = { posix::open(from, O_RDONLY) }; - if (in.fd == -1) - { - ec.assign(errno, std::generic_category()); - return false; - } - int oflag = O_WRONLY|O_CREAT; - if (options.overwrite || options.update) - oflag |= O_TRUNC; - else - oflag |= O_EXCL; - CloseFD out = { posix::open(to, oflag, S_IWUSR) }; - if (out.fd == -1) - { - if (errno == EEXIST && options.skip) - ec.clear(); - else - ec.assign(errno, std::generic_category()); - return false; - } - -#if defined _GLIBCXX_USE_FCHMOD && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS - if (::fchmod(out.fd, from_st->st_mode)) -#elif defined _GLIBCXX_USE_FCHMODAT && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS - if (::fchmodat(AT_FDCWD, to, from_st->st_mode, 0)) -#else - if (posix::chmod(to, from_st->st_mode)) -#endif - { - ec.assign(errno, std::generic_category()); - return false; - } - - size_t count = from_st->st_size; -#if defined _GLIBCXX_USE_SENDFILE && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS - off_t offset = 0; - ssize_t n = ::sendfile(out.fd, in.fd, &offset, count); - if (n < 0 && errno != ENOSYS && errno != EINVAL) - { - ec.assign(errno, std::generic_category()); - return false; - } - if ((size_t)n == count) - { - if (!out.close() || !in.close()) - { - ec.assign(errno, std::generic_category()); - return false; - } - ec.clear(); - return true; - } - else if (n > 0) - count -= n; -#endif // _GLIBCXX_USE_SENDFILE - - using std::ios; - __gnu_cxx::stdio_filebuf sbin(in.fd, ios::in|ios::binary); - __gnu_cxx::stdio_filebuf sbout(out.fd, ios::out|ios::binary); - - if (sbin.is_open()) - in.fd = -1; - if (sbout.is_open()) - out.fd = -1; - -#ifdef _GLIBCXX_USE_SENDFILE - if (n != 0) - { - if (n < 0) - n = 0; - - const auto p1 = sbin.pubseekoff(n, ios::beg, ios::in); - const auto p2 = sbout.pubseekoff(n, ios::beg, ios::out); - - const std::streampos errpos(std::streamoff(-1)); - if (p1 == errpos || p2 == errpos) - { - ec = std::make_error_code(std::errc::io_error); - return false; - } - } -#endif - - if (count && !(std::ostream(&sbout) << &sbin)) - { - ec = std::make_error_code(std::errc::io_error); - return false; - } - if (!sbout.close() || !sbin.close()) - { - ec.assign(errno, std::generic_category()); - return false; - } - ec.clear(); - return true; -} -#endif // NEED_DO_COPY_FILE -#endif // _GLIBCXX_HAVE_SYS_STAT_H - void fs::copy(const path& from, const path& to, copy_options options, error_code& ec) { +#ifdef _GLIBCXX_HAVE_SYS_STAT_H const bool skip_symlinks = is_set(options, copy_options::skip_symlinks); const bool create_symlinks = is_set(options, copy_options::create_symlinks); const bool copy_symlinks = is_set(options, copy_options::copy_symlinks); @@ -591,6 +393,9 @@ fs::copy(const path& from, const path& to, copy_options options, // 2683. filesystem::copy() says "no effects" else ec.clear(); +#else + ec = std::make_error_code(std::errc::not_supported); +#endif } bool @@ -1068,6 +873,7 @@ namespace std::uintmax_t fs::file_size(const path& p, error_code& ec) noexcept { +#ifdef _GLIBCXX_HAVE_SYS_STAT_H struct S { S(const stat_type& st) : type(make_file_type(st)), size(st.st_size) { } @@ -1085,6 +891,9 @@ fs::file_size(const path& p, error_code& ec) noexcept else ec = std::make_error_code(std::errc::not_supported); } +#else + ec = std::make_error_code(std::errc::not_supported); +#endif return -1; } @@ -1101,8 +910,13 @@ fs::hard_link_count(const path& p) std::uintmax_t fs::hard_link_count(const path& p, error_code& ec) noexcept { +#ifdef _GLIBCXX_HAVE_SYS_STAT_H return do_stat(p, ec, std::mem_fn(&stat_type::st_nlink), static_cast(-1)); +#else + ec = std::make_error_code(std::errc::not_supported); + return static_cast(-1); +#endif } bool @@ -1141,11 +955,16 @@ fs::last_write_time(const path& p) fs::file_time_type fs::last_write_time(const path& p, error_code& ec) noexcept { +#ifdef _GLIBCXX_HAVE_SYS_STAT_H return do_stat(p, ec, [&ec](const auto& st) { return internal_file_clock::from_stat(st, ec); }, file_time_type::min()); +#else + ec = std::make_error_code(std::errc::not_supported); + return file_time_type::min(); +#endif } void @@ -1158,7 +977,7 @@ fs::last_write_time(const path& p, file_time_type new_time) } void -fs::last_write_time(const path& p __attribute__((__unused__)), +fs::last_write_time(const path& p, file_time_type new_time, error_code& ec) noexcept { auto d = internal_file_clock::_S_to_sys(new_time).time_since_epoch(); @@ -1179,7 +998,7 @@ fs::last_write_time(const path& p __attribute__((__unused__)), ec.assign(errno, std::generic_category()); else ec.clear(); -#elif _GLIBCXX_HAVE_UTIME_H +#elif _GLIBCXX_USE_UTIME && _GLIBCXX_HAVE_SYS_STAT_H posix::utimbuf times; times.modtime = s.count(); times.actime = do_stat(p, ec, [](const auto& st) { return st.st_atime; }, @@ -1279,7 +1098,7 @@ fs::read_symlink(const path& p) return tgt; } -fs::path fs::read_symlink(const path& p [[gnu::unused]], error_code& ec) +fs::path fs::read_symlink(const path& p, error_code& ec) { path result; #if defined(_GLIBCXX_HAVE_READLINK) && defined(_GLIBCXX_HAVE_SYS_STAT_H) @@ -1472,51 +1291,6 @@ fs::space(const path& p) return s; } -#ifdef NEED_DO_SPACE -void -fs::do_space(const __gnu_posix::char_type* pathname, - uintmax_t& capacity, uintmax_t& free, uintmax_t& available, - std::error_code& ec) -{ -#ifdef _GLIBCXX_HAVE_SYS_STATVFS_H - struct ::statvfs f; - if (::statvfs(pathname, &f)) - ec.assign(errno, std::generic_category()); - else - { - if (f.f_frsize != (unsigned long)-1) - { - const uintmax_t fragment_size = f.f_frsize; - const fsblkcnt_t unknown = -1; - if (f.f_blocks != unknown) - capacity = f.f_blocks * fragment_size; - if (f.f_bfree != unknown) - free = f.f_bfree * fragment_size; - if (f.f_bavail != unknown) - available = f.f_bavail * fragment_size; - } - ec.clear(); - } -#elif _GLIBCXX_FILESYSTEM_IS_WINDOWS - ULARGE_INTEGER bytes_avail = {}, bytes_total = {}, bytes_free = {}; - if (GetDiskFreeSpaceExW(pathname, &bytes_avail, &bytes_total, &bytes_free)) - { - if (bytes_total.QuadPart != 0) - capacity = bytes_total.QuadPart; - if (bytes_free.QuadPart != 0) - free = bytes_free.QuadPart; - if (bytes_avail.QuadPart != 0) - available = bytes_avail.QuadPart; - ec.clear(); - } - else - ec.assign((int)GetLastError(), std::system_category()); -#else - ec = std::make_error_code(std::errc::not_supported); -#endif -} -#endif // NEED_DO_SPACE - fs::space_info fs::space(const path& p, error_code& ec) noexcept { @@ -1525,6 +1299,7 @@ fs::space(const path& p, error_code& ec) noexcept static_cast(-1), static_cast(-1) }; +#ifdef _GLIBCXX_HAVE_SYS_STAT_H #if _GLIBCXX_FILESYSTEM_IS_WINDOWS path dir = absolute(p); dir.remove_filename(); @@ -1532,7 +1307,10 @@ fs::space(const path& p, error_code& ec) noexcept #else auto str = p.c_str(); #endif + do_space(str, info.capacity, info.free, info.available, ec); +#endif // _GLIBCXX_HAVE_SYS_STAT_H + return info; } diff --git a/libstdc++-v3/src/filesystem/Makefile.am b/libstdc++-v3/src/filesystem/Makefile.am index 6f2a9f63b8a..af9dcd25f8e 100644 --- a/libstdc++-v3/src/filesystem/Makefile.am +++ b/libstdc++-v3/src/filesystem/Makefile.am @@ -30,9 +30,7 @@ if ENABLE_DUAL_ABI cxx11_abi_sources = \ cow-dir.cc \ cow-ops.cc \ - cow-path.cc \ - cow-std-dir.cc \ - cow-std-ops.cc + cow-path.cc else cxx11_abi_sources = endif @@ -41,8 +39,6 @@ sources = \ dir.cc \ ops.cc \ path.cc \ - std-dir.cc \ - std-ops.cc \ ${cxx11_abi_sources} # vpath % $(top_srcdir)/src/filesystem diff --git a/libstdc++-v3/src/filesystem/dir-common.h b/libstdc++-v3/src/filesystem/dir-common.h index bcfbfcd0bea..6ec798c9aa0 100644 --- a/libstdc++-v3/src/filesystem/dir-common.h +++ b/libstdc++-v3/src/filesystem/dir-common.h @@ -26,6 +26,7 @@ #define _GLIBCXX_DIR_COMMON_H 1 #include // strcmp +#include #if _GLIBCXX_FILESYSTEM_IS_WINDOWS #include // wcscmp #endif @@ -34,8 +35,6 @@ # include # endif # include -#else -# error "the header is needed to build the Filesystem TS" #endif namespace std _GLIBCXX_VISIBILITY(default) @@ -53,13 +52,20 @@ using dirent = _wdirent; inline DIR* opendir(const wchar_t* path) { return ::_wopendir(path); } inline dirent* readdir(DIR* dir) { return ::_wreaddir(dir); } inline int closedir(DIR* dir) { return ::_wclosedir(dir); } -#else +#elif defined _GLIBCXX_HAVE_DIRENT_H using char_type = char; using DIR = ::DIR; typedef struct ::dirent dirent; using ::opendir; using ::readdir; using ::closedir; +#else +using char_type = char; +struct dirent { const char* d_name; }; +struct DIR { }; +inline DIR* opendir(const char*) { return nullptr; } +inline dirent* readdir(DIR*) { return nullptr; } +inline int closedir(DIR*) { return -1; } #endif } // namespace __gnu_posix diff --git a/libstdc++-v3/src/filesystem/dir.cc b/libstdc++-v3/src/filesystem/dir.cc index 0738ea784f7..3e6e598fa64 100644 --- a/libstdc++-v3/src/filesystem/dir.cc +++ b/libstdc++-v3/src/filesystem/dir.cc @@ -27,6 +27,11 @@ #endif #include + +#ifndef _GLIBCXX_HAVE_DIRENT_H +# error "the header is needed to build the Filesystem TS" +#endif + #include #include #include diff --git a/libstdc++-v3/src/filesystem/ops-common.h b/libstdc++-v3/src/filesystem/ops-common.h index 1c0d650f444..f20867c217e 100644 --- a/libstdc++-v3/src/filesystem/ops-common.h +++ b/libstdc++-v3/src/filesystem/ops-common.h @@ -42,6 +42,14 @@ # include #endif +#ifdef NEED_DO_COPY_FILE +# include +# include +# ifdef _GLIBCXX_USE_SENDFILE +# include // sendfile +# endif +#endif + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -108,26 +116,42 @@ namespace __gnu_posix return ret; } using char_type = wchar_t; -#else // _GLIBCXX_FILESYSTEM_IS_WINDOWS +#elif defined _GLIBCXX_HAVE_UNISTD_H using ::open; using ::close; -#ifdef _GLIBCXX_HAVE_SYS_STAT_H +# ifdef _GLIBCXX_HAVE_SYS_STAT_H typedef struct ::stat stat_type; using ::stat; +# ifdef _GLIBCXX_USE_LSTAT using ::lstat; -#endif +# else + inline int lstat(const char* path, stat_type* buffer) + { return stat(path, buffer); } +# endif +# endif using ::mode_t; using ::chmod; using ::mkdir; using ::getcwd; using ::chdir; -#if !_GLIBCXX_USE_UTIMENSAT && _GLIBCXX_HAVE_UTIME_H +# if !_GLIBCXX_USE_UTIMENSAT && _GLIBCXX_USE_UTIME using ::utimbuf; using ::utime; -#endif +# endif using ::rename; using ::truncate; using char_type = char; +#else // ! _GLIBCXX_FILESYSTEM_IS_WINDOWS && ! _GLIBCXX_HAVE_UNISTD_H + inline int open(const char*, int, ...) { errno = ENOTSUP; return -1; } + inline int close(int) { errno = ENOTSUP; return -1; } + using mode_t = int; + inline int chmod(const char*, mode_t) { errno = ENOTSUP; return -1; } + inline int mkdir(const char*, mode_t) { errno = ENOTSUP; return -1; } + inline char* getcwd(char*, size_t) { errno = ENOTSUP; return nullptr; } + inline int chdir(const char*) { errno = ENOTSUP; return -1; } + inline int rename(const char*, const char*) { errno = ENOTSUP; return -1; } + inline int truncate(const char*, long) { errno = ENOTSUP; return -1; } + using char_type = char; #endif // _GLIBCXX_FILESYSTEM_IS_WINDOWS } // namespace __gnu_posix @@ -190,18 +214,6 @@ namespace __gnu_posix bool skip, update, overwrite; }; - bool - do_copy_file(const __gnu_posix::char_type* from, - const __gnu_posix::char_type* to, - copy_options_existing_file options, - stat_type* from_st, stat_type* to_st, - std::error_code& ec) noexcept; - - void - do_space(const __gnu_posix::char_type* pathname, - uintmax_t& capacity, uintmax_t& free, uintmax_t& available, - std::error_code&); - #endif // _GLIBCXX_HAVE_SYS_STAT_H } // namespace filesystem @@ -211,6 +223,19 @@ _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM #ifdef _GLIBCXX_HAVE_SYS_STAT_H using std::filesystem::__gnu_posix::stat_type; + using std::filesystem::__gnu_posix::char_type; + + bool + do_copy_file(const char_type* from, const char_type* to, + std::filesystem::copy_options_existing_file options, + stat_type* from_st, stat_type* to_st, + std::error_code& ec) noexcept; + + void + do_space(const char_type* pathname, + uintmax_t& capacity, uintmax_t& free, uintmax_t& available, + std::error_code&); + inline file_type make_file_type(const stat_type& st) noexcept @@ -257,6 +282,253 @@ _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM is_set(opt, copy_options::overwrite_existing) }; } + +#ifdef NEED_DO_COPY_FILE + bool + do_copy_file(const char_type* from, const char_type* to, + std::filesystem::copy_options_existing_file options, + stat_type* from_st, stat_type* to_st, + std::error_code& ec) noexcept + { + namespace fs = std::filesystem; + namespace posix = fs::__gnu_posix; + + stat_type st1, st2; + file_status t, f; + + if (to_st == nullptr) + { + if (posix::stat(to, &st1)) + { + const int err = errno; + if (!fs::is_not_found_errno(err)) + { + ec.assign(err, std::generic_category()); + return false; + } + } + else + to_st = &st1; + } + else if (to_st == from_st) + to_st = nullptr; + + if (to_st == nullptr) + t = file_status{file_type::not_found}; + else + t = make_file_status(*to_st); + + if (from_st == nullptr) + { + if (posix::stat(from, &st2)) + { + ec.assign(errno, std::generic_category()); + return false; + } + else + from_st = &st2; + } + f = make_file_status(*from_st); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2712. copy_file() has a number of unspecified error conditions + if (!is_regular_file(f)) + { + ec = std::make_error_code(std::errc::not_supported); + return false; + } + + if (exists(t)) + { + if (!is_regular_file(t)) + { + ec = std::make_error_code(std::errc::not_supported); + return false; + } + + if (to_st->st_dev == from_st->st_dev + && to_st->st_ino == from_st->st_ino) + { + ec = std::make_error_code(std::errc::file_exists); + return false; + } + + if (options.skip) + { + ec.clear(); + return false; + } + else if (options.update) + { + const auto from_mtime = fs::file_time(*from_st, ec); + if (ec) + return false; + if ((from_mtime <= fs::file_time(*to_st, ec)) || ec) + return false; + } + else if (!options.overwrite) + { + ec = std::make_error_code(std::errc::file_exists); + return false; + } + else if (!is_regular_file(t)) + { + ec = std::make_error_code(std::errc::not_supported); + return false; + } + } + + struct CloseFD { + ~CloseFD() { if (fd != -1) posix::close(fd); } + bool close() { return posix::close(std::exchange(fd, -1)) == 0; } + int fd; + }; + + CloseFD in = { posix::open(from, O_RDONLY) }; + if (in.fd == -1) + { + ec.assign(errno, std::generic_category()); + return false; + } + int oflag = O_WRONLY|O_CREAT; + if (options.overwrite || options.update) + oflag |= O_TRUNC; + else + oflag |= O_EXCL; + CloseFD out = { posix::open(to, oflag, S_IWUSR) }; + if (out.fd == -1) + { + if (errno == EEXIST && options.skip) + ec.clear(); + else + ec.assign(errno, std::generic_category()); + return false; + } + +#if defined _GLIBCXX_USE_FCHMOD && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS + if (::fchmod(out.fd, from_st->st_mode)) +#elif defined _GLIBCXX_USE_FCHMODAT && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS + if (::fchmodat(AT_FDCWD, to, from_st->st_mode, 0)) +#else + if (posix::chmod(to, from_st->st_mode)) +#endif + { + ec.assign(errno, std::generic_category()); + return false; + } + + size_t count = from_st->st_size; +#if defined _GLIBCXX_USE_SENDFILE && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS + off_t offset = 0; + ssize_t n = ::sendfile(out.fd, in.fd, &offset, count); + if (n < 0 && errno != ENOSYS && errno != EINVAL) + { + ec.assign(errno, std::generic_category()); + return false; + } + if ((size_t)n == count) + { + if (!out.close() || !in.close()) + { + ec.assign(errno, std::generic_category()); + return false; + } + ec.clear(); + return true; + } + else if (n > 0) + count -= n; +#endif // _GLIBCXX_USE_SENDFILE + + using std::ios; + __gnu_cxx::stdio_filebuf sbin(in.fd, ios::in|ios::binary); + __gnu_cxx::stdio_filebuf sbout(out.fd, ios::out|ios::binary); + + if (sbin.is_open()) + in.fd = -1; + if (sbout.is_open()) + out.fd = -1; + +#ifdef _GLIBCXX_USE_SENDFILE + if (n != 0) + { + if (n < 0) + n = 0; + + const auto p1 = sbin.pubseekoff(n, ios::beg, ios::in); + const auto p2 = sbout.pubseekoff(n, ios::beg, ios::out); + + const std::streampos errpos(std::streamoff(-1)); + if (p1 == errpos || p2 == errpos) + { + ec = std::make_error_code(std::errc::io_error); + return false; + } + } +#endif + + if (count && !(std::ostream(&sbout) << &sbin)) + { + ec = std::make_error_code(std::errc::io_error); + return false; + } + if (!sbout.close() || !sbin.close()) + { + ec.assign(errno, std::generic_category()); + return false; + } + ec.clear(); + return true; + } +#endif // NEED_DO_COPY_FILE + +#ifdef NEED_DO_SPACE +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" + void + do_space(const char_type* pathname, + uintmax_t& capacity, uintmax_t& free, uintmax_t& available, + std::error_code& ec) + { +#ifdef _GLIBCXX_HAVE_SYS_STATVFS_H + struct ::statvfs f; + if (::statvfs(pathname, &f)) + ec.assign(errno, std::generic_category()); + else + { + if (f.f_frsize != (unsigned long)-1) + { + const uintmax_t fragment_size = f.f_frsize; + const fsblkcnt_t unknown = -1; + if (f.f_blocks != unknown) + capacity = f.f_blocks * fragment_size; + if (f.f_bfree != unknown) + free = f.f_bfree * fragment_size; + if (f.f_bavail != unknown) + available = f.f_bavail * fragment_size; + } + ec.clear(); + } +#elif _GLIBCXX_FILESYSTEM_IS_WINDOWS + ULARGE_INTEGER bytes_avail = {}, bytes_total = {}, bytes_free = {}; + if (GetDiskFreeSpaceExW(pathname, &bytes_avail, &bytes_total, &bytes_free)) + { + if (bytes_total.QuadPart != 0) + capacity = bytes_total.QuadPart; + if (bytes_free.QuadPart != 0) + free = bytes_free.QuadPart; + if (bytes_avail.QuadPart != 0) + available = bytes_avail.QuadPart; + ec.clear(); + } + else + ec.assign((int)GetLastError(), std::system_category()); +#else + ec = std::make_error_code(std::errc::not_supported); +#endif + } +#pragma GCC diagnostic pop +#endif // NEED_DO_SPACE + #endif // _GLIBCXX_HAVE_SYS_STAT_H _GLIBCXX_END_NAMESPACE_FILESYSTEM diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc index 95bf23b5b52..369604da80f 100644 --- a/libstdc++-v3/src/filesystem/ops.cc +++ b/libstdc++-v3/src/filesystem/ops.cc @@ -24,6 +24,8 @@ #ifndef _GLIBCXX_USE_CXX11_ABI # define _GLIBCXX_USE_CXX11_ABI 1 +# define NEED_DO_COPY_FILE +# define NEED_DO_SPACE #endif #include @@ -243,7 +245,6 @@ namespace using std::filesystem::is_not_found_errno; using std::filesystem::file_time; - using std::filesystem::do_copy_file; #endif // _GLIBCXX_HAVE_SYS_STAT_H } // namespace @@ -1175,7 +1176,7 @@ fs::space(const path& p, error_code& ec) noexcept #else auto str = p.c_str(); #endif - std::filesystem::do_space(str, info.capacity, info.free, info.available, ec); + fs::do_space(str, info.capacity, info.free, info.available, ec); return info; } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/directory_entry/86597.cc b/libstdc++-v3/testsuite/27_io/filesystem/directory_entry/86597.cc index 10202f5be3e..67c70abf4a1 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/directory_entry/86597.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/directory_entry/86597.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/directory_entry/lwg3171.cc b/libstdc++-v3/testsuite/27_io/filesystem/directory_entry/lwg3171.cc index 95158c63ca8..b688d69085e 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/directory_entry/lwg3171.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/directory_entry/lwg3171.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/file_status/1.cc b/libstdc++-v3/testsuite/27_io/filesystem/file_status/1.cc index 030a1d273f3..0bda10d28e2 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/file_status/1.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/file_status/1.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/filesystem_error/cons.cc b/libstdc++-v3/testsuite/27_io/filesystem/filesystem_error/cons.cc index cd40397c346..8b24541cbc6 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/filesystem_error/cons.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/filesystem_error/cons.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/filesystem_error/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/filesystem_error/copy.cc index 71eac38e0d3..926f164f5fa 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/filesystem_error/copy.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/filesystem_error/copy.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc index 71ecd21ab40..ddb424b4be0 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/pop.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/pop.cc index fab7ac0f896..b092dee91e0 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/iterators/pop.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/pop.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc index ca4899d058c..bf67bfd215b 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc index 496f3f8d4fb..45f66ac96c5 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc index 9f511c51a9d..8051a4bfb7a 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc index 2fba1fba2d1..7234e34831f 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy_file.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy_file.cc index 85e97c634d3..dfad8541bfe 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy_file.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy_file.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc index 007c5cd55fc..d248676b82d 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc index e196c57e799..da78fb2de87 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_symlink.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_symlink.cc index 55a103f8936..4236f20f62d 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_symlink.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_symlink.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/current_path.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/current_path.cc index b5a6c638476..c62ada9f111 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/current_path.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/current_path.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/equivalent.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/equivalent.cc index f371cdb0afe..ca1d691bc7c 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/equivalent.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/equivalent.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/exists.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/exists.cc index 330ec542ce8..df8251e55c2 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/exists.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/exists.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/file_size.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/file_size.cc index bb11653cae2..57c9e96e4dc 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/file_size.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/file_size.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/is_empty.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/is_empty.cc index e4e4c3e3bc7..c572a834576 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/is_empty.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/is_empty.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc index 49822e166b1..7a693a1ddcb 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc index 669b04903f1..23d5817acad 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/proximate.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/proximate.cc index 09358250628..8a7e258628a 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/proximate.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/proximate.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc index f04932fcc0f..038c0447a04 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } // { dg-xfail-if "symlinks not supported" { *-*-mingw* } } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/relative.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/relative.cc index c7521d13262..e013faaaf68 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/relative.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/relative.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc index 066bd2bad0e..afe9580fa33 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc index 255a6b1b9ff..2f2802ff859 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/space.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/space.cc index 4070e7bdb92..e545e5e8f70 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/space.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/space.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc index 8a526db7cab..b5ab1b5fd5e 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc index 66125743001..6f01419da3e 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } // { dg-xfail-if "symlinks not supported" { *-*-mingw* } } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/temp_directory_path.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/temp_directory_path.cc index 8f03b9dc324..b3ae66d7d64 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/temp_directory_path.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/temp_directory_path.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc index ef6a8b563ea..e7f1a4ca782 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-options "-std=gnu++17" } // { dg-do run { target c++17 } } // { dg-require-filesystem-ts "" } --OaZoDhBhXzo6bW1J--