From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id A2EAF3858427; Mon, 29 Apr 2024 14:18:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2EAF3858427 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714400332; bh=MJ6sTgxh32OCPV4lXFwNmNDXeG2Vfc2MprygvEfw0N0=; h=From:To:Subject:Date:From; b=qBA77G7zmYtXvRK1/w+04ok2fIzyDKx47Npuv05PtwAtMYaQ7WHpevjctK4BbpsbK lfV8PksPHiYuCS9+qfwtN6szJZYfum2pHegVrw/ZNNjjsxPuyVS0LwByOwgDJaV8y0 xqtCiqdzs2lQKQhHwkD//4oB0J35gTc2f0UNjMts= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-11403] libstdc++, Darwin: Handle a linker warning [PR112397]. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 729170a45040e96d567be79bda00604a7645a23d X-Git-Newrev: 8c19cb9c6186b65f1858c91d423238a00ffe0c01 Message-Id: <20240429141852.A2EAF3858427@sourceware.org> Date: Mon, 29 Apr 2024 14:18:52 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8c19cb9c6186b65f1858c91d423238a00ffe0c01 commit r11-11403-g8c19cb9c6186b65f1858c91d423238a00ffe0c01 Author: Iain Sandoe Date: Thu Feb 8 17:54:31 2024 +0000 libstdc++, Darwin: Handle a linker warning [PR112397]. 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 (cherry picked from commit 1609fdff16f17ead37666f6d0e801800ee3d04d2) Diff: --- libstdc++-v3/configure | 38 +++++++++++++++++++++++++++++--------- libstdc++-v3/configure.ac | 7 +++++++ libstdc++-v3/libsupc++/Makefile.am | 8 ++++++++ libstdc++-v3/libsupc++/Makefile.in | 6 ++++++ 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 8633b8a6dab..316c19a2c95 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -776,6 +776,8 @@ GLIBCXX_HOSTED_TRUE glibcxx_compiler_shared_flag glibcxx_compiler_pic_flag glibcxx_lt_pic_flag +OS_IS_DARWIN_FALSE +OS_IS_DARWIN_TRUE enable_static enable_shared lt_host_flags @@ -12176,7 +12178,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12179 "configure" +#line 12181 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12282,7 +12284,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12285 "configure" +#line 12287 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15564,6 +15566,20 @@ esac +os_is_darwin=no +case ${host_os} in + darwin*) os_is_darwin=yes ;; + *) ;; +esac + if test x${os_is_darwin} = xyes; then + OS_IS_DARWIN_TRUE= + OS_IS_DARWIN_FALSE='#' +else + OS_IS_DARWIN_TRUE='#' + OS_IS_DARWIN_FALSE= +fi + + if test "$enable_vtable_verify" = yes; then predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o" postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o" @@ -15964,7 +15980,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; } # Fake what AC_TRY_COMPILE does. cat > conftest.$ac_ext << EOF -#line 15967 "configure" +#line 15983 "configure" int main() { typedef bool atomic_type; @@ -15999,7 +16015,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16002 "configure" +#line 16018 "configure" int main() { typedef short atomic_type; @@ -16034,7 +16050,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16037 "configure" +#line 16053 "configure" int main() { // NB: _Atomic_word not necessarily int. @@ -16070,7 +16086,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16073 "configure" +#line 16089 "configure" int main() { typedef long long atomic_type; @@ -16223,7 +16239,7 @@ $as_echo "mutex" >&6; } # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 16226 "configure" +#line 16242 "configure" int main() { _Decimal32 d1; @@ -16265,7 +16281,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 16268 "configure" +#line 16284 "configure" template struct same { typedef T2 type; }; @@ -16299,7 +16315,7 @@ $as_echo "$enable_int128" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16302 "configure" +#line 16318 "configure" template struct same { typedef T2 type; }; @@ -78444,6 +78460,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${OS_IS_DARWIN_TRUE}" && test -z "${OS_IS_DARWIN_FALSE}"; then + as_fn_error $? "conditional \"OS_IS_DARWIN\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${GLIBCXX_HOSTED_TRUE}" && test -z "${GLIBCXX_HOSTED_FALSE}"; then as_fn_error $? "conditional \"GLIBCXX_HOSTED\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index 4d16b094d7f..6c823efe910 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -98,6 +98,13 @@ ACX_LT_HOST_FLAGS AC_SUBST(enable_shared) AC_SUBST(enable_static) +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" postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o" diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am index 10ac4bb0124..c857702abfa 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 diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in index 5776a56282b..b5fd8eaa83b 100644 --- a/libstdc++-v3/libsupc++/Makefile.in +++ b/libstdc++-v3/libsupc++/Makefile.in @@ -965,6 +965,12 @@ cp-demangle.o: cp-demangle.c atomicity.cc: ${atomicity_file} $(LN_S) ${atomicity_file} ./atomicity.cc || true +# See PR 112397 +@OS_IS_DARWIN_TRUE@new_opvnt.lo: new_opvnt.cc +@OS_IS_DARWIN_TRUE@ $(LTCXXCOMPILE) -fno-reorder-blocks-and-partition -I. -c $< +@OS_IS_DARWIN_TRUE@new_opvnt.o: new_opvnt.cc +@OS_IS_DARWIN_TRUE@ $(CXXCOMPILE) -fno-reorder-blocks-and-partition -I. -c $< + install-stdHEADERS: $(std_HEADERS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(stddir)