[gcc r13-3215] Tigthen the addition of -lgcc_eh to vxworks_libgcc_spec

Olivier Hainque hainque@gcc.gnu.org
Tue Oct 11 07:28:30 GMT 2022


https://gcc.gnu.org/g:46325c16324b06fa1b3ea7f8cb05f2109ed66cf6

commit r13-3215-g46325c16324b06fa1b3ea7f8cb05f2109ed66cf6
Author: Olivier Hainque <hainque@adacore.com>
Date:   Fri Feb 18 22:44:53 2022 +0000

    Tigthen the addition of -lgcc_eh to vxworks_libgcc_spec
    
    This change refines VXWORKS_LIBGCC_SPEC wrt the inclusion
    of -lgcc_eh.
    
    Unless the compiler features support for dual sjlj and
    table based eh, libgcc_eh.a is available only with multilib
    variants for which we build a shared lib (mrtp on VxWorks).
    
    Rework logic to handle absence of libgcc_s
    for -mrtp -mcmodel=large, using a conditional expr kind of
    spec.
    
    The gthread support in libgcc_eh might resort to libgcc
    functions on some targets, e.g. cas synchronisation routines
    on aarch64. Arrange to append -lgcc also after -lgcc_eh
    in VXWORKS_LIBGCC_SPEC.
    
    2022-10-09  Olivier Hainque  <hainque@adacore.com>
    
    gcc/
            * config/vxworks.h (VX_LGCC_EH_SO0, VX_LGCC_EH_SO1): New
            internal macros.
            (VXWORKS_LIBGCC_SPEC): Use them and document.

Diff:
---
 gcc/config/vxworks.h | 48 ++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 44 insertions(+), 4 deletions(-)

diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h
index 075a45109e8..e7e5ffe9999 100644
--- a/gcc/config/vxworks.h
+++ b/gcc/config/vxworks.h
@@ -224,14 +224,54 @@ extern void vxworks_driver_init (unsigned int *, struct cl_decoded_option **);
 #undef VXWORKS_LINK_SPEC
 #define VXWORKS_LINK_SPEC VXWORKS_BASE_LINK_SPEC " " VXWORKS_EXTRA_LINK_SPEC
 
+/* Control how to include libgcc in the link closure, handling both "shared"
+   and "non-static" in addition to "static-libgcc" when shared lib support is
+   enabled.  */
+
 #undef VXWORKS_LIBGCC_SPEC
+
+/* libgcc_eh control; libgcc_eh.a is available either together with libgcc_s
+   (mrtp and mcmodel!=large when configured with --enable-shared) or when the
+   compiler is specially setup to support dual sjlj/table-based eh.  */
+
+/* VX_LGCC_EH_SO1: The "-lgcc_eh" part we need in situations where we know a
+   shared libgcc is available (ENABLE_SHARED_LIBGCC + mrtp multilib).  */
+
+#define VX_LGCC_EH_SO1 " -lgcc_eh -lgcc"
+/* Extra -lgcc to handle functions from libgcc_eh that refer to symbols
+   exposed by libgcc and not guaranteed to be dragged in before -lgcc_eh
+   appears.  */
+
+/* VX_LGCC_EH_SO0: The "-lgcc_eh" part we need in situations where we know a
+   shared libgcc is not available (!ENABLE_SHARED_LIBGCC or !mrtp multlib).  */
+
+#if !defined(CONFIG_DUAL_EXCEPTIONS)
+
+/* No shared lib && !DUAL_EH -> no libgcc_eh available at all.  */
+#define VX_LGCC_EH_SO0
+
+#else /* CONFIG_DUAL_EXCEPTIONS  */
+
+/* No shared lib but DUAL_EH -> libgcc_eh around and spec handled by the driver
+   depending on ENABLE_SHARED_LIBGCC.  If defined, the driver expects a regular
+   sequence.  Otherwise, the driver is expected to turn -lgcc into -lgcc_eh on
+   its own and just add an instance to address possible cross refs.  */
+
+#if defined(ENABLE_SHARED_LIBGCC)
+#define VX_LGCC_EH_SO0 " -lgcc_eh -lgcc"
+#else
+#define VX_LGCC_EH_SO0 " -lgcc"
+#endif
+
+#endif /* CONFIG_DUAL_EXCEPTIONS  */
+
 #if defined(ENABLE_SHARED_LIBGCC)
 #define VXWORKS_LIBGCC_SPEC                                             \
-"%{!mrtp:-lgcc -lgcc_eh}                                                \
- %{mrtp:%{!static-libgcc:%{shared|non-static:-lgcc_s;:-lgcc -lgcc_eh}}  \
-         %{static-libgcc:-lgcc -lgcc_eh}}"
+  "%{!mrtp|mcmodel=large:-lgcc" VX_LGCC_EH_SO0 ";"			\
+  " :%{!static-libgcc:%{shared|non-static:-lgcc_s;:-lgcc" VX_LGCC_EH_SO1 "}} \
+     %{static-libgcc:-lgcc" VX_LGCC_EH_SO1 "}}"
 #else
-#define VXWORKS_LIBGCC_SPEC "-lgcc"
+#define VXWORKS_LIBGCC_SPEC "-lgcc" VX_LGCC_EH_SO0
 #endif
 
 /* Setup the crtstuff begin/end we might need for dwarf EH registration


More information about the Gcc-cvs mailing list