public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5942] Rework VXWORKS_LINK_SPEC for shared objects support
@ 2021-12-13 18:04 Olivier Hainque
  0 siblings, 0 replies; only message in thread
From: Olivier Hainque @ 2021-12-13 18:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fc4a93eb41243babe3f2ef3a3c6171b48e503138

commit r12-5942-gfc4a93eb41243babe3f2ef3a3c6171b48e503138
Author: Douglas B Rupp <rupp@adacore.com>
Date:   Thu Apr 8 11:03:19 2021 -0700

    Rework VXWORKS_LINK_SPEC for shared objects support
    
    Split LINK_SPEC as BASE_LINK_SPEC + EXTRA_LINK_SPEC,
    with an overridable LINK_OS component that cpu ports may
    redefine.
    
    Leverage the latter on powerpc for VxWorks 7, where we incorporate
    our specific bits in the linux os configuration as the system compiler
    is now very close to a standard linux one.
    
    The split allows supporting shared objects (shared libs and
    non-static rtps) on recent versions of VxWorks while retaining
    compatibility with older VxWorks targets which could link with
    shared libraries but not build them.
    
    2021-12-07  Doug Rupp  <rupp@adacore.com>
                Olivier Hainque  <hainque@adacore.com>
    
    gcc/
            * config/vxworks.h (VXWORKS_LINK_OS_SPEC): New spec.
            (VXWORKS_BASE_LINK_SPEC): New spec, using the former.
            (VXWORKS_EXTRA_LINK_SPEC): New spec for old and new VxWorks.
            (VXWORKS_LINK_SPEC): Combo of BASE and EXTRA specs.
            * config/rs6000/vxworks.h (VXWORKS_LINK_OS_SPEC): Empty.
            (LINK_OS_EXTRA_SPEC32): Use VXWORKS_LINK_SPEC.
            (LINK_OS_EXTRA_SPEC64): Likewise.

Diff:
---
 gcc/config/rs6000/vxworks.h | 13 ++++++++-----
 gcc/config/vxworks.h        | 35 +++++++++++++++++++++++------------
 2 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/gcc/config/rs6000/vxworks.h b/gcc/config/rs6000/vxworks.h
index fbe09027163..d2d65855656 100644
--- a/gcc/config/rs6000/vxworks.h
+++ b/gcc/config/rs6000/vxworks.h
@@ -252,15 +252,18 @@ along with GCC; see the file COPYING3.  If not see
 #undef DOT_SYMBOLS
 #define DOT_SYMBOLS 0
 
-#undef LINK_OS_VXWORKS_SPEC
-#define LINK_OS_VXWORKS_SPEC \
-  " %{!mrtp:-r} %{mrtp:-q -static} %{!Xbind-lazy:-z now}"
+/* For link specs, we leverage the linux configuration bits through
+   LINK_OS_EXTRA_SPEC32/64 and need to cancel the default %(link_os)
+   expansion in VXWORKS_LINK_SPEC.  */
+
+#undef VXWORKS_LINK_OS_SPEC
+#define VXWORKS_LINK_OS_SPEC ""
 
 #undef LINK_OS_EXTRA_SPEC32
-#define LINK_OS_EXTRA_SPEC32 LINK_OS_VXWORKS_SPEC " " VXWORKS_RELAX_LINK_SPEC
+#define LINK_OS_EXTRA_SPEC32 VXWORKS_LINK_SPEC " " VXWORKS_RELAX_LINK_SPEC
 
 #undef LINK_OS_EXTRA_SPEC64
-#define LINK_OS_EXTRA_SPEC64 LINK_OS_VXWORKS_SPEC
+#define LINK_OS_EXTRA_SPEC64 VXWORKS_LINK_SPEC
 
 /* linux64.h enables this, not supported in vxWorks.  */
 #undef TARGET_FLOAT128_ENABLE_TYPE
diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h
index 52d6aa1ae96..88bffc4522b 100644
--- a/gcc/config/vxworks.h
+++ b/gcc/config/vxworks.h
@@ -132,8 +132,7 @@ along with GCC; see the file COPYING3.  If not see
 #define VXWORKS_NET_LIBS_RTP "-lnet -ldsi"
 #endif
 
-#define VXWORKS_BASE_LIBS_RTP \
-  "-lc -lgcc %{!shared:%{!non-static:-lc_internal}}"
+#define VXWORKS_BASE_LIBS_RTP "-lc -lgcc %{!shared:-lc_internal}"
 
 #define VXWORKS_EXTRA_LIBS_RTP
 
@@ -179,15 +178,23 @@ along with GCC; see the file COPYING3.  If not see
 		  " TLS_SYM "                                              \
 		  --start-group " VXWORKS_LIBS_RTP " --end-group}}"
 
-/* The no-op spec for "-shared" below is present because otherwise GCC
-   will treat it as an unrecognized option.  */
-#undef VXWORKS_LINK_SPEC
-#define VXWORKS_LINK_SPEC				\
+#if TARGET_VXWORKS7
+#define VXWORKS_EXTRA_LINK_SPEC ""
+#else
+/* Older VxWorks RTPs can only link with shared libs, and
+   need special switches --force-dynamic --export-dynamic. */
+#define VXWORKS_EXTRA_LINK_SPEC				\
+"%{mrtp:%{!shared:%{non-static:--force-dynamic --export-dynamic}}}"
+#endif
+
+/* A default link_os expansion for RTPs, that cpu ports may override.  */
+#undef VXWORKS_LINK_OS_SPEC
+#define VXWORKS_LINK_OS_SPEC "%(link_os)"
+
+/* The -B and -X switches are for DIAB based linking. */
+#undef VXWORKS_BASE_LINK_SPEC
+#define VXWORKS_BASE_LINK_SPEC				\
 "%{!mrtp:-r}						\
- %{!shared:						\
-   %{mrtp:-q %{h*}					\
-          %{R*} %{!T*: %(link_start) }			\
-          %(link_os)}}					\
  %{v:-V}						\
  %{shared:-shared}					\
  %{Bstatic:-Bstatic}					\
@@ -195,8 +202,12 @@ along with GCC; see the file COPYING3.  If not see
  %{!Xbind-lazy:-z now}					\
  %{Xbind-now:%{Xbind-lazy:				\
    %e-Xbind-now and -Xbind-lazy are incompatible}}	\
- %{mrtp:%{!shared:%{!non-static:-static}		\
- 		  %{non-static:--force-dynamic --export-dynamic}}}"
+ %{mrtp:-q %{!shared:%{!non-static:-static}}            \
+        %{h*} %{R*} %{!T*: %(link_start)}"              \
+        VXWORKS_LINK_OS_SPEC "}"
+
+#undef VXWORKS_LINK_SPEC
+#define VXWORKS_LINK_SPEC VXWORKS_BASE_LINK_SPEC " " VXWORKS_EXTRA_LINK_SPEC
 
 #undef VXWORKS_LIBGCC_SPEC
 #if defined(ENABLE_SHARED_LIBGCC)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-13 18:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-13 18:04 [gcc r12-5942] Rework VXWORKS_LINK_SPEC for shared objects support Olivier Hainque

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).