Skip to contentSkip to conversation

ppc64: fix compilation of when AltiVec is enabled

PATCH In review Christian Ehrhardt 6 participants 11 messages Aug 30, 2018 – Nov 8, 2018 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ppc64: fix compilation of when AltiVec is enabled

The definition of almost any newer standard like --stc=c11 will drop __APPLCE_ALTIVEC__ which otherwise would be defined.
If that is the case then altivec.h will redefine bool to a type conflicting with those defined by stdbool.h.

This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector __bool int’ {aka ‘__vector(4) __bool int’} from type ‘int’ in_port_id_set = false;

Other alternatives were pursued on [1] but they always ended up being more complex than what would be appropriate for the issue we face.

[1]: http://mails.dpdk.org/archives/dev/2018-August/109926.html

---
 .../common/include/arch/ppc_64/rte_memcpy.h           | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +11 -0
index 75f74897b..0b3b89b56 100644
@@ -37,6 +37,17 @@
 #include <string.h>
 /*To include altivec.h, GCC version must  >= 4.8 */
 #include <altivec.h>
+/*
+ * Compilation workaround for PPC64 targets when AltiVec is fully
+ * enabled e.g. with std=c11. Otherwise there would be a type conflict
+ * of "bool" between stdbool and altivec.
+ */
+#if defined(__PPC64__) && !defined(__APPLE_ALTIVEC__)
+ #undef bool
+ /* redefine as in stdbool.h */
+ #define bool _Bool
+#endif
+
 
 #ifdef __cplusplus
 extern "C" {
Signature · 1 line
2.17.1
Acked-by on v3 1/1
#1 lore raw

I think this patch is good enough to solve the confliction issue.

Quoted 56 lines

-----Original Message-----
From: Christian Ehrhardt [mailto:[email protected]]
Sent: 2018年8月30日 20:00
To: [email protected]; dev <[email protected]>; Gowrishankar Muthukrishnan <[email protected]>; Chao Zhu <[email protected]>
Cc: Luca Boccassi <[email protected]>; Thomas Monjalon <[email protected]>; Christian Ehrhardt <[email protected]>
Subject: [PATCH v3] ppc64: fix compilation of when AltiVec is enabled

The definition of almost any newer standard like --stc=c11 will drop __APPLCE_ALTIVEC__ which otherwise would be defined.
If that is the case then altivec.h will redefine bool to a type conflicting with those defined by stdbool.h.

This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector __bool int’ {aka ‘__vector(4) __bool int’} from type ‘int’ in_port_id_set = false;

Other alternatives were pursued on [1] but they always ended up being more complex than what would be appropriate for the issue we face.

[1]: http://mails.dpdk.org/archives/dev/2018-August/109926.html

---
 .../common/include/arch/ppc_64/rte_memcpy.h           | 11
+++++++++++
 1 file changed, 11 insertions(+)
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +10 -1
index 75f74897b..0b3b89b56 100644
@@ -37,6 +37,17 @@
 #include <string.h>
 /*To include altivec.h, GCC version must  >= 4.8 */  #include <altivec.h>
+/*
+ * Compilation workaround for PPC64 targets when AltiVec is fully
+ * enabled e.g. with std=c11. Otherwise there would be a type conflict
+ * of "bool" between stdbool and altivec.
+ */
+#if defined(__PPC64__) && !defined(__APPLE_ALTIVEC__)  #undef bool
+ /* redefine as in stdbool.h */
+ #define bool _Bool
+#endif
+
 
 #ifdef __cplusplus
 extern "C" {
--
Quoted 1 line

2.17.1

#2 lore raw
Quoted 58 lines · Chao Zhu

I think this patch is good enough to solve the confliction issue.

Quoted 11 lines

-----Original Message-----
From: Christian Ehrhardt [mailto:[email protected]]
Sent: 2018年8月30日 20:00
To: [email protected]; dev <[email protected]>; Gowrishankar Muthukrishnan <[email protected]>; Chao Zhu <[email protected]>
Cc: Luca Boccassi <[email protected]>; Thomas Monjalon <[email protected]>; Christian Ehrhardt <[email protected]>
Subject: [PATCH v3] ppc64: fix compilation of when AltiVec is enabled

Quoted 3 lines

The definition of almost any newer standard like --stc=c11 will drop __APPLCE_ALTIVEC__ which otherwise would be defined.
If that is the case then altivec.h will redefine bool to a type

conflicting with

Quoted 8 lines

those defined by stdbool.h.

This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector __bool int’ {aka ‘__vector(4) __bool int’} from type ‘int’ in_port_id_set = false;

Other alternatives were pursued on [1] but they always ended up being

more

Quoted 18 lines

complex than what would be appropriate for the issue we face.

[1]: http://mails.dpdk.org/archives/dev/2018-August/109926.html

---
 .../common/include/arch/ppc_64/rte_memcpy.h           | 11
+++++++++++
 1 file changed, 11 insertions(+)
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +0 -0
index 75f74897b..0b3b89b56 100644

lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h line 38

Quoted 2 lines
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +0 -0
@@ -37,6 +37,17 @@
 #include <string.h>
 /*To include altivec.h, GCC version must  >= 4.8 */  #include

<altivec.h>

Quoted 11 lines
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +10 -0
+/*
+ * Compilation workaround for PPC64 targets when AltiVec is fully
+ * enabled e.g. with std=c11. Otherwise there would be a type conflict
+ * of "bool" between stdbool and altivec.
+ */
+#if defined(__PPC64__) && !defined(__APPLE_ALTIVEC__)  #undef bool
+ /* redefine as in stdbool.h */
+ #define bool _Bool
+#endif
+
 
Quoted 6 lines
Quoted 4 lines
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +0 -1
 #ifdef __cplusplus
 extern "C" {
--

2.17.1

Thanks Chao for taking over for now.
Being listed as Maintainer for "IBM Power" atm, can you push this yourself or do you need someone else to commit it?

Signature · 3 lines
Christian Ehrhardt
Software Engineer, Ubuntu Server
Canonical Ltd
Acked-by
#3 lore raw

We’ll have internal discussion and push it.

Thanks!

From: Christian Ehrhardt [mailto:[email protected]]
Sent: 2018年8月31日 13:15
To: Chao Zhu <[email protected]>
Cc: [email protected]; dev <[email protected]>; Gowrishankar Muthukrishnan <[email protected]>; Luca Boccassi <[email protected]>; Thomas Monjalon <[email protected]>
Subject: Re: [PATCH v3] ppc64: fix compilation of when AltiVec is enabled

On Fri, Aug 31, 2018 at 3:48 AM Chao Zhu <[email protected] <mailto:[email protected]> > wrote:

I think this patch is good enough to solve the confliction issue.

Quoted 56 lines

-----Original Message-----
From: Christian Ehrhardt [mailto:[email protected] <mailto:[email protected]> ]
Sent: 2018年8月30日 20:00
To: [email protected] <mailto:[email protected]> ; dev <[email protected] <mailto:[email protected]> >; Gowrishankar Muthukrishnan <[email protected] <mailto:[email protected]> >; Chao Zhu <[email protected] <mailto:[email protected]> >
Cc: Luca Boccassi <[email protected] <mailto:[email protected]> >; Thomas Monjalon
<[email protected] <mailto:[email protected]> >; Christian Ehrhardt <[email protected] <mailto:[email protected]> >
Subject: [PATCH v3] ppc64: fix compilation of when AltiVec is enabled

The definition of almost any newer standard like --stc=c11 will drop __APPLCE_ALTIVEC__ which otherwise would be defined.
If that is the case then altivec.h will redefine bool to a type conflicting with those defined by stdbool.h.

This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector __bool int’ {aka ‘__vector(4) __bool int’} from type ‘int’ in_port_id_set = false;

Other alternatives were pursued on [1] but they always ended up being more complex than what would be appropriate for the issue we face.

[1]: http://mails.dpdk.org/archives/dev/2018-August/109926.html

Tested-by Takeshi T Yoshimura <[email protected] <mailto:[email protected]> >
Reviewed-by Adrien Mazarguil <[email protected] <mailto:[email protected]> >
Signed-off-by Christian Ehrhardt <[email protected] <mailto:[email protected]> >
---
 .../common/include/arch/ppc_64/rte_memcpy.h           | 11
+++++++++++
 1 file changed, 11 insertions(+)
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +10 -1
index 75f74897b..0b3b89b56 100644
@@ -37,6 +37,17 @@
 #include <string.h>
 /*To include altivec.h, GCC version must  >= 4.8 */  #include <altivec.h>
+/*
+ * Compilation workaround for PPC64 targets when AltiVec is fully
+ * enabled e.g. with std=c11. Otherwise there would be a type conflict
+ * of "bool" between stdbool and altivec.
+ */
+#if defined(__PPC64__) && !defined(__APPLE_ALTIVEC__)  #undef bool
+ /* redefine as in stdbool.h */
+ #define bool _Bool
+#endif
+
 
 #ifdef __cplusplus
 extern "C" {
--
Quoted 1 line

2.17.1

Acked-by Chao Zhu <[email protected] <mailto:[email protected]> >

Thanks Chao for taking over for now.

Being listed as Maintainer for "IBM Power" atm, can you push this yourself or do you need someone else to commit it?

Signature · 5 lines
Christian Ehrhardt

Software Engineer, Ubuntu Server

Canonical Ltd
#4 lore raw
In reply to Christian Ehrhardt

Hi Christian,

Couldn't follow up on this last week, however I still have some concerns and comments, please see below.

Quoted 31 lines · Christian Ehrhardt

The definition of almost any newer standard like --stc=c11 will drop __APPLCE_ALTIVEC__ which otherwise would be defined.
If that is the case then altivec.h will redefine bool to a type conflicting with those defined by stdbool.h.

This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector __bool int’ {aka ‘__vector(4) __bool int’} from type ‘int’ in_port_id_set = false;

Other alternatives were pursued on [1] but they always ended up being more complex than what would be appropriate for the issue we face.

[1]: http://mails.dpdk.org/archives/dev/2018-August/109926.html

---
 .../common/include/arch/ppc_64/rte_memcpy.h           | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +1 -0
index 75f74897b..0b3b89b56 100644
@@ -37,6 +37,17 @@
 #include <string.h>
 /*To include altivec.h, GCC version must  >= 4.8 */
 #include <altivec.h>
+/*

lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h line 50

Quoted 10 lines
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +10 -0
+ * Compilation workaround for PPC64 targets when AltiVec is fully
+ * enabled e.g. with std=c11. Otherwise there would be a type conflict
+ * of "bool" between stdbool and altivec.
+ */
+#if defined(__PPC64__) && !defined(__APPLE_ALTIVEC__)
+ #undef bool
+ /* redefine as in stdbool.h */
+ #define bool _Bool
+#endif
+

The above will break existing C++ programs that include rte_memcpy.h.

Problem is that bool is an actual C++ type. C99 has _Bool which doesn't exist in C++ along with a bool macro that appears only after including stdbool.h.

To make things worse, nothing prevents C++ programs from importing a C-style bool macro by including stdbool.h (or cstdbool).

Enclosing it in #ifdef __cplusplus won't help because you never know what bool is supposed to be in the first place as it depends on how applications are written. I think something like this prior suggestion [1] (saving/restoring bool) is the only way to deal with that in a safe-ish fashion.

Pending something better, the above #undef/#define workaround is only safe to use inside mlx5 PMD code that triggers the compilation issue. It must not be found in a public header.

Quoted 5 lines
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +0 -0
 #ifdef __cplusplus
 extern "C" {
Signature · 1 line
2.17.1

[1] https://mails.dpdk.org/archives/dev/2018-August/110401.html

Signature · 2 lines
Adrien Mazarguil
6WIND
#5 lore raw

03/09/2018 11:29, Adrien Mazarguil:

Quoted 61 lines

Hi Christian,

Couldn't follow up on this last week, however I still have some concerns and comments, please see below.

Quoted 29 lines · Christian Ehrhardt

The definition of almost any newer standard like --stc=c11 will drop __APPLCE_ALTIVEC__ which otherwise would be defined.
If that is the case then altivec.h will redefine bool to a type conflicting with those defined by stdbool.h.

This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector __bool int’ {aka ‘__vector(4) __bool int’} from type ‘int’ in_port_id_set = false;

Other alternatives were pursued on [1] but they always ended up being more complex than what would be appropriate for the issue we face.

[1]: http://mails.dpdk.org/archives/dev/2018-August/109926.html

---
 .../common/include/arch/ppc_64/rte_memcpy.h           | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +1 -0
@@ -37,6 +37,17 @@
 #include <string.h>
 /*To include altivec.h, GCC version must  >= 4.8 */
 #include <altivec.h>
+/*

lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h line 50

Quoted 10 lines
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +10 -0
+ * Compilation workaround for PPC64 targets when AltiVec is fully
+ * enabled e.g. with std=c11. Otherwise there would be a type conflict
+ * of "bool" between stdbool and altivec.
+ */
+#if defined(__PPC64__) && !defined(__APPLE_ALTIVEC__)
+ #undef bool
+ /* redefine as in stdbool.h */
+ #define bool _Bool
+#endif
+

The above will break existing C++ programs that include rte_memcpy.h.

Problem is that bool is an actual C++ type. C99 has _Bool which doesn't exist in C++ along with a bool macro that appears only after including stdbool.h.

To make things worse, nothing prevents C++ programs from importing a C-style bool macro by including stdbool.h (or cstdbool).

Enclosing it in #ifdef __cplusplus won't help because you never know what bool is supposed to be in the first place as it depends on how applications are written. I think something like this prior suggestion [1] (saving/restoring bool) is the only way to deal with that in a safe-ish fashion.

Quoted 8 lines

Pending something better, the above #undef/#define workaround is only safe to use inside mlx5 PMD code that triggers the compilation issue. It must not be found in a public header.

lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h line 53

Quoted 2 lines
lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h +0 -0
 #ifdef __cplusplus
 extern "C" {

[1] https://mails.dpdk.org/archives/dev/2018-August/110401.html

Thank you for the review Adrien. I think we could accept the patch if some notes mention it breaks C++ applications.
But...
After 2 months, nobody replied or complained about the issue not fixed. So I classify this patch as rejected.

Summary of alerts here:

	http://mails.dpdk.org/archives/dev/2018-November/118259.html
#6 lore raw

PATCH 1/1 net/mlx5: fix build on PPC64

In reply to Adrien Mazarguil

The AltiVec header file breaks boolean type:

error: incompatible types when initializing type '__vector _bool int' {aka '_vector(4) __bool int'} using type 'int'

If __APPLE_ALTIVEC__ is defined, then bool type is redefined and conflicts with stdbool.h.

There is no good solution to fix it for the whole project without breaking something else, so a workaround is inserted in mlx5 PMD. This workaround is not compatible with C++ but there is no C++ in DPDK.

---
 drivers/net/mlx5/mlx5_utils.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/mlx5/mlx5_utils.h +10 -0
index 886f60e61..97092c749 100644
@@ -15,6 +15,16 @@
 
 #include "mlx5_defs.h"
 
+/*
+ * Compilation workaround for PPC64 when AltiVec is fully enabled, e.g. std=c11.
+ * Otherwise there would be a type conflict between stdbool and altivec.
+ */
+#if defined(__PPC64__) && !defined(__APPLE_ALTIVEC__)
+#undef bool
+/* redefine as in stdbool.h */
+#define bool _Bool
+#endif
+
 /* Bit-field manipulation. */
 #define BITFIELD_DECLARE(bf, type, size) \
 	type bf[(((size_t)(size) / (sizeof(type) * CHAR_BIT)) + \
Signature · 1 line
2.19.0
Tested-by on v1 1/1
#7 lore raw

Re: [PATCH] net/mlx5: fix build on PPC64

Quoted 15 lines · Thomas Monjalon

The AltiVec header file breaks boolean type:

error: incompatible types when initializing type '__vector _bool int' {aka '_vector(4) __bool int'} using type 'int'

If __APPLE_ALTIVEC__ is defined, then bool type is redefined and conflicts with stdbool.h.

There is no good solution to fix it for the whole project without breaking something else, so a workaround is inserted in mlx5 PMD. This workaround is not compatible with C++ but there is no C++ in DPDK.

<cut ....>

Hi Thomas

Thanks for re-posting this patch. I see no build breaks on power8 or power9 with this patch. I tried both 18.11-rc1 and upstream (master).

#8 lore raw

Re: [PATCH] net/mlx5: fix build on PPC64

07/11/2018 20:05, dwilder:

Quoted 17 lines · Thomas Monjalon
Quoted 8 lines

The AltiVec header file breaks boolean type:

error: incompatible types when initializing type '__vector _bool int' {aka '_vector(4) __bool int'} using type 'int'

If __APPLE_ALTIVEC__ is defined, then bool type is redefined and conflicts with stdbool.h.

Quoted 7 lines

There is no good solution to fix it for the whole project without breaking something else, so a workaround is inserted in mlx5 PMD. This workaround is not compatible with C++ but there is no C++ in DPDK.

Quoted 8 lines

<cut ....>

Hi Thomas

Thanks for re-posting this patch. I see no build breaks on power8 or power9 with this patch. I tried both 18.11-rc1 and upstream (master).

It is not really a re-post. I took the last solution which was proposed for EAL, and applied it to mlx5 only.

#9 lore raw

Re: [PATCH] net/mlx5: fix build on PPC64

Wednesday, November 7, 2018 11:10 PM, Thomas Monjalon:

Quoted 24 lines

Subject: Re: [PATCH] net/mlx5: fix build on PPC64

07/11/2018 20:05, dwilder:

Quoted 21 lines · Thomas Monjalon
Quoted 15 lines

The AltiVec header file breaks boolean type:

error: incompatible types when initializing type '__vector _bool int' {aka '_vector(4) __bool int'} using type 'int'

If __APPLE_ALTIVEC__ is defined, then bool type is redefined and conflicts with stdbool.h.

There is no good solution to fix it for the whole project without breaking something else, so a workaround is inserted in mlx5 PMD. This workaround is not compatible with C++ but there is no C++ in DPDK.

<cut ....>

Quoted 7 lines
Quoted 4 lines

Hi Thomas

Thanks for re-posting this patch. I see no build breaks on power8 or power9 with this patch. I tried both 18.11-rc1 and upstream (master).

It is not really a re-post. I took the last solution which was proposed for EAL, and applied it to mlx5 only.

Applied to next-net-mlx, thanks.

Quoted 1 line
Acked-by on v1 1/1
#10 lore raw

��: [PATCH] net/mlx5: fix build on PPC64

In reply to Thomas Monjalon
Quoted 51 lines

-----�ʼ�ԭ��-----
������: Thomas Monjalon <[email protected]>
����ʱ��: 2018��11��8�� 0:00
�ռ���: [email protected]
����: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected] ����: [PATCH] net/mlx5: fix build on PPC64

The AltiVec header file breaks boolean type:

error: incompatible types when initializing type '__vector _bool int' {aka '_vector(4) __bool int'} using type 'int'

If __APPLE_ALTIVEC__ is defined, then bool type is redefined and conflicts with stdbool.h.

There is no good solution to fix it for the whole project without breaking something else, so a workaround is inserted in mlx5 PMD.
This workaround is not compatible with C++ but there is no C++ in DPDK.

---
 drivers/net/mlx5/mlx5_utils.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/mlx5/mlx5_utils.h +2 -0
index 886f60e61..97092c749 100644
@@ -15,6 +15,16 @@
 
 #include "mlx5_defs.h"
 
+/*
+ * Compilation workaround for PPC64 when AltiVec is fully enabled, e.g.

std=c11.
+ * Otherwise there would be a type conflict between stdbool and altivec.
+ */

drivers/net/mlx5/mlx5_utils.h +5 -1
+#if defined(__PPC64__) && !defined(__APPLE_ALTIVEC__) #undef bool
+/* redefine as in stdbool.h */
+#define bool _Bool
+#endif
+
 /* Bit-field manipulation. */
 #define BITFIELD_DECLARE(bf, type, size) \
 	type bf[(((size_t)(size) / (sizeof(type) * CHAR_BIT)) + \
--
Quoted 1 line

2.19.0

Verified, it works. Thanks!