Patchwork pixman: remove -Wredundand-decls

login
register
mail settings
Submitter Paolo Bonzini
Date April 16, 2013, 9:22 a.m.
Message ID <516D1859.5040703@redhat.com>
Download mbox | patch
Permalink /patch/236874/
State New
Headers show

Comments

Paolo Bonzini - April 16, 2013, 9:22 a.m.
Il 16/04/2013 09:57, Markus Armbruster ha scritto:
>>
>> I think this is just beautiful. Fedora18, x86_64, NO cross
>> compiler. gcc does not apply -Wredundant-decls to /usr/include/* but
>> does it for all other headers and in the case of cross compilation I
>> hit this case.

'-Wsystem-headers'
     Print warning messages for constructs found in system header files.
     Warnings from system headers are normally suppressed, on the
     assumption that they usually do not indicate real problems and
     would only make the compiler output harder to read.

>> Does anyone know the way to tell gcc that libc headers are not at
>> /usr/include but somewhere else?

I think this helps:

'--sysroot=DIR'
     Use DIR as the logical root directory for headers and libraries.
     For example, if the compiler normally searches for headers in
     '/usr/include' and libraries in '/usr/lib', it instead searches
     'DIR/usr/include' and 'DIR/usr/lib'.

but you shouldn't need it.  Just configure your GCC with
--with-sysroot=/foo and it should just work.

Also:

> This workaround does NOT work if pragmas used. "#pragma GCC diagnostic
> error "-Wredundant-decls"" re-enables warnings as errors.

The solution is to use push/pop like this:


Untested, feel free to resubmit with my Signed-off-by.

Paolo
Markus Armbruster - April 16, 2013, 10:29 a.m.
Paolo Bonzini <pbonzini@redhat.com> writes:

[...]
>> This workaround does NOT work if pragmas used. "#pragma GCC diagnostic
>> error "-Wredundant-decls"" re-enables warnings as errors.
>
> The solution is to use push/pop like this:
>
> diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c
> index 867a662..4bf2cde 100644
> --- a/coroutine-ucontext.c
> +++ b/coroutine-ucontext.c
> @@ -169,6 +169,7 @@ Coroutine *qemu_coroutine_new(void)
>  #ifdef CONFIG_VALGRIND_H
>  #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
>  /* Work around an unused variable in the valgrind.h macro... */
> +#pragma GCC diagnostic push
>  #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
>  #endif
>  static inline void valgrind_stack_deregister(CoroutineUContext *co)
> @@ -176,7 +177,7 @@ static inline void
> valgrind_stack_deregister(CoroutineUContext *co)
>      VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id);
>  }
>  #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
> -#pragma GCC diagnostic error "-Wunused-but-set-variable"
> +#pragma GCC diagnostic pop
>  #endif
>  #endif
>
> diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
> index b032f52..882e2a3 100644
> --- a/include/ui/qemu-pixman.h
> +++ b/include/ui/qemu-pixman.h
> @@ -8,11 +8,12 @@
>
>  /* pixman-0.16.0 headers have a redundant declaration */
>  #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
> +#pragma GCC diagnostic push
>  #pragma GCC diagnostic ignored "-Wredundant-decls"
>  #endif
>  #include <pixman.h>
>  #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
> -#pragma GCC diagnostic error "-Wredundant-decls"
> +#pragma GCC diagnostic pop
>  #endif
>
>  #include "qemu/typedefs.h"
>
> Untested, feel free to resubmit with my Signed-off-by.
>
> Paolo

You missed the one in ui/gtk.c.  My patch covers it, and also configure.
Alexey Kardashevskiy - April 16, 2013, 10:54 a.m.
On 04/16/2013 07:22 PM, Paolo Bonzini wrote:
> Il 16/04/2013 09:57, Markus Armbruster ha scritto:
>>>
>>> I think this is just beautiful. Fedora18, x86_64, NO cross
>>> compiler. gcc does not apply -Wredundant-decls to /usr/include/* but
>>> does it for all other headers and in the case of cross compilation I
>>> hit this case.
>
> '-Wsystem-headers'
>       Print warning messages for constructs found in system header files.
>       Warnings from system headers are normally suppressed, on the
>       assumption that they usually do not indicate real problems and
>       would only make the compiler output harder to read.
>
>>> Does anyone know the way to tell gcc that libc headers are not at
>>> /usr/include but somewhere else?
>
> I think this helps:
>
> '--sysroot=DIR'
>       Use DIR as the logical root directory for headers and libraries.
>       For example, if the compiler normally searches for headers in
>       '/usr/include' and libraries in '/usr/lib', it instead searches
>       'DIR/usr/include' and 'DIR/usr/lib'.
>
> but you shouldn't need it.  Just configure your GCC with
> --with-sysroot=/foo and it should just work.


--sysroot helps for native compiler but does not for the cross compiler.

Anyway, I tried Markus's patch, now assert.h generates just warnings which 
I can successfully suppress. Cool, thanks everyone :)
Paolo Bonzini - April 16, 2013, 11:12 a.m.
Il 16/04/2013 12:54, Alexey Kardashevskiy ha scritto:
>>
>> but you shouldn't need it.  Just configure your GCC with
>> --with-sysroot=/foo and it should just work.
> 
> 
> --sysroot helps for native compiler but does not for the cross compiler.

That usually points at an incorrect configuration when you built GCC.

> Anyway, I tried Markus's patch, now assert.h generates just warnings
> which I can successfully suppress. Cool, thanks everyone :)

His patch looks good.  Markus, can you repost as a top-level message
with my Reviewed-by?

Paolo
Markus Armbruster - April 16, 2013, 11:52 a.m.
Paolo Bonzini <pbonzini@redhat.com> writes:

> Il 16/04/2013 12:54, Alexey Kardashevskiy ha scritto:
>>>
>>> but you shouldn't need it.  Just configure your GCC with
>>> --with-sysroot=/foo and it should just work.
>> 
>> 
>> --sysroot helps for native compiler but does not for the cross compiler.
>
> That usually points at an incorrect configuration when you built GCC.
>
>> Anyway, I tried Markus's patch, now assert.h generates just warnings
>> which I can successfully suppress. Cool, thanks everyone :)
>
> His patch looks good.  Markus, can you repost as a top-level message
> with my Reviewed-by?

Done.  Thank you both for the testing and the review!

Patch

diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c
index 867a662..4bf2cde 100644
--- a/coroutine-ucontext.c
+++ b/coroutine-ucontext.c
@@ -169,6 +169,7 @@  Coroutine *qemu_coroutine_new(void)
 #ifdef CONFIG_VALGRIND_H
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
 /* Work around an unused variable in the valgrind.h macro... */
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
 #endif
 static inline void valgrind_stack_deregister(CoroutineUContext *co)
@@ -176,7 +177,7 @@  static inline void
valgrind_stack_deregister(CoroutineUContext *co)
     VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id);
 }
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
-#pragma GCC diagnostic error "-Wunused-but-set-variable"
+#pragma GCC diagnostic pop
 #endif
 #endif

diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index b032f52..882e2a3 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -8,11 +8,12 @@ 

 /* pixman-0.16.0 headers have a redundant declaration */
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wredundant-decls"
 #endif
 #include <pixman.h>
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
-#pragma GCC diagnostic error "-Wredundant-decls"
+#pragma GCC diagnostic pop
 #endif

 #include "qemu/typedefs.h"