public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Olivier Hainque <hainque@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-3215] Tigthen the addition of -lgcc_eh to vxworks_libgcc_spec
Date: Tue, 11 Oct 2022 07:28:30 +0000 (GMT)	[thread overview]
Message-ID: <20221011072830.226833858C2D@sourceware.org> (raw)

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

                 reply	other threads:[~2022-10-11  7:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221011072830.226833858C2D@sourceware.org \
    --to=hainque@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).