net/mlx5: fix build on PPC64

Message ID 20181107160028.5938-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: Shahaf Shuler
Headers
Series net/mlx5: fix build on PPC64 |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Thomas Monjalon Nov. 7, 2018, 4 p.m. UTC
  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.

Suggested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Suggested-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/mlx5/mlx5_utils.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
  

Comments

David Wilder Nov. 7, 2018, 7:05 p.m. UTC | #1
On 2018-11-07 08:00, Thomas Monjalon wrote:
> 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.
> 
> Suggested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> Suggested-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

<cut ....>

Tested-by: David Wilder <dwilder@us.ibm.com>

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).
  
Thomas Monjalon Nov. 7, 2018, 9:10 p.m. UTC | #2
07/11/2018 20:05, dwilder:
> On 2018-11-07 08:00, Thomas Monjalon wrote:
> > 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.
> > 
> > Suggested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> > Suggested-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> 
> <cut ....>
> 
> Tested-by: David Wilder <dwilder@us.ibm.com>
> 
> 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 Nov. 8, 2018, 8:25 a.m. UTC | #3
Wednesday, November 7, 2018 11:10 PM, Thomas Monjalon:
> Subject: Re: [PATCH] net/mlx5: fix build on PPC64
> 
> 07/11/2018 20:05, dwilder:
> > On 2018-11-07 08:00, Thomas Monjalon wrote:
> > > 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.
> > >
> > > Suggested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> > > Suggested-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> > > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> >
> > <cut ....>
> >
> > Tested-by: David Wilder <dwilder@us.ibm.com>
> >
> > 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. 

>
  
Chao Zhu Nov. 8, 2018, 9:46 a.m. UTC | #4
> -----ÓʼþÔ­¼þ-----
> ·¢¼þÈË: Thomas Monjalon <thomas@monjalon.net>
> ·¢ËÍʱ¼ä: 2018Äê11ÔÂ8ÈÕ 0:00
> ÊÕ¼þÈË: dev@dpdk.org
> ³­ËÍ: christian.ehrhardt@canonical.com; adrien.mazarguil@6wind.com;
> shahafs@mellanox.com; yskoh@mellanox.com;
> gowrishankar.m@linux.vnet.ibm.com; chaozhu@linux.vnet.ibm.com;
> pradeep@us.ibm.com; tyos@jp.ibm.com; dwilder@us.ibm.com
> Ö÷Ìâ: [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.
>
> Suggested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> Suggested-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  drivers/net/mlx5/mlx5_utils.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h
> index 886f60e61..97092c749 100644
> --- a/drivers/net/mlx5/mlx5_utils.h
> +++ b/drivers/net/mlx5/mlx5_utils.h
> @@ -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)) + \
> --
> 2.19.0
Verified, it works. Thanks!

Acked-by: Chao Zhu <chaozhu@linux.vnet.ibm.com>
  

Patch

diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h
index 886f60e61..97092c749 100644
--- a/drivers/net/mlx5/mlx5_utils.h
+++ b/drivers/net/mlx5/mlx5_utils.h
@@ -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)) + \