public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch]  Rework CPP_BUILTINS_SPEC for powerpc-vxworks
@ 2020-10-01  9:30 Olivier Hainque
  2020-10-02 22:43 ` Segher Boessenkool
  0 siblings, 1 reply; 6+ messages in thread
From: Olivier Hainque @ 2020-10-01  9:30 UTC (permalink / raw)
  To: GCC Patches

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

This change reworks CPP_BUILTINS_SPEC for powerpc-vxworks to
prepare for the upcoming addition of 32 and 64 bit ports for
VxWorks 7r2.

This has been used in gcc-9 based production compilers for a
year on both vxworks 7 and 6.9. Also passed a build & test sequence
for powerpc-vxworks 7 and 6.9 with gcc-10 and a sanity check build
with a recent mainline.

Will commit to mainline shortly.

Olivier

2020-10-01  Olivier Hainque  <hainque@adacore.com>

        * config/rs6000/vxworks.h (TARGET_OS_CPP_BUILTINS): Accommodate
        expectations from different versions of VxWorks, for 32 or 64bit
        configurations.


[-- Attachment #2: 0006-Augment-CPP_BUILTINS_SPEC-for-powerpc-vxworks.diff --]
[-- Type: application/octet-stream, Size: 2712 bytes --]

--- a/gcc/config/rs6000/vxworks.h
+++ b/gcc/config/rs6000/vxworks.h
@@ -26,21 +26,56 @@ along with GCC; see the file COPYING3.  If not see
 /* CPP predefined macros.  */
 
 #undef TARGET_OS_CPP_BUILTINS
-#define TARGET_OS_CPP_BUILTINS()		\
-  do						\
-    {						\
-      builtin_define ("__ppc");			\
-      builtin_define ("__PPC__");		\
-      builtin_define ("__EABI__");		\
-      builtin_define ("__ELF__");		\
-      if (!TARGET_SOFT_FLOAT)			\
-	builtin_define ("__hardfp");		\
+#define TARGET_OS_CPP_BUILTINS()                \
+  do                                            \
+    {                                           \
+      /* CPU macros.  */			\
+      builtin_define ("__ppc");                 \
+      builtin_define ("__ppc__");               \
+      builtin_define ("__PPC");                 \
+      builtin_define ("__PPC__");               \
+      builtin_define ("__powerpc");             \
+      builtin_define ("__powerpc__");           \
+      if (TARGET_64BIT)                         \
+        {                                       \
+          builtin_define ("__ppc64");           \
+          builtin_define ("__ppc64__");         \
+          builtin_define ("__PPC64");		\
+          builtin_define ("__PPC64__");         \
+          builtin_define ("__powerpc64");	\
+          builtin_define ("__powerpc64__");     \
+	}					\
 						\
-      /* C89 namespace violation! */		\
-      builtin_define ("CPU_FAMILY=PPC");	\
-        					\
-      VXWORKS_OS_CPP_BUILTINS ();		\
-    }		\
+      /* Asserts for #cpu and #machine.  */	\
+      if (TARGET_64BIT)                         \
+	{					\
+          builtin_assert ("cpu=powerpc64");     \
+          builtin_assert ("machine=powerpc64"); \
+        }                                       \
+      else 					\
+	{					\
+          builtin_assert ("cpu=powerpc");	\
+          builtin_assert ("machine=powerpc");   \
+	}					\
+						\
+      /* PowerPC VxWorks specificities.  */	\
+      if (!TARGET_SOFT_FLOAT)                   \
+        {                                       \
+          builtin_define ("__hardfp");          \
+          builtin_define ("_WRS_HARDWARE_FP");  \
+        }                                       \
+						\
+      if (!TARGET_VXWORKS7)			\
+	{					\
+          builtin_define ("__EABI__");          \
+	  builtin_define ("__ELF__");           \
+          builtin_define ("CPU_FAMILY=PPC");	\
+	}					\
+						\
+      /* Common VxWorks and port items.  */	\
+      VXWORKS_OS_CPP_BUILTINS ();               \
+      TARGET_OS_SYSV_CPP_BUILTINS ();           \
+    }                                           \
   while (0)
 
 /* vx6 library path.  */
-- 
2.17.1


[-- Attachment #3: Type: text/plain, Size: 5 bytes --]







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

* Re: [patch]  Rework CPP_BUILTINS_SPEC for powerpc-vxworks
  2020-10-01  9:30 [patch] Rework CPP_BUILTINS_SPEC for powerpc-vxworks Olivier Hainque
@ 2020-10-02 22:43 ` Segher Boessenkool
  2020-10-05 17:27   ` Olivier Hainque
  0 siblings, 1 reply; 6+ messages in thread
From: Segher Boessenkool @ 2020-10-02 22:43 UTC (permalink / raw)
  To: Olivier Hainque; +Cc: GCC Patches

Hi Olivier,

On Thu, Oct 01, 2020 at 11:30:55AM +0200, Olivier Hainque wrote:
> This change reworks CPP_BUILTINS_SPEC for powerpc-vxworks to
> prepare for the upcoming addition of 32 and 64 bit ports for
> VxWorks 7r2.

Cool, looking forward to it!

Your attachment is not quotable (it is application/octet-stream), so
I'll paste it in here, hopefully correct:

--- a/gcc/config/rs6000/vxworks.h
+++ b/gcc/config/rs6000/vxworks.h
@@ -26,21 +26,56 @@ along with GCC; see the file COPYING3.  If not see
 /* CPP predefined macros.  */
 
 #undef TARGET_OS_CPP_BUILTINS
-#define TARGET_OS_CPP_BUILTINS()		\
-  do						\
-    {						\
-      builtin_define ("__ppc");			\
-      builtin_define ("__PPC__");		\
-      builtin_define ("__EABI__");		\
-      builtin_define ("__ELF__");		\
-      if (!TARGET_SOFT_FLOAT)			\
-	builtin_define ("__hardfp");		\
+#define TARGET_OS_CPP_BUILTINS()                \

Hrm, you changed a lot of white space, was that on purpose?

+  do                                            \
+    {                                           \
+      /* CPU macros.  */			\
+      builtin_define ("__ppc");                 \
+      builtin_define ("__ppc__");               \
+      builtin_define ("__PPC");                 \
+      builtin_define ("__PPC__");               \
+      builtin_define ("__powerpc");             \
+      builtin_define ("__powerpc__");           \
+      if (TARGET_64BIT)                         \
+        {                                       \
+          builtin_define ("__ppc64");           \
+          builtin_define ("__ppc64__");         \
+          builtin_define ("__PPC64");		\
+          builtin_define ("__PPC64__");         \
+          builtin_define ("__powerpc64");	\
+          builtin_define ("__powerpc64__");     \
+	}					\

Are all those new names actually defined by your ABIs?  If not, this is
counter-productive: it does not help anyone if there are six ways to
write things, where not all ways are supported by all compilers!
(Including older versions of the same compilers.)

-      /* C89 namespace violation! */		\
-      builtin_define ("CPU_FAMILY=PPC");	\

+          builtin_define ("CPU_FAMILY=PPC");	\

You removed the comment, but it is rather important still?  Of course
the "C89" part of it is dated, but it is true for all newer language
standards just the same.

Cheers,


Segher

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

* Re: [patch]  Rework CPP_BUILTINS_SPEC for powerpc-vxworks
  2020-10-02 22:43 ` Segher Boessenkool
@ 2020-10-05 17:27   ` Olivier Hainque
  2020-10-13 13:35     ` Olivier Hainque
  0 siblings, 1 reply; 6+ messages in thread
From: Olivier Hainque @ 2020-10-05 17:27 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Olivier Hainque, GCC Patches

Hi Segher,

> On 3 Oct 2020, at 00:43, Segher Boessenkool <segher@kernel.crashing.org> wrote:
> 
> Hi Olivier,
> 
> On Thu, Oct 01, 2020 at 11:30:55AM +0200, Olivier Hainque wrote:
>> This change reworks CPP_BUILTINS_SPEC for powerpc-vxworks to
>> prepare for the upcoming addition of 32 and 64 bit ports for
>> VxWorks 7r2.
> 
> Cool, looking forward to it!

:-)

> Your attachment is not quotable (it is application/octet-stream),

Ah, I thought I has addressed that. Will review.

> so
> I'll paste it in here, hopefully correct:
> 
> --- a/gcc/config/rs6000/vxworks.h
> +++ b/gcc/config/rs6000/vxworks.h
> @@ -26,21 +26,56 @@ along with GCC; see the file COPYING3.  If not see
> /* CPP predefined macros.  */
> 
> #undef TARGET_OS_CPP_BUILTINS
> -#define TARGET_OS_CPP_BUILTINS()		\
> -  do						\
> -    {						\
> -      builtin_define ("__ppc");			\
> -      builtin_define ("__PPC__");		\
> -      builtin_define ("__EABI__");		\
> -      builtin_define ("__ELF__");		\
> -      if (!TARGET_SOFT_FLOAT)			\
> -	builtin_define ("__hardfp");		\
> +#define TARGET_OS_CPP_BUILTINS()                \
> 
> Hrm, you changed a lot of white space, was that on purpose?

Not really, I was just refactoring the whole block and thought
that seeing the entire new block as one piece was of possible
interest.

I can adjust to keep the few unchanged pieces unchanged.

> +  do                                            \
> +    {                                           \
> +      /* CPU macros.  */			\
> +      builtin_define ("__ppc");                 \
> +      builtin_define ("__ppc__");               \
> +      builtin_define ("__PPC");                 \
> +      builtin_define ("__PPC__");               \
> +      builtin_define ("__powerpc");             \
> +      builtin_define ("__powerpc__");           \
> +      if (TARGET_64BIT)                         \
> +        {                                       \
> +          builtin_define ("__ppc64");           \
> +          builtin_define ("__ppc64__");         \
> +          builtin_define ("__PPC64");		\
> +          builtin_define ("__PPC64__");         \
> +          builtin_define ("__powerpc64");	\
> +          builtin_define ("__powerpc64__");     \
> +	}					\
> 
> Are all those new names actually defined by your ABIs?  If not, this is
> counter-productive: it does not help anyone if there are six ways to
> write things, where not all ways are supported by all compilers!
> (Including older versions of the same compilers.)

This is inspired from a mix of what the system compilers do
and what we can find in the system headers across the two versions
(vx6 and 7), with the intent to come up with a consistent and
not too convoluted overall logic.

I'll see if I differentiating 6 and 7 can tighten at least
some of the subsets.

> -      /* C89 namespace violation! */		\
> -      builtin_define ("CPU_FAMILY=PPC");	\
> 
> +          builtin_define ("CPU_FAMILY=PPC");	\
> 
> You removed the comment, but it is rather important still?  Of course
> the "C89" part of it is dated, but it is true for all newer language
> standards just the same.

I'm happy to add the comment back, even without the C89 specialization.
It's just one macro that the VxWorks header files rely on pretty
heavily.

I'll post an updated version, thanks for the comments.

Cheers,

Olivier


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

* Re: [patch]  Rework CPP_BUILTINS_SPEC for powerpc-vxworks
  2020-10-05 17:27   ` Olivier Hainque
@ 2020-10-13 13:35     ` Olivier Hainque
  2020-10-13 15:38       ` Segher Boessenkool
  0 siblings, 1 reply; 6+ messages in thread
From: Olivier Hainque @ 2020-10-13 13:35 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Olivier Hainque, GCC Patches, Rasmus Villemoes

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

Hi Segher,

> On 5 Oct 2020, at 19:27, Olivier Hainque <hainque@adacore.com> wrote:
> 
> I'll post an updated version, thanks for the comments.

Here's an updated version which passed in-house build & tests
with gcc-10 based toolchains for VxWorks 6.9 & 7.2, and with which
I could build mainline for VxWorks 6.9 including libstdc++ (combined
with a few other patches, orthogonal to what is proposed here and
which I'll post shortly).

Same ChangeLog. Patch hopefully quotable if needed now.

Olivier

2020-10-13  Olivier Hainque  <hainque@adacore.com>

       * config/rs6000/vxworks.h (TARGET_OS_CPP_BUILTINS): Accommodate
       expectations from different versions of VxWorks, for 32 or 64bit
       configurations.



[-- Attachment #2: ppc_vxworks_cpp_builtins.txt --]
[-- Type: text/plain, Size: 2217 bytes --]

diff --git a/gcc/config/rs6000/vxworks.h b/gcc/config/rs6000/vxworks.h
index 771dddf68bba..60e1ef42390f 100644
--- a/gcc/config/rs6000/vxworks.h
+++ b/gcc/config/rs6000/vxworks.h
@@ -29,17 +29,60 @@ along with GCC; see the file COPYING3.  If not see
 #define TARGET_OS_CPP_BUILTINS()		\
   do						\
     {						\
-      builtin_define ("__ppc");			\
-      builtin_define ("__PPC__");		\
-      builtin_define ("__EABI__");		\
       builtin_define ("__ELF__");		\
+      if (!TARGET_VXWORKS7)			\
+	builtin_define ("__EABI__");		\
+						\
+      /* CPU macros, based on what the system compilers do.  */	\
+      if (!TARGET_VXWORKS7)			\
+	{					\
+	  builtin_define ("__ppc");		\
+	  /* Namespace violation below, but the system headers \
+	     really depend heavily on this.  */	\
+	  builtin_define ("CPU_FAMILY=PPC");	\
+						\
+	  /* __PPC__ isn't actually emitted by the system compiler \
+	     prior to vx7 but has been advertised by us for ages.  */	\
+	  builtin_define ("__PPC__");		\
+	}					\
+      else					\
+	{					\
+	  builtin_define ("__PPC__");		\
+	  builtin_define ("__powerpc__");	\
+	  if (TARGET_64BIT)			\
+	    {					\
+	      builtin_define ("__PPC64__");	\
+	      builtin_define ("__powerpc64__");	\
+	    }					\
+	  else					\
+	    {					\
+	      builtin_define ("__PPC");		\
+	      builtin_define ("__powerpc");	\
+	    }					\
+	}					\
+						\
+      /* Asserts for #cpu and #machine.  */	\
+      if (TARGET_64BIT)				\
+	{					\
+	  builtin_assert ("cpu=powerpc64");     \
+	  builtin_assert ("machine=powerpc64"); \
+	}					\
+      else 					\
+	{					\
+	  builtin_assert ("cpu=powerpc");	\
+	  builtin_assert ("machine=powerpc");   \
+	}					\
+						\
+      /* PowerPC VxWorks specificities.  */	\
       if (!TARGET_SOFT_FLOAT)			\
-	builtin_define ("__hardfp");		\
+	{					\
+	  builtin_define ("__hardfp");		\
+	  builtin_define ("_WRS_HARDWARE_FP");  \
+	}                                       \
 						\
-      /* C89 namespace violation! */		\
-      builtin_define ("CPU_FAMILY=PPC");	\
-        					\
+      /* Common VxWorks and port items.  */	\
       VXWORKS_OS_CPP_BUILTINS ();		\
+      TARGET_OS_SYSV_CPP_BUILTINS ();		\
     }		\
   while (0)
 

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

* Re: [patch]  Rework CPP_BUILTINS_SPEC for powerpc-vxworks
  2020-10-13 13:35     ` Olivier Hainque
@ 2020-10-13 15:38       ` Segher Boessenkool
  2020-10-14 10:52         ` Olivier Hainque
  0 siblings, 1 reply; 6+ messages in thread
From: Segher Boessenkool @ 2020-10-13 15:38 UTC (permalink / raw)
  To: Olivier Hainque; +Cc: GCC Patches, Rasmus Villemoes

Hi!

On Tue, Oct 13, 2020 at 03:35:11PM +0200, Olivier Hainque wrote:
> Here's an updated version which passed in-house build & tests
> with gcc-10 based toolchains for VxWorks 6.9 & 7.2, and with which
> I could build mainline for VxWorks 6.9 including libstdc++ (combined
> with a few other patches, orthogonal to what is proposed here and
> which I'll post shortly).
> 
> Same ChangeLog. Patch hopefully quotable if needed now.

It is, thank you!

The patch looks fine to me now.  Not that you need my approval :-)


Segher

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

* Re: [patch]  Rework CPP_BUILTINS_SPEC for powerpc-vxworks
  2020-10-13 15:38       ` Segher Boessenkool
@ 2020-10-14 10:52         ` Olivier Hainque
  0 siblings, 0 replies; 6+ messages in thread
From: Olivier Hainque @ 2020-10-14 10:52 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Olivier Hainque, GCC Patches, Rasmus Villemoes



> On 13 Oct 2020, at 17:38, Segher Boessenkool 
>> 
>> Same ChangeLog. Patch hopefully quotable if needed now.
> 
> It is, thank you!

Sure.

> The patch looks fine to me now.

Great, thanks!

>  Not that you need my approval :-)

Always happy to get constructive suggestions for
improvements :)

Your comments encouraged me to look at the set of
predefined macros slightly differently, which proved
very useful.

Glad to see that the adjustements lead to something
that looks better in your opinion as well.

Best Regards,

Olivier


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

end of thread, other threads:[~2020-10-14 10:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01  9:30 [patch] Rework CPP_BUILTINS_SPEC for powerpc-vxworks Olivier Hainque
2020-10-02 22:43 ` Segher Boessenkool
2020-10-05 17:27   ` Olivier Hainque
2020-10-13 13:35     ` Olivier Hainque
2020-10-13 15:38       ` Segher Boessenkool
2020-10-14 10:52         ` 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).