public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* common grounds for VxWorks 7 support
@ 2017-06-26 15:38 Olivier Hainque
  2017-06-26 15:56 ` Nathan Sidwell
  2017-06-26 16:44 ` Jeff Law
  0 siblings, 2 replies; 5+ messages in thread
From: Olivier Hainque @ 2017-06-26 15:38 UTC (permalink / raw)
  To: GCC Patches, Nathan Sidwell
  Cc: Olivier Hainque, Jerome Lambourg, Douglas B Rupp

[-- Attachment #1: Type: text/plain, Size: 1648 bytes --]

Hello,

This patch introduces common grounds for VxWorks 7 support.

The main device is the introduction of a TARGET_VXWORKS7 macro which we
leverage throughout the various vxworks.h / vxworks.c files, common or cpu
specific.

We have done several CPU specific ports already, and this scheme works pretty
well.

There's quite a bit of common material between Vx7 and the previous versions.

For the distinctions we need to make, the use of preprocessing doesn't impair
readability IMO, on the contrary, while the usual alternative with extra target
files rapidly becomes subtle to handle right (getting the proper inclusion
ordering while preventing code duplication is not always easy and may make
maintenance harder or more error-prone).

Nathan does this work for you ?

If OK on principle, I'm not sure who is to approve the tiny config.gcc part.

Thanks in advance for your feedback,

With Kind Regards,

Olivier

2017-06-26  Jerome Lambourg  <lambourg@adacore.com>
            Olivier Hainque  <hainque@adacore.com>

        * config.gcc (tm_defines for VxWorks): Define TARGET_VXWORKS7 for
        all vxworks7 targets.
        * config/vxworks.h (TARGET_VXWORKS7): If not defined, define to 0.
        (VXWORKS_ADDITIONAL_CPP_SPEC): Alternative definition for VXWORKS7.
        (VXWORKS_LIBS_RTP, VXWORKS_LIBS_RTP_DIR): New macros, allowing
        variations for VX6/VX7 and 32/64bits later on in ...
        (VXWORKS_LIB_SPEC): Leverage new macros.
        (VXWORKS_OS_CPP_BUILTINS): Define _VSB_CONFIG_FILE for VXWORKS7,
        as well as _ALLOW_KEYWORD_MACROS when "inline" is not a keyword.


[-- Attachment #2: 0002-common-vxworks7-support.patch --]
[-- Type: application/octet-stream, Size: 4135 bytes --]

diff --git a/gcc/config.gcc b/gcc/config.gcc
index d5609c0..2912009 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -926,6 +926,11 @@ case ${target} in
     "" | yes | vxworks) thread_file='vxworks' ;;
     *) echo 'Unknown thread configuration for VxWorks'; exit 1 ;;
   esac
+  case $target in
+    *-*-vxworks7*)
+      tm_defines="$tm_defines TARGET_VXWORKS7=1"
+      ;;
+  esac
   ;;
 *-*-elf|arc*-*-elf*)
   # Assume that newlib is being used and so __cxa_atexit is provided.
diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h
index d16c84d..11d811c 100644
--- a/gcc/config/vxworks.h
+++ b/gcc/config/vxworks.h
@@ -23,6 +23,11 @@ along with GCC; see the file COPYING3.  If not see
 #undef TARGET_VXWORKS
 #define TARGET_VXWORKS 1
 
+/* If TARGET_VXWORKS7 is undefined, then we're not targeting it.  */
+#ifndef TARGET_VXWORKS7
+#define TARGET_VXWORKS7 0
+#endif
+
 /* In kernel mode, VxWorks provides all the libraries itself, as well as
    the functionality of startup files, etc.  In RTP mode, it behaves more
    like a traditional Unix, with more external files.  Most of our specs
@@ -36,6 +41,23 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Since we provide a default -isystem, expand -isystem on the command
    line early.  */
+#if TARGET_VXWORKS7
+
+#undef VXWORKS_ADDITIONAL_CPP_SPEC
+#define VXWORKS_ADDITIONAL_CPP_SPEC                     \
+ "%{!nostdinc:                                          \
+    %{isystem*}                                         \
+    %{mrtp: -idirafter %:getenv(VSB_DIR /h)             \
+            -idirafter %:getenv(VSB_DIR /share/h)       \
+            -idirafter %:getenv(VSB_DIR /usr/h/public)  \
+            -idirafter %:getenv(VSB_DIR /usr/h)         \
+      ;:    -idirafter %:getenv(VSB_DIR /h)             \
+            -idirafter %:getenv(VSB_DIR /share/h)       \
+            -idirafter %:getenv(VSB_DIR /krnl/h/system) \
+            -idirafter %:getenv(VSB_DIR /krnl/h/public)}}"
+
+#else /* TARGET_VXWORKS7 */
+
 #undef VXWORKS_ADDITIONAL_CPP_SPEC
 #define VXWORKS_ADDITIONAL_CPP_SPEC		\
  "%{!nostdinc:					\
@@ -43,14 +65,30 @@ along with GCC; see the file COPYING3.  If not see
     %{mrtp: %:getenv(WIND_USR /h)		\
       ;:    %:getenv(WIND_BASE /target/h)}}"
 
+#endif
+
 /* The references to __init and __fini will be satisfied by
    libc_internal.a.  */
+
+#define VXWORKS_LIBS_RTP "-lc -lgcc -lc_internal -lnet -ldsi"
+
+/* On Vx6 and previous, the libraries to pick up depends on the architecture,
+   so cannot be defined for all archs at once.  On Vx7, a VSB is always needed
+   and its structure is fixed and does not depend on the arch.  We can thus
+   tell gcc where to look for when linking with RTP libraries.  */
+
+#if TARGET_VXWORKS7
+#define VXWORKS_LIBS_DIR_RTP "-L%:getenv(VSB_DIR /usr/lib/common)"
+#else
+#define VXWORKS_LIBS_DIR_RTP ""
+#endif
+
 #undef VXWORKS_LIB_SPEC
 #define	VXWORKS_LIB_SPEC						\
 "%{mrtp:%{shared:-u " USER_LABEL_PREFIX "__init -u " USER_LABEL_PREFIX "__fini} \
 	%{!shared:%{non-static:-u " USER_LABEL_PREFIX "_STI__6__rtld -ldl} \
-		  --start-group -lc -lgcc -lc_internal -lnet -ldsi	\
-		  --end-group}}"
+		  --start-group " VXWORKS_LIBS_RTP " --end-group} \
+        " VXWORKS_LIBS_DIR_RTP "}"
 
 /* The no-op spec for "-shared" below is present because otherwise GCC
    will treat it as an unrecognized option.  */
@@ -133,6 +171,17 @@ extern void vxworks_asm_out_destructor (rtx symbol, int priority);
 	builtin_define ("_WRS_KERNEL");					\
       builtin_define ("_VX_TOOL_FAMILY=gnu");				\
       builtin_define ("_VX_TOOL=gnu");					\
+      if (TARGET_VXWORKS7)						\
+        {								\
+           builtin_define ("_VSB_CONFIG_FILE=<config/vsbConfig.h>");	\
+           								\
+	   /* _ALLOW_KEYWORD_MACROS is needed on VxWorks 7 to		\
+	      prevent compilation failures triggered by our		\
+	      definition of "inline" in ansidecl when "inline"		\
+	      is not a keyword.  */					\
+	   if (!flag_isoc99 && !c_dialect_cxx())			\
+             builtin_define ("_ALLOW_KEYWORD_MACROS");			\
+        }								\
     }									\
   while (0)
 
-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: common grounds for VxWorks 7 support
  2017-06-26 15:38 common grounds for VxWorks 7 support Olivier Hainque
@ 2017-06-26 15:56 ` Nathan Sidwell
  2017-06-26 16:25   ` Olivier Hainque
  2017-06-26 16:44 ` Jeff Law
  1 sibling, 1 reply; 5+ messages in thread
From: Nathan Sidwell @ 2017-06-26 15:56 UTC (permalink / raw)
  To: Olivier Hainque, GCC Patches; +Cc: Jerome Lambourg, Douglas B Rupp

On 06/26/2017 11:38 AM, Olivier Hainque wrote:

> Nathan does this work for you ?

certainly,

> If OK on principle, I'm not sure who is to approve the tiny config.gcc part.

You :) (it's in a vxworks-specific fragment, I think the Changelog 
format for that kind of thing is:
    * config.gcc (triplet-glob): ...





-- 
Nathan Sidwell

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: common grounds for VxWorks 7 support
  2017-06-26 15:56 ` Nathan Sidwell
@ 2017-06-26 16:25   ` Olivier Hainque
  0 siblings, 0 replies; 5+ messages in thread
From: Olivier Hainque @ 2017-06-26 16:25 UTC (permalink / raw)
  To: Nathan Sidwell
  Cc: Olivier Hainque, GCC Patches, Jerome Lambourg, Douglas B Rupp


> On Jun 26, 2017, at 17:56 , Nathan Sidwell <nathan@acm.org> wrote:
> 
> On 06/26/2017 11:38 AM, Olivier Hainque wrote:
> 
>> Nathan does this work for you ?
> 
> certainly,

Great!

>> If OK on principle, I'm not sure who is to approve the tiny config.gcc part.
> 
> You :) (it's in a vxworks-specific fragment,

Oh, nice :)

> I think the Changelog format for that kind of thing is:
>   * config.gcc (triplet-glob): ...

I see, will adjust.

Thanks for your prompt feedback!

More patches to come :)

Olivier

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: common grounds for VxWorks 7 support
  2017-06-26 15:38 common grounds for VxWorks 7 support Olivier Hainque
  2017-06-26 15:56 ` Nathan Sidwell
@ 2017-06-26 16:44 ` Jeff Law
  2017-06-26 19:17   ` Olivier Hainque
  1 sibling, 1 reply; 5+ messages in thread
From: Jeff Law @ 2017-06-26 16:44 UTC (permalink / raw)
  To: Olivier Hainque, GCC Patches, Nathan Sidwell
  Cc: Jerome Lambourg, Douglas B Rupp

On 06/26/2017 09:38 AM, Olivier Hainque wrote:
> Hello,
> 
> This patch introduces common grounds for VxWorks 7 support.
> 
> The main device is the introduction of a TARGET_VXWORKS7 macro which we
> leverage throughout the various vxworks.h / vxworks.c files, common or cpu
> specific.
> 
> We have done several CPU specific ports already, and this scheme works pretty
> well.
> 
> There's quite a bit of common material between Vx7 and the previous versions.
> 
> For the distinctions we need to make, the use of preprocessing doesn't impair
> readability IMO, on the contrary, while the usual alternative with extra target
> files rapidly becomes subtle to handle right (getting the proper inclusion
> ordering while preventing code duplication is not always easy and may make
> maintenance harder or more error-prone).
> 
> Nathan does this work for you ?
> 
> If OK on principle, I'm not sure who is to approve the tiny config.gcc part.
> 
> Thanks in advance for your feedback,
> 
> With Kind Regards,
> 
> Olivier
> 
> 2017-06-26  Jerome Lambourg  <lambourg@adacore.com>
>             Olivier Hainque  <hainque@adacore.com>
> 
>         * config.gcc (tm_defines for VxWorks): Define TARGET_VXWORKS7 for
>         all vxworks7 targets.
>         * config/vxworks.h (TARGET_VXWORKS7): If not defined, define to 0.
>         (VXWORKS_ADDITIONAL_CPP_SPEC): Alternative definition for VXWORKS7.
>         (VXWORKS_LIBS_RTP, VXWORKS_LIBS_RTP_DIR): New macros, allowing
>         variations for VX6/VX7 and 32/64bits later on in ...
>         (VXWORKS_LIB_SPEC): Leverage new macros.
>         (VXWORKS_OS_CPP_BUILTINS): Define _VSB_CONFIG_FILE for VXWORKS7,
>         as well as _ALLOW_KEYWORD_MACROS when "inline" is not a keyword.
> 
I'd think the tiny config.gcc bits would fall under the VxWorks umbrella
and you can self-approve.

jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: common grounds for VxWorks 7 support
  2017-06-26 16:44 ` Jeff Law
@ 2017-06-26 19:17   ` Olivier Hainque
  0 siblings, 0 replies; 5+ messages in thread
From: Olivier Hainque @ 2017-06-26 19:17 UTC (permalink / raw)
  To: Jeff Law
  Cc: Olivier Hainque, GCC Patches, Nathan Sidwell, Jerome Lambourg,
	Douglas B Rupp


> On Jun 26, 2017, at 18:44 , Jeff Law <law@redhat.com> wrote:
> 
>> If OK on principle, I'm not sure who is to approve the tiny config.gcc part.

> I'd think the tiny config.gcc bits would fall under the VxWorks umbrella
> and you can self-approve.

Wonderful :-) Thanks for confirming Jeff!

Olivier

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-26 19:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-26 15:38 common grounds for VxWorks 7 support Olivier Hainque
2017-06-26 15:56 ` Nathan Sidwell
2017-06-26 16:25   ` Olivier Hainque
2017-06-26 16:44 ` Jeff Law
2017-06-26 19:17   ` 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).