aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-08-31 18:31:32 +0100
committerJonathan Wakely <jwakely@redhat.com>2023-09-01 12:13:34 +0100
commitf2eb6132c6951edf7960a82828c571a1b98a1a09 (patch)
tree6c44c7db3d8fbba3ea98a3388b43069b7c6a8df2
parentfcede95472ceb4b63d0c131ed2f98bd79e0e360d (diff)
downloadgcc-f2eb6132c6951edf7960a82828c571a1b98a1a09.zip
gcc-f2eb6132c6951edf7960a82828c571a1b98a1a09.tar.gz
gcc-f2eb6132c6951edf7960a82828c571a1b98a1a09.tar.bz2
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.
-rw-r--r--libstdc++-v3/src/c++20/tzdb.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc
index 0fcbf6a..d22cea7 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