ppc64: fix compilation of when AltiVec is enabled
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
@@ -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 __cplusplusextern "C" {
Signature · 1 line
2.17.1
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 enabledThe definition of almost any newer standard like --stc=c11 will drop
__APPLCE_ALTIVEC__which otherwise would be defined.
If that is the case thenaltivec.hwill redefine bool to a type conflicting with those defined bystdbool.h.This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector__boolint’ {aka ‘__vector(4)__boolint’} 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]>Reviewed-by Adrien Mazarguil <[email protected]>Signed-off-by Christian Ehrhardt <[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@@ -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 __cplusplusextern "C" { --
Quoted 1 line
2.17.1
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 enabledQuoted 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 thenaltivec.hwill redefine bool to a typeconflicting 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__boolint’ {aka ‘__vector(4)__boolint’} 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
Tested-by Takeshi T Yoshimura <[email protected]>Reviewed-by Adrien Mazarguil <[email protected]>Signed-off-by Christian Ehrhardt <[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 +0
-0lib/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 __cplusplusextern "C" { --2.17.1
Acked-by Chao Zhu <[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 · 3 lines
Christian Ehrhardt Software Engineer, Ubuntu Server Canonical Ltd
Chao Zhu
Acked-byWe’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 enabledThe definition of almost any newer standard like --stc=c11 will drop
__APPLCE_ALTIVEC__which otherwise would be defined.
If that is the case thenaltivec.hwill redefine bool to a type conflicting with those defined bystdbool.h.This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector__boolint’ {aka ‘__vector(4)__boolint’} 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@@ -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 __cplusplusextern "C" { --
Quoted 1 line
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 · 5 lines
Christian Ehrhardt Software Engineer, Ubuntu Server Canonical Ltd
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 thenaltivec.hwill redefine bool to a type conflicting with those defined bystdbool.h.This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector__boolint’ {aka ‘__vector(4)__boolint’} 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]>Reviewed-by Adrien Mazarguil <[email protected]>Signed-off-by Christian Ehrhardt <[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 +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.
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 __cplusplusextern "C" {Signature · 1 line
2.17.1
[1] https://mails.dpdk.org/archives/dev/2018-August/110401.html
Signature · 2 lines
Adrien Mazarguil 6WIND
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 thenaltivec.hwill redefine bool to a type conflicting with those defined bystdbool.h.This breaks compilation of 18.08 on ppc64 like:
mlx5_nl_flow.c:407:17: error: incompatible types when assigning to type ‘__vector__boolint’ {aka ‘__vector(4)__boolint’} 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]>Reviewed-by Adrien Mazarguil <[email protected]>Signed-off-by Christian Ehrhardt <[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 +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
_Boolwhich doesn't exist in C++ along with a bool macro that appears only after includingstdbool.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
__cpluspluswon'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 __cplusplusextern "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
PATCH 1/1 net/mlx5: fix build on PPC64
In reply to Adrien MazarguilThe 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
@@ -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
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_boolint' {aka '_vector(4)__boolint'} using type 'int'If
__APPLE_ALTIVEC__is defined, then bool type is redefined and conflicts withstdbool.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.
Suggested-by Christian Ehrhardt <[email protected]>Suggested-by Adrien Mazarguil <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>
<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).
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_boolint' {aka '_vector(4)__boolint'} using type 'int'If
__APPLE_ALTIVEC__is defined, then bool type is redefined and conflicts withstdbool.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.
Suggested-by Christian Ehrhardt <[email protected]>Suggested-by Adrien Mazarguil <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>
Quoted 8 lines
<cut ....>
Tested-by David Wilder <[email protected]>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.
Shahaf Shuler
AppliedRe: [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_boolint' {aka '_vector(4)__boolint'} using type 'int'If
__APPLE_ALTIVEC__is defined, then bool type is redefined and conflicts withstdbool.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.
Suggested-by Christian Ehrhardt <[email protected]>Suggested-by Adrien Mazarguil <[email protected]>Signed-off-by Thomas Monjalon <[email protected]><cut ....>
Tested-by David Wilder <[email protected]>
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
��: [PATCH] net/mlx5: fix build on PPC64
In reply to Thomas MonjalonQuoted 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 PPC64The AltiVec header file breaks boolean type:
error: incompatible types when initializing type '
__vector_boolint' {aka '_vector(4)__boolint'} using type 'int'If
__APPLE_ALTIVEC__is defined, then bool type is redefined and conflicts withstdbool.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.Suggested-by Christian Ehrhardt <[email protected]>Suggested-by Adrien Mazarguil <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/mlx5/mlx5_utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/mlx5/mlx5_utils.h +2
-0@@ -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!