Message ID | 20200212113135.GY17695@tucnak |
---|---|
State | New |
Headers | show |
Series | c++: Emit DFP typeinfos even when DFP is disabled [PR92906] | expand |
On 12/02/20 12:31 +0100, Jakub Jelinek wrote: >Hi! > >Before Joseph's changes when compiling >libstdc++-v3/libsupc++/fundamental_type_info.cc >we were emitting >_ZTIPDd, _ZTIPDe, _ZTIPDf, _ZTIPKDd, _ZTIPKDe, _ZTIPKDf, _ZTIDd, _ZTIDe, _ZTIDf >symbols even when DFP wasn't usable, but now we don't and thus those 9 >symbols @@CXXABI_1.3.4 are gone from libstdc++. While nothing could >probably use it (except perhaps dlsym etc.), various tools don't really like >symbols disappearing from symbol versioned shared libraries with stable ABI. >Adding those in assembly would be possible, but would be a portability >nightmare (the PR has something Red Hat uses in libstdc++_nonshared.a, but that >can handle only a handful of linux ELF targets we care about). >So, instead this patch hacks up the FE, so that it emits those, but in a way >that won't make the DFP types available again on targets that don't support >them. > >Bootstrapped/regtested on x86_64-linux and i686-linux (where it doesn't >change anything, because DFP is supported), aarch64-linux (where it fixed >FAIL: libstdc++-abi/abi_check >) and armv7hl-linux (where abi_check didn't fail because we don't have >baseline file, but comparing abilist of unpatched and patched libstdc++.so.6 >shows: >+_ZTIDd@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 8 >+_ZTIDe@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 8 >+_ZTIDf@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 8 >+_ZTIPDd@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 >+_ZTIPDe@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 >+_ZTIPDf@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 >+_ZTIPKDd@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 >+_ZTIPKDe@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 >+_ZTIPKDf@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 >). Ok for trunk? It seems less hacky than the aliases that would be needed in libstdc++.so to solve it purely in the library.
On 2/12/20 12:31 PM, Jakub Jelinek wrote: > Hi! > > Before Joseph's changes when compiling > libstdc++-v3/libsupc++/fundamental_type_info.cc > we were emitting > _ZTIPDd, _ZTIPDe, _ZTIPDf, _ZTIPKDd, _ZTIPKDe, _ZTIPKDf, _ZTIDd, _ZTIDe, _ZTIDf > symbols even when DFP wasn't usable, but now we don't and thus those 9 > symbols @@CXXABI_1.3.4 are gone from libstdc++. While nothing could > probably use it (except perhaps dlsym etc.), various tools don't really like > symbols disappearing from symbol versioned shared libraries with stable ABI. > Adding those in assembly would be possible, but would be a portability > nightmare (the PR has something Red Hat uses in libstdc++_nonshared.a, but that > can handle only a handful of linux ELF targets we care about). > So, instead this patch hacks up the FE, so that it emits those, but in a way > that won't make the DFP types available again on targets that don't support > them. > > Bootstrapped/regtested on x86_64-linux and i686-linux (where it doesn't > change anything, because DFP is supported), aarch64-linux (where it fixed > FAIL: libstdc++-abi/abi_check > ) and armv7hl-linux (where abi_check didn't fail because we don't have > baseline file, but comparing abilist of unpatched and patched libstdc++.so.6 > shows: > +_ZTIDd@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 8 > +_ZTIDe@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 8 > +_ZTIDf@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 8 > +_ZTIPDd@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 > +_ZTIPDe@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 > +_ZTIPDf@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 > +_ZTIPKDd@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 > +_ZTIPKDe@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 > +_ZTIPKDf@@CXXABI_1.3.4 OBJECT WEAK DEFAULT 16 > ). Ok for trunk? OK. > 2020-02-12 Jakub Jelinek <jakub@redhat.com> > > PR libstdc++/92906 > * cp-tree.h (enum cp_tree_index): Add CPTI_FALLBACK_DFLOAT32_TYPE, > CPTI_FALLBACK_DFLOAT64_TYPE and CPTI_FALLBACK_DFLOAT128_TYPE. > (fallback_dfloat32_type, fallback_dfloat64_type, > fallback_dfloat128_type): Define. > * mangle.c (write_builtin_type): Handle fallback_dfloat*_type like > dfloat*_type_node. > * rtti.c (emit_support_tinfos): Emit DFP typeinfos even when dfp > is disabled for compatibility. > > --- gcc/cp/cp-tree.h.jj 2020-02-10 15:02:05.031846484 +0100 > +++ gcc/cp/cp-tree.h 2020-02-11 23:00:25.561410042 +0100 > @@ -206,6 +206,10 @@ enum cp_tree_index > > CPTI_SOURCE_LOCATION_IMPL, > > + CPTI_FALLBACK_DFLOAT32_TYPE, > + CPTI_FALLBACK_DFLOAT64_TYPE, > + CPTI_FALLBACK_DFLOAT128_TYPE, > + > CPTI_MAX > }; > > @@ -366,6 +370,12 @@ extern GTY(()) tree cp_global_trees[CPTI > > #define access_default_node null_node > > +/* Variant of dfloat{32,64,128}_type_node only used for fundamental > + rtti purposes if DFP is disabled. */ > +#define fallback_dfloat32_type cp_global_trees[CPTI_FALLBACK_DFLOAT32_TYPE] > +#define fallback_dfloat64_type cp_global_trees[CPTI_FALLBACK_DFLOAT64_TYPE] > +#define fallback_dfloat128_type cp_global_trees[CPTI_FALLBACK_DFLOAT128_TYPE] > + > > #include "name-lookup.h" > > --- gcc/cp/mangle.c.jj 2020-01-21 09:13:43.339634944 +0100 > +++ gcc/cp/mangle.c 2020-02-11 22:59:28.466265009 +0100 > @@ -2569,11 +2569,11 @@ write_builtin_type (tree type) > write_char ('d'); > else if (type == long_double_type_node) > write_char ('e'); > - else if (type == dfloat32_type_node) > + else if (type == dfloat32_type_node || type == fallback_dfloat32_type) > write_string ("Df"); > - else if (type == dfloat64_type_node) > + else if (type == dfloat64_type_node || type == fallback_dfloat64_type) > write_string ("Dd"); > - else if (type == dfloat128_type_node) > + else if (type == dfloat128_type_node || type == fallback_dfloat128_type) > write_string ("De"); > else > gcc_unreachable (); > --- gcc/cp/rtti.c.jj 2020-01-21 09:13:43.359634642 +0100 > +++ gcc/cp/rtti.c 2020-02-11 22:59:28.467264994 +0100 > @@ -1588,6 +1588,20 @@ emit_support_tinfos (void) > } > for (tree t = registered_builtin_types; t; t = TREE_CHAIN (t)) > emit_support_tinfo_1 (TREE_VALUE (t)); > + /* For compatibility, emit DFP typeinfos even when DFP isn't enabled, > + because we've emitted that in the past. */ > + if (!targetm.decimal_float_supported_p ()) > + { > + gcc_assert (dfloat32_type_node == NULL_TREE > + && dfloat64_type_node == NULL_TREE > + && dfloat128_type_node == NULL_TREE); > + fallback_dfloat32_type = make_node (REAL_TYPE); > + fallback_dfloat64_type = make_node (REAL_TYPE); > + fallback_dfloat128_type = make_node (REAL_TYPE); > + emit_support_tinfo_1 (fallback_dfloat32_type); > + emit_support_tinfo_1 (fallback_dfloat64_type); > + emit_support_tinfo_1 (fallback_dfloat128_type); > + } > input_location = saved_loc; > } > > > Jakub >
--- gcc/cp/cp-tree.h.jj 2020-02-10 15:02:05.031846484 +0100 +++ gcc/cp/cp-tree.h 2020-02-11 23:00:25.561410042 +0100 @@ -206,6 +206,10 @@ enum cp_tree_index CPTI_SOURCE_LOCATION_IMPL, + CPTI_FALLBACK_DFLOAT32_TYPE, + CPTI_FALLBACK_DFLOAT64_TYPE, + CPTI_FALLBACK_DFLOAT128_TYPE, + CPTI_MAX }; @@ -366,6 +370,12 @@ extern GTY(()) tree cp_global_trees[CPTI #define access_default_node null_node +/* Variant of dfloat{32,64,128}_type_node only used for fundamental + rtti purposes if DFP is disabled. */ +#define fallback_dfloat32_type cp_global_trees[CPTI_FALLBACK_DFLOAT32_TYPE] +#define fallback_dfloat64_type cp_global_trees[CPTI_FALLBACK_DFLOAT64_TYPE] +#define fallback_dfloat128_type cp_global_trees[CPTI_FALLBACK_DFLOAT128_TYPE] + #include "name-lookup.h" --- gcc/cp/mangle.c.jj 2020-01-21 09:13:43.339634944 +0100 +++ gcc/cp/mangle.c 2020-02-11 22:59:28.466265009 +0100 @@ -2569,11 +2569,11 @@ write_builtin_type (tree type) write_char ('d'); else if (type == long_double_type_node) write_char ('e'); - else if (type == dfloat32_type_node) + else if (type == dfloat32_type_node || type == fallback_dfloat32_type) write_string ("Df"); - else if (type == dfloat64_type_node) + else if (type == dfloat64_type_node || type == fallback_dfloat64_type) write_string ("Dd"); - else if (type == dfloat128_type_node) + else if (type == dfloat128_type_node || type == fallback_dfloat128_type) write_string ("De"); else gcc_unreachable (); --- gcc/cp/rtti.c.jj 2020-01-21 09:13:43.359634642 +0100 +++ gcc/cp/rtti.c 2020-02-11 22:59:28.467264994 +0100 @@ -1588,6 +1588,20 @@ emit_support_tinfos (void) } for (tree t = registered_builtin_types; t; t = TREE_CHAIN (t)) emit_support_tinfo_1 (TREE_VALUE (t)); + /* For compatibility, emit DFP typeinfos even when DFP isn't enabled, + because we've emitted that in the past. */ + if (!targetm.decimal_float_supported_p ()) + { + gcc_assert (dfloat32_type_node == NULL_TREE + && dfloat64_type_node == NULL_TREE + && dfloat128_type_node == NULL_TREE); + fallback_dfloat32_type = make_node (REAL_TYPE); + fallback_dfloat64_type = make_node (REAL_TYPE); + fallback_dfloat128_type = make_node (REAL_TYPE); + emit_support_tinfo_1 (fallback_dfloat32_type); + emit_support_tinfo_1 (fallback_dfloat64_type); + emit_support_tinfo_1 (fallback_dfloat128_type); + } input_location = saved_loc; }