From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1298) id 48CD83858012; Mon, 13 Dec 2021 18:04:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 48CD83858012 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Olivier Hainque To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5942] Rework VXWORKS_LINK_SPEC for shared objects support X-Act-Checkin: gcc X-Git-Author: Douglas B Rupp X-Git-Refname: refs/heads/master X-Git-Oldrev: 04577ac0843d7a4961d992e678db3e4a85275825 X-Git-Newrev: fc4a93eb41243babe3f2ef3a3c6171b48e503138 Message-Id: <20211213180414.48CD83858012@sourceware.org> Date: Mon, 13 Dec 2021 18:04:14 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Dec 2021 18:04:14 -0000 https://gcc.gnu.org/g:fc4a93eb41243babe3f2ef3a3c6171b48e503138 commit r12-5942-gfc4a93eb41243babe3f2ef3a3c6171b48e503138 Author: Douglas B Rupp 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 Olivier Hainque 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)