[v2] Add pragma to ignore gcc-compat warnings in clang when used with diagnose_if.

Message ID 20220117232318.219749-1-mikeb01@gmail.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] Add pragma to ignore gcc-compat warnings in clang when used with diagnose_if. |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Michael Barker Jan. 17, 2022, 11:23 p.m. UTC
  When using clang with -Wall the use of diagnose_if kicks up a warning,
requiring all dpdk includes to be wrapped with the pragma.  This change
isolates the ignore just the appropriate location and makes it easier
for users to apply -Wall,-Werror

Signed-off-by: Michael Barker <mikeb01@gmail.com>
---
 lib/eal/include/rte_compat.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Jan. 20, 2022, 2:16 p.m. UTC | #1
18/01/2022 00:23, Michael Barker:
> When using clang with -Wall the use of diagnose_if kicks up a warning,

Please could you copy the warning in the commit log?

> requiring all dpdk includes to be wrapped with the pragma.  This change
> isolates the ignore just the appropriate location and makes it easier
> for users to apply -Wall,-Werror

Please could you explain how it is related to -Wgcc-compat?

[...]
>  #define __rte_internal \
> +_Pragma("GCC diagnostic push") \
> +_Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \
>  __attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \
> -section(".text.internal")))
> +section(".text.internal"))) \
> +_Pragma("GCC diagnostic pop")
  
Michael Barker Jan. 23, 2022, 9:17 p.m. UTC | #2
On Fri, 21 Jan 2022 at 03:16, Thomas Monjalon <thomas@monjalon.net> wrote:

> 18/01/2022 00:23, Michael Barker:
> > When using clang with -Wall the use of diagnose_if kicks up a warning,
>
> Please could you copy the warning in the commit log?
>

I've updated the commit log to be more descriptive (and included the
associated warning).

> requiring all dpdk includes to be wrapped with the pragma.  This change
> > isolates the ignore just the appropriate location and makes it easier
> > for users to apply -Wall,-Werror
>
> Please could you explain how it is related to -Wgcc-compat?
>

I'm currently working on some code that makes use of DPDK, which is built
with '-Wall,-Werror' enabled.  When using the clang toolchain the build
fails as a result of this macro that this patch updates.  The workaround
from my application is to wrap all of the DPDK header includes in pragma to
disable the warnings (see below).  This has the unfortunate side effect of
disabling this warning across all of the included DPDK headers, which is
not ideal.  Hence the reason to submit the patch which disables the warning
just in the location where it occurs.

#if defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wgcc-compat"
#endif
#include <rte_ethdev.h>
#if defined(__clang__)
#pragma GCC diagnostic pop "-Wgcc-compat"
#endif



>
> [...]
> >  #define __rte_internal \
> > +_Pragma("GCC diagnostic push") \
> > +_Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \
> >  __attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \
> > -section(".text.internal")))
> > +section(".text.internal"))) \
> > +_Pragma("GCC diagnostic pop")
>
>
>
>
  
Stephen Hemminger Jan. 23, 2022, 11:53 p.m. UTC | #3
On Mon, 24 Jan 2022 10:17:37 +1300
Michael Barker <mikeb01@gmail.com> wrote:

> On Fri, 21 Jan 2022 at 03:16, Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > 18/01/2022 00:23, Michael Barker:  
> > > When using clang with -Wall the use of diagnose_if kicks up a warning,  
> >
> > Please could you copy the warning in the commit log?
> >  
> 
> I've updated the commit log to be more descriptive (and included the
> associated warning).
> 
> > requiring all dpdk includes to be wrapped with the pragma.  This change  
> > > isolates the ignore just the appropriate location and makes it easier
> > > for users to apply -Wall,-Werror  
> >
> > Please could you explain how it is related to -Wgcc-compat?
> >  
> 
> I'm currently working on some code that makes use of DPDK, which is built
> with '-Wall,-Werror' enabled.  When using the clang toolchain the build
> fails as a result of this macro that this patch updates.  The workaround
> from my application is to wrap all of the DPDK header includes in pragma to
> disable the warnings (see below).  This has the unfortunate side effect of
> disabling this warning across all of the included DPDK headers, which is
> not ideal.  Hence the reason to submit the patch which disables the warning
> just in the location where it occurs.
> 

Fix the issue please, don't suppress it.
  

Patch

diff --git a/lib/eal/include/rte_compat.h b/lib/eal/include/rte_compat.h
index 2718612cce..9556bbf4d0 100644
--- a/lib/eal/include/rte_compat.h
+++ b/lib/eal/include/rte_compat.h
@@ -33,8 +33,11 @@  section(".text.internal")))
 #elif !defined ALLOW_INTERNAL_API && __has_attribute(diagnose_if) /* For clang */
 
 #define __rte_internal \
+_Pragma("GCC diagnostic push") \
+_Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \
 __attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \
-section(".text.internal")))
+section(".text.internal"))) \
+_Pragma("GCC diagnostic pop")
 
 #else