From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 01FBB397B804; Thu, 22 Jul 2021 17:05:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01FBB397B804 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-9997] libstdc++: Move atomic functions to libsupc++ [PR 96657] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 3a415b6a93765f29bffd0582a001bf03c4b93f3c X-Git-Newrev: f2074277aa3ce0848429e34d6149ba26ff3b708e Message-Id: <20210722170513.01FBB397B804@sourceware.org> Date: Thu, 22 Jul 2021 17:05:12 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2021 17:05:13 -0000 https://gcc.gnu.org/g:f2074277aa3ce0848429e34d6149ba26ff3b708e commit r10-9997-gf2074277aa3ce0848429e34d6149ba26ff3b708e Author: Jonathan Wakely Date: Wed Apr 14 20:48:54 2021 +0100 libstdc++: Move atomic functions to libsupc++ [PR 96657] The changes for PR libstdc++/64735 mean that libsupc++ function might now depend on the __exchange_and_add and __atomic_add functions defined in config/cpu/*/atomicity.h which is not compiled into libsupc++. This causes a link failure for some targets when trying to use libsupc++ without the rest of libstdc++. This patch simply moves the definitions of those functions into libsupc++ so that they are available there. libstdc++-v3/ChangeLog: PR libstdc++/96657 * libsupc++/Makefile.am: Add atomicity.cc here. * src/c++98/Makefile.am: Remove it from here. * libsupc++/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * testsuite/18_support/exception_ptr/96657.cc: New test. (cherry picked from commit 6c0c7fc6236470a533675cd3cd1ebb1cc3dd112c) Diff: --- libstdc++-v3/libsupc++/Makefile.am | 4 ++++ libstdc++-v3/libsupc++/Makefile.in | 18 +++++++++++------- libstdc++-v3/src/c++98/Makefile.am | 5 ----- libstdc++-v3/src/c++98/Makefile.in | 10 +++------- .../testsuite/18_support/exception_ptr/96657.cc | 17 +++++++++++++++++ 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am index 35ad3ae7799..b6b2516b284 100644 --- a/libstdc++-v3/libsupc++/Makefile.am +++ b/libstdc++-v3/libsupc++/Makefile.am @@ -48,6 +48,7 @@ sources = \ array_type_info.cc \ atexit_arm.cc \ atexit_thread.cc \ + atomicity.cc \ bad_alloc.cc \ bad_array_length.cc \ bad_array_new.cc \ @@ -127,6 +128,9 @@ cp-demangle.lo: cp-demangle.c cp-demangle.o: cp-demangle.c $(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $< +atomicity_file = ${glibcxx_srcdir}/$(ATOMICITY_SRCDIR)/atomicity.h +atomicity.cc: ${atomicity_file} + $(LN_S) ${atomicity_file} ./atomicity.cc || true # Use special rules for the C++17 sources so that the proper flags are passed. new_opa.lo: new_opa.cc diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in index a0a500eabe5..f4f4f3c2862 100644 --- a/libstdc++-v3/libsupc++/Makefile.in +++ b/libstdc++-v3/libsupc++/Makefile.in @@ -153,13 +153,13 @@ am__installdirs = "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(bitsdir)" \ LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_LTLIBRARIES) libsupc___la_LIBADD = am__objects_1 = array_type_info.lo atexit_arm.lo atexit_thread.lo \ - bad_alloc.lo bad_array_length.lo bad_array_new.lo bad_cast.lo \ - bad_typeid.lo class_type_info.lo del_op.lo del_ops.lo \ - del_opnt.lo del_opv.lo del_opvs.lo del_opvnt.lo dyncast.lo \ - eh_alloc.lo eh_arm.lo eh_aux_runtime.lo eh_call.lo eh_catch.lo \ - eh_exception.lo eh_globals.lo eh_personality.lo eh_ptr.lo \ - eh_term_handler.lo eh_terminate.lo eh_tm.lo eh_throw.lo \ - eh_type.lo eh_unex_handler.lo enum_type_info.lo \ + atomicity.lo bad_alloc.lo bad_array_length.lo bad_array_new.lo \ + bad_cast.lo bad_typeid.lo class_type_info.lo del_op.lo \ + del_ops.lo del_opnt.lo del_opv.lo del_opvs.lo del_opvnt.lo \ + dyncast.lo eh_alloc.lo eh_arm.lo eh_aux_runtime.lo eh_call.lo \ + eh_catch.lo eh_exception.lo eh_globals.lo eh_personality.lo \ + eh_ptr.lo eh_term_handler.lo eh_terminate.lo eh_tm.lo \ + eh_throw.lo eh_type.lo eh_unex_handler.lo enum_type_info.lo \ function_type_info.lo fundamental_type_info.lo guard.lo \ guard_error.lo hash_bytes.lo nested_exception.lo \ new_handler.lo new_op.lo new_opnt.lo new_opv.lo new_opvnt.lo \ @@ -498,6 +498,7 @@ sources = \ array_type_info.cc \ atexit_arm.cc \ atexit_thread.cc \ + atomicity.cc \ bad_alloc.cc \ bad_array_length.cc \ bad_array_new.cc \ @@ -564,6 +565,7 @@ sources = \ libsupc___la_SOURCES = $(sources) $(c_sources) $(vtv_sources) libsupc__convenience_la_SOURCES = $(sources) $(c_sources) $(vtv_sources) +atomicity_file = ${glibcxx_srcdir}/$(ATOMICITY_SRCDIR)/atomicity.h # 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 @@ -955,6 +957,8 @@ cp-demangle.lo: cp-demangle.c $(LTCOMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $< cp-demangle.o: cp-demangle.c $(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $< +atomicity.cc: ${atomicity_file} + $(LN_S) ${atomicity_file} ./atomicity.cc || true # Use special rules for the C++17 sources so that the proper flags are passed. new_opa.lo: new_opa.cc diff --git a/libstdc++-v3/src/c++98/Makefile.am b/libstdc++-v3/src/c++98/Makefile.am index 61916f86dec..51920591135 100644 --- a/libstdc++-v3/src/c++98/Makefile.am +++ b/libstdc++-v3/src/c++98/Makefile.am @@ -39,7 +39,6 @@ endif # particular host. host_sources = \ $(cow_string_host_sources) \ - atomicity.cc \ codecvt_members.cc \ collate_members.cc \ messages_members.cc \ @@ -65,10 +64,6 @@ numeric_members.cc: ${glibcxx_srcdir}/$(CNUMERIC_CC) time_members.cc: ${glibcxx_srcdir}/$(CTIME_CC) $(LN_S) ${glibcxx_srcdir}/$(CTIME_CC) . || true -atomicity_file = ${glibcxx_srcdir}/$(ATOMICITY_SRCDIR)/atomicity.h -atomicity.cc: ${atomicity_file} - $(LN_S) ${atomicity_file} ./atomicity.cc || true - if ENABLE_DUAL_ABI collate_members_cow.cc: ${glibcxx_srcdir}/$(CCOLLATE_CC) $(LN_S) ${glibcxx_srcdir}/$(CCOLLATE_CC) ./$@ || true diff --git a/libstdc++-v3/src/c++98/Makefile.in b/libstdc++-v3/src/c++98/Makefile.in index 6895780a5f7..68e3a95f9a0 100644 --- a/libstdc++-v3/src/c++98/Makefile.in +++ b/libstdc++-v3/src/c++98/Makefile.in @@ -127,9 +127,9 @@ libc__98convenience_la_LIBADD = @ENABLE_DUAL_ABI_TRUE@ messages_members_cow.lo \ @ENABLE_DUAL_ABI_TRUE@ monetary_members_cow.lo \ @ENABLE_DUAL_ABI_TRUE@ numeric_members_cow.lo -am__objects_3 = $(am__objects_2) atomicity.lo codecvt_members.lo \ - collate_members.lo messages_members.lo monetary_members.lo \ - numeric_members.lo time_members.lo +am__objects_3 = $(am__objects_2) codecvt_members.lo collate_members.lo \ + messages_members.lo monetary_members.lo numeric_members.lo \ + time_members.lo @ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_4 = allocator-inst.lo \ @ENABLE_EXTERN_TEMPLATE_TRUE@ concept-inst.lo ext-inst.lo \ @ENABLE_EXTERN_TEMPLATE_TRUE@ misc-inst.lo @@ -443,7 +443,6 @@ headers = # particular host. host_sources = \ $(cow_string_host_sources) \ - atomicity.cc \ codecvt_members.cc \ collate_members.cc \ messages_members.cc \ @@ -451,7 +450,6 @@ host_sources = \ numeric_members.cc \ time_members.cc -atomicity_file = ${glibcxx_srcdir}/$(ATOMICITY_SRCDIR)/atomicity.h # Source files linked in via configuration/make substitution for a # particular host, but with ad hoc naming rules. @@ -842,8 +840,6 @@ numeric_members.cc: ${glibcxx_srcdir}/$(CNUMERIC_CC) time_members.cc: ${glibcxx_srcdir}/$(CTIME_CC) $(LN_S) ${glibcxx_srcdir}/$(CTIME_CC) . || true -atomicity.cc: ${atomicity_file} - $(LN_S) ${atomicity_file} ./atomicity.cc || true @ENABLE_DUAL_ABI_TRUE@collate_members_cow.cc: ${glibcxx_srcdir}/$(CCOLLATE_CC) @ENABLE_DUAL_ABI_TRUE@ $(LN_S) ${glibcxx_srcdir}/$(CCOLLATE_CC) ./$@ || true diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/96657.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/96657.cc new file mode 100644 index 00000000000..61572668385 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/exception_ptr/96657.cc @@ -0,0 +1,17 @@ +// { dg-options "-nodefaultlibs -lsupc++ -lgcc_s -lc" { target sparc*-*-linux-gnu } } +// { dg-do link { target c++11 } } + +#include + +void +test01() +{ + // PR libstdc++/96657 undefined references in libsupc++ + std::make_exception_ptr(1); +} + +int +main() +{ + test01(); +}