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: 85943 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27A103861815 for ; Sun, 18 Feb 2024 16:16:17 +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-Google-Smtp-Source: AGHT+IGYn+as8pPt8lfAwJ5z0N1Tw9iAQdsQl9m7CcHFWMeaxb2zwLJK0C7mqmcY+tzTDWprPG7c4g== 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+patchwork=sourceware.org@gcc.gnu.org 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