public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-3616] libstdc++: Avoid useless dependency on read_symlink from tzdb Date: Fri, 1 Sep 2023 11:16:52 +0000 (GMT) [thread overview] Message-ID: <20230901111652.D71303858D37@sourceware.org> (raw) https://gcc.gnu.org/g:f2eb6132c6951edf7960a82828c571a1b98a1a09 commit r14-3616-gf2eb6132c6951edf7960a82828c571a1b98a1a09 Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Aug 31 18:31:32 2023 +0100 libstdc++: Avoid useless dependency on read_symlink from tzdb chrono::tzdb::current_zone uses filesystem::read_symlink, which creates a dependency on the fs_ops.o object in libstdc++.a, which then creates dependencies on several OS functions if --gc-sections isn't used. For more details see PR libstdc++/104167 comment 8 and comment 11. In the cases where that causes linker failures, we probably don't have readlink anyway, so the filesystem::read_symlink call will always fail. Repeat the preprocessor conditions for filesystem::read_symlink in the body of chrono::tzdb::current_zone so that we don't create a dependency on fs_ops.o for a function that will always fail. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (tzdb::current_zone): Check configure macros for POSIX readlink before using filesystem::read_symlink. Diff: --- libstdc++-v3/src/c++20/tzdb.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index 0fcbf6a4824e..d22cea7e0709 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -1635,6 +1635,9 @@ namespace std::chrono // TODO cache this function's result? #ifndef _AIX + // Repeat the preprocessor condition used by filesystem::read_symlink, + // to avoid a dependency on src/c++17/fs_ops.o if it won't work anyway. +#if defined(_GLIBCXX_HAVE_READLINK) && defined(_GLIBCXX_HAVE_SYS_STAT_H) error_code ec; // This should be a symlink to e.g. /usr/share/zoneinfo/Europe/London auto path = filesystem::read_symlink("/etc/localtime", ec); @@ -1653,6 +1656,7 @@ namespace std::chrono return tz; } } +#endif // Otherwise, look for a file naming the time zone. string_view files[] { "/etc/timezone", // Debian derivates
reply other threads:[~2023-09-01 11:16 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230901111652.D71303858D37@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).