From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id E9A24386186F; Mon, 19 Feb 2024 08:58:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E9A24386186F 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 E9A24386186F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::634 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708333115; cv=none; b=Ibmzrvej+K04iUHtr/PqAeObDykyBfmMeFhBtvaKAxXdVpsCiG8Nkbpb4H54WaZ5WMfG1JU1btoiPEqYwIHb+Rvckte8f1Bd3/TQ8X4T8PgFhyNGGBtRcFjV3qDzYa+AFToKdN6ESHpeyuolW92ffnGAxzCT6s2Dz9F/VJgEQrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708333115; c=relaxed/simple; bh=qrlTEoo1lnsH36jdY5SeAJ7NaAXihKkXIInm6SZxQW4=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=dX4MEPMDjD2y4tK7Zbrd2Bc5X+/Ffk3V0IEZOvXANjqFVr2nVWh9WBgml7GZSQCAYCx3RI/2o/jh3CSwdc8V7zmJcGm35zKRdQkQyM2vJsU9rkL+7r2iXqy31vt2eO3LWO8C0GSujOxgYswUJZS/dUdJ/b7TNmrWMzJ5qhalxrA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a3d5e77cfbeso690033166b.0; Mon, 19 Feb 2024 00:58:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708333110; x=1708937910; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=m345W1NdCelL34TQ9i5UjxaeWCvx3Rgub7xk3zIm4ms=; b=Oo6vu/XBHImgy3HwezN1hZCIY8t9yQIEfYkoE1Yw5pGIh8uz+HP7wD9uU+MfU5uFA/ PVhWAfFpnsm81AOr4YMfCJpjol7clnKHtPgqGXetGNP0igYUb2Yaus5EaZw2mUGGMYMf ADrqlSEb74VP+6iiKw7zwiN1bOXhyUcpg61ie3wny7qJlQPyUd8J79/EVaAsEZJCXY9c MR/H0/JRVWmIyXxv2EvVQ/wZZMK/UYnMxrkmLChJYsnEvPDnSRqFJkQc0Mk9DSVNflEa Kp8FdZKHTZTrITcVifK+RbAjwRE2kBaVZa7+4yS2tlcKVnJ/IkgQUIOte5Ct0gKAiRpZ ERcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708333110; x=1708937910; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=m345W1NdCelL34TQ9i5UjxaeWCvx3Rgub7xk3zIm4ms=; b=vXpeKBQALllhiRfLXiUEiLc8fnARerSZefW9M/Iz1GJk+J20Qvgp5Cy8fdNP3F70w7 hWfr9BdTB/88cQqxyDtxoR8F/D5xOl7Od3ADQ3hlms9N7eXGBXh170NahtKglvk3iSnY jhKvl9ng8SDVnTY8Ve4nCTqn/G2fylYSv2vPRuql9IbRb83Z6EA43aOZBA/HwLobcXEM 1eTNxCt80g8c0udLnSjfTQiNFJ8LlrAprzMexr28x43ZWeKRS2UBcY2ke0cfuZAAAZUC z6Hq6oLtHLnlKzKcsbiYQzPZcJIAUgqvilakb0m3mkj71wnOHUFH+QpwKzljvc97/0JL oGFw== X-Forwarded-Encrypted: i=1; AJvYcCU3ujeKRvav71vZqhVgVOmFQVo5V81fYCI2qdsuPVSy0zD1hRSZlm4S7dIzf1w+A0QP1RW+BMGQE1lL8l2/qT06ThPq31c+GA== X-Gm-Message-State: AOJu0Yyz3U2D7MTqnLQIXg/JXG/vuJ2iyw6f5/aepkP8KUH5Xdh/ca3g TSLMgw4iIYUqzuNLUbG6TV5K13zJc+h9QlP8sQP8tgutB4lWE5qHldtj5hp0woJ9l0wo6x/QeQt QJ6+w7VVdelVudVctJOc/IXjWe8c= X-Google-Smtp-Source: AGHT+IHwhIF61OCOnlpuzQpfLAPUJPj9FGBrJAlnegIqely67LMP/QKnWmXJQ1IDxDFJ43tPVsQXKPcZDZKcj/Y260s= X-Received: by 2002:a17:906:b84f:b0:a3e:961e:722c with SMTP id ga15-20020a170906b84f00b00a3e961e722cmr1663587ejb.1.1708333110389; Mon, 19 Feb 2024 00:58:30 -0800 (PST) MIME-Version: 1.0 References: <20240218161514.4207-1-iain@sandoe.co.uk> In-Reply-To: <20240218161514.4207-1-iain@sandoe.co.uk> From: Jonathan Wakely Date: Mon, 19 Feb 2024 08:57:56 +0000 Message-ID: Subject: Re: [PATCH] libstdc++, Darwin: Handle a linker warning [PR112397]. To: Iain Sandoe Cc: "libstdc++" , gcc-patches , Jonathan Wakely Content-Type: multipart/alternative; boundary="00000000000033f87e0611b84c51" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,HTML_MESSAGE,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 List-Id: --00000000000033f87e0611b84c51 Content-Type: text/plain; charset="UTF-8" On Sun, 18 Feb 2024, 16:15 Iain Sandoe, wrote: > Tested on i686-darwin9, x86_64-darwin14,17,19,21,23, x86_64-linux, > aarch64-linux-gnu, > > OK for trunk? > eventual back-ports? > Yup, ok for all. 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 > -- > 2.39.2 (Apple Git-143) > > --00000000000033f87e0611b84c51--