From patchwork Sun Feb 18 16:15:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 202809 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp850065dyc; Sun, 18 Feb 2024 08:16:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVZtcA17bQY5nCMetsOAcxa5XbHsMhm+Y3fz1LjgO04bbt4ugTFQ1xUsIc1YvHh5t7TsvHkPnW5YhfAQXGtsf21farfGg== X-Google-Smtp-Source: AGHT+IGI/yvd91wD+59pWRoZtqU/iWslYZZCpo1Qd7jNpX43WF82rctv7XbDMrak5gDL6bMaf+WP X-Received: by 2002:a05:620a:20d8:b0:787:34f6:a706 with SMTP id f24-20020a05620a20d800b0078734f6a706mr10731749qka.28.1708272989507; Sun, 18 Feb 2024 08:16:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708272989; cv=pass; d=google.com; s=arc-20160816; b=kV2mI4twgIILZ+WOg0YCuH8ldlA/hs/dPMdnJ0D0ryXcxyq3LOPexoUtUQico2Wby7 XuGBE8U0hfOJhldZdi2U0WEqEF/bOMdtnTb9m+6zmaLu/2/EkN0TCeCk/+zxYVFiNq7M tR5vLyZB7c6uiLvhsEO6zRPC+UeWxv1cuTNw8+mvC8bp5RrSKztU7rLEIrzL//GVvfnu W2wjxY/QcpwiqvQ64csSVxw3A0dlfvqC9sSkqcgOfmA+Q1cnYVDG9mY7xNaj7p4i1Jsn Sczj5iawyHiiom/cz4dJKzryH4IcYKmoqRvfbnpb/rqnhivrqbJWBIBw6E2+h8XWNmqs YFMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=+qldVGSCFQWrmRGqYqX7zsc3Z53hdTauxvm6PSJnVUU=; fh=Uqp2sd+2Ajb7Morkh41vDIu1NNt5Q4ih+hy6tXDLh8U=; b=FNO5PqmK/3vLlUHVX4c6gjsr0Ljl0v8Q3/KZ4TtCX7+QyGiTaJyeiBUlbrMTC9pdcl WjAfxOdoOhZWAsP5E5w2y1C3rZViQ9ZYZfi/yWJT+Mw9zD8+DYqiqJubDZFkA8k73U3M sFm3JZpoOoKSau7HsnajSgcbDFKZmpZOlS0hgskfv/5Dd91yI+zh1dX9vNhBHFpcaiiV GnVr4aaurq1TINmP+z/svCHxp6cUhCMkW17HPP9tASYmhYg6GSeQTMjnMXheTwVz9Wos H5L+hCtGEbNbZEGWHAYE+7n4eaTrJJMPxkbiAd4REqvIFkS7XzYR6QTbV+7j4ZOnILn5 d3qA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WTUq8GVW; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bp16-20020a05620a459000b007873edd4634si4921687qkb.256.2024.02.18.08.16.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 08:16:29 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WTUq8GVW; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 354F33857011 for ; Sun, 18 Feb 2024 16:16:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 135DC3857011; Sun, 18 Feb 2024 16:15:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 135DC3857011 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 135DC3857011 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708272920; cv=none; b=RjwYJMEah0r31VDGe9IZp+pOa6wrFQ8cP+h3U9RCsumZAR9Gikpzx3JUycNxB9A+9FXfBx4nsjpmPCbGElETUetUUus/1NVUF2RhZwcv4ezJcfQuU7ACVZqH+FYYdNne8cVtMOo1KzlQVoTBt3Lmd4qcW3X0FpIioPFNJFFUp2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708272920; c=relaxed/simple; bh=igM8+6dv9qQEQbjCwGJI0uVOt6EMPFPUmy1IRV9bFRg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ix0aoioA4aoysrd7Z0lPOy3fkudKZgHY3fEfpTVCImL6ys2KsmUnl0nWOvqedYre+Rvs4J7/h+v6qqao/nPUTbIo3upKo7qh7t4sEg1015LtHUh2jbHQhjsUp/NOn7fAi8IMIaOQwpXMm79kmo707/sbq/7g+R6OA9FsDR9MLHw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-41243d19ecaso15171905e9.3; Sun, 18 Feb 2024 08:15:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708272916; x=1708877716; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=+qldVGSCFQWrmRGqYqX7zsc3Z53hdTauxvm6PSJnVUU=; b=WTUq8GVWzKTcpniQyVzbTIj0Cv9E0HBMBQ07j/sy3tYyEe1loZOIVXiI9cEZHFe1Sd iz8w9tRXohknNZPEKPzYGRtEw/XygCFsLY7TSf+lPm1ORbvBj0xqX/qhz37ClzLSwngd gmx3AGhbTnebYtik989i28dK7pkau+Bqr0TjYjY8D7kt7bVQ8AeQcjDjoQekfMCGpBAI Z+9Sf+8BrLxaZKY15atvHHqlTZwyEWFDubCVYhU7svyJFXWmrlGtcvuBz9W/zIboAbQR 8BKBjMc7vC/Z55YPvOZgo3FsjSFRv5ylDP0tIuH+97BZ7CXsExxK3WT0Pz8jSC2ZtK5g jloQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708272916; x=1708877716; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+qldVGSCFQWrmRGqYqX7zsc3Z53hdTauxvm6PSJnVUU=; b=avbdEtEZjXTi4YYKInvPlGd/Wtt7V+tlMHQYbK3ppFwI6aQdz25hqTBwuCeL9CBpLl ylTur+90ejlwHJ/A6/r4g/eFtDduAIhDU6l8eKLtX144MmUlyj2H91lglKP1m7X5QQs8 O4OrLiEDldvieLMrNmD3YwQ9UrwlRD8lMiPD+PMP/6Z1TCur7xWV6Ouqks5sCYtxs2MW DucuKndwY6yBBA8h3gT4SuBRE/YmJ+Yh9h/dCrJvUCwR7SLinIj16ow7JDZPWfRAzPNP XfCJJTyJdntNthCBsCup+ZtI+Yy/KuAsFoB+2WiE6T2hhHe1ddRvN5zGpNYqX64+sc8X /feQ== X-Forwarded-Encrypted: i=1; AJvYcCUhoZaL6eyWlvZCxkrEHTA5yfuvGkvg5IBzLUwf7HYVCDubYy7/YRAHvuU/fykTXIZ368Yc5WL5X2DrNpvOlzIyqAU40fKa/A== X-Gm-Message-State: AOJu0Yw4WOKE0ZHmWq6nKtZOXBZMpiIOo9KU4/NQJkyu4i3kV3lcYRlV HKq2xkn54dqgtKyWVj6p0h/D4St2WdzLJfamZ6KGVssGpfdF7D6IvJWfVpqq X-Received: by 2002:a05:600c:4f0f:b0:410:e830:24 with SMTP id l15-20020a05600c4f0f00b00410e8300024mr8205670wmq.7.1708272916423; Sun, 18 Feb 2024 08:15:16 -0800 (PST) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id t8-20020a7bc3c8000000b0040ef0e26132sm2919790wmj.0.2024.02.18.08.15.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 18 Feb 2024 08:15:16 -0800 (PST) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: jwakely@redhat.com Subject: [PATCH] libstdc++, Darwin: Handle a linker warning [PR112397]. Date: Sun, 18 Feb 2024 16:15:14 +0000 Message-Id: <20240218161514.4207-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Reply-To: iain@sandoe.co.uk Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791254058256625991 X-GMAIL-MSGID: 1791254058256625991 Tested on i686-darwin9, x86_64-darwin14,17,19,21,23, x86_64-linux, aarch64-linux-gnu, OK for trunk? eventual back-ports? thanks Iain --- 8< --- Darwin's linker warns when we make a direct branch to code that is in a weak definition (citing that if a different implementation of the weak function is chosen by the dynamic linker this would be an error). As the analysis in the PR shows, this can happen when we have hot/ cold partitioning and there is an error path that is primarily cold but makes use of epilogue code in the hot section. In this simple case, we can easily deduce that the code is in fact safe; however that is not something we can realistically implement in the linker. Since the user-replaceable allocators are implemented using weak definitions, this is a warning that is frequently flagged up in both the testsuite and end-user code. The chosen solution here is to suppress the hot/cold partitioning for these cases (it is unlikely to impact performance much c.f. the actual allocation). PR target/112397 libstdc++-v3/ChangeLog: * configure: Regenerate. * configure.ac: Detect if we are building for Darwin. * libsupc++/Makefile.am: If we are building for Darwin, then suppress hot/cold partitioning for the array allocators. * libsupc++/Makefile.in: Regenerated. Signed-off-by: Iain Sandoe Co-authored-by: Jonathan Wakely --- libstdc++-v3/configure | 35 +++++++++++++++++++++++------- libstdc++-v3/configure.ac | 6 +++++ libstdc++-v3/libsupc++/Makefile.am | 8 +++++++ libstdc++-v3/libsupc++/Makefile.in | 6 +++++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index c68cac4f345..37396bd6ebb 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -109,6 +109,12 @@ ACX_LT_HOST_FLAGS AC_SUBST(enable_shared) AC_SUBST(enable_static) AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes]) +os_is_darwin=no +case ${host_os} in + darwin*) os_is_darwin=yes ;; + *) ;; +esac +AM_CONDITIONAL([OS_IS_DARWIN], [test x${os_is_darwin} = xyes]) if test "$enable_vtable_verify" = yes; then predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o" diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am index d0e1618507e..e151ce7a1fe 100644 --- a/libstdc++-v3/libsupc++/Makefile.am +++ b/libstdc++-v3/libsupc++/Makefile.am @@ -132,6 +132,14 @@ atomicity_file = ${glibcxx_srcdir}/$(ATOMICITY_SRCDIR)/atomicity.h atomicity.cc: ${atomicity_file} $(LN_S) ${atomicity_file} ./atomicity.cc || true +if OS_IS_DARWIN +# See PR 112397 +new_opvnt.lo: new_opvnt.cc + $(LTCXXCOMPILE) -fno-reorder-blocks-and-partition -I. -c $< +new_opvnt.o: new_opvnt.cc + $(CXXCOMPILE) -fno-reorder-blocks-and-partition -I. -c $< +endif + # AM_CXXFLAGS needs to be in each subdirectory so that it can be # modified in a per-library or per-sub-library way. Need to manually # set this option because CONFIG_CXXFLAGS has to be after