From patchwork Fri Sep 1 11:16:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 137381 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c792:0:b0:3f2:4152:657d with SMTP id b18csp814050vqu; Fri, 1 Sep 2023 04:19:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEG/UyHkAU8DaA8Rzt0eFDRFziPYZnX88LAjh+JI9hVptt9UxWE8/yv2apBrVLeLYp2QTIP X-Received: by 2002:a05:6512:3192:b0:4f9:586b:dba1 with SMTP id i18-20020a056512319200b004f9586bdba1mr1629362lfe.4.1693567158989; Fri, 01 Sep 2023 04:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693567158; cv=none; d=google.com; s=arc-20160816; b=VuxuxgmeZJVty5hLsDX2aASmb1AzBnbMl57EL8phD4VgZ/Aov7aSykNdH2Q+icPBr+ 7/WfIWYIscEvTxGodD77q1qTKb61pDINpbZaKlf/D2AqWv2jpY27rmOK/rDOIO3Ay4eJ PKBLzbJNCQDURjnjRd3VEw+wnt9iPL7ssI9am9cHUPuKYJRaL3G92l4NHhAX/fcFxeFQ ZaUKiM+SbMAMRVMUWNF3W9WL1JCbmbJ8ZDbSlgC/g4/LtWVGyFa32XXcrCTb4CkbT2ks VPah0L9q26CkSTLCdQ/EUApM1rM3yF5IKZRs+76rcf31IC5fxsPS3UksvSxH1IyREatF ogsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=hdvrgu8L/3YN/tDjJS90rzqJaNAvOqRZgTj/Q61JlzY=; fh=sJ+2/4g29YdyXkoRrFZSpsL2zxijepB7X/1rB0LDDh8=; b=vGMuSEpTdyEX3Bmh+u3T/YolAPg00jouqBQdn9PIBXJtumPS2qi8pq6e1eV1UmcAzy ELMcDCt0Ev+CycMtCbPJiH40OzknwuER1YzV2SZPlBXFNlgCT7gTT5WTnpg9MPvUq+gN Bfr4kXeKvIObLxa9gaoLlA6Jo/Fxoixsc0dJQIyMHBw8tajfDOrmfQetuWcUKzzsKphP aDeZCylSX9cQAde2fspCJda1qLZc7plzaGMIYq7zOxtCYXaI//0J4mcjv0BeaZgYU0xG 3sy96StuW16mspmjbjGq/xPoRMfpJz2am2Vu9zcaKwNOuJhvp5fprJQuDiTBVkTFrt3Y Dmuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HiamF5QR; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id k4-20020a05640212c400b0052a2322934asi2482589edx.253.2023.09.01.04.19.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 04:19:18 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HiamF5QR; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC99938768A2 for ; Fri, 1 Sep 2023 11:18:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC99938768A2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693567085; bh=hdvrgu8L/3YN/tDjJS90rzqJaNAvOqRZgTj/Q61JlzY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=HiamF5QR21qVpKv3iFtBgJ8r/m8tgr6ZDjjWjumvOzwAktNSE0BhJItZfXpGLGZBk EtZtr9+qmUGc6Ec85fxYze+d5Z+s+3yC8hYptrjAg+YElU8wcu3XysS+WK06ak8f6H q+RnVlzKNln+VqctsMZZMYJoKwXZL7Ilerok7QPw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 445CB3857352 for ; Fri, 1 Sep 2023 11:17:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 445CB3857352 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-136-V5d1JgPpNdig9WZw1y8XTQ-1; Fri, 01 Sep 2023 07:17:14 -0400 X-MC-Unique: V5d1JgPpNdig9WZw1y8XTQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5BFC6927C47; Fri, 1 Sep 2023 11:17:14 +0000 (UTC) Received: from localhost (unknown [10.42.28.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20AEC404754A; Fri, 1 Sep 2023 11:17:14 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Avoid useless dependency on read_symlink from tzdb Date: Fri, 1 Sep 2023 12:16:53 +0100 Message-ID: <20230901111713.229441-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775833877425286155 X-GMAIL-MSGID: 1775833877425286155 Tested x86_64-linux. Pushed to trunk. -- >8 -- 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. --- 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 0fcbf6a4824..d22cea7e070 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