qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH maybe-for-3.1?] linux-user: Fix compilation with clang 3.4
@ 2018-11-30 10:33 Thomas Huth
  2018-11-30 10:42 ` Laurent Vivier
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2018-11-30 10:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, Laurent Vivier, peter.maydell

Clang version 3.4.2 does not know the -Wpragmas option yet and bails
out with an error when we try to disable it in linux-user/qemu.h.
Fortunately, clang has a __has_warning() macro which allows us to add
an explicit check for this option to fix this issue.

Fixes: 850d5e330a9c68cc998cecc02caf8a3c8d1ee8a3
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 Today, I noticed that building the linux-user targets is currently also
 not working with Clang 3.4 anymore ... so in case we will roll out 3.1-rc4,
 I think this patch should be considered, too. Otherwise, this certainly
 does not justify another rc, so it can also be added later via stable.

 include/qemu/compiler.h | 4 ++++
 linux-user/qemu.h       | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 6b92710..ca9bc85 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -119,6 +119,10 @@
 #define GCC_FMT_ATTR(n, m)
 #endif
 
+#ifndef __has_warning
+#define __has_warning(x) 0 /* compatibility with non-clang compilers */
+#endif
+
 #ifndef __has_feature
 #define __has_feature(x) 0 /* compatibility with non-clang compilers */
 #endif
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index dd5771c..c7b3c37 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -481,7 +481,7 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
  *   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83256 -- so we only
  *   include the warning-suppression pragmas for clang
  */
-#ifdef __clang__
+#if defined(__clang__) && __has_warning("-Wpragmas")
 #define PRAGMA_DISABLE_PACKED_WARNING                                   \
     _Pragma("GCC diagnostic push");                                     \
     _Pragma("GCC diagnostic ignored \"-Wpragmas\"");                    \
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH maybe-for-3.1?] linux-user: Fix compilation with clang 3.4
  2018-11-30 10:33 [Qemu-devel] [PATCH maybe-for-3.1?] linux-user: Fix compilation with clang 3.4 Thomas Huth
@ 2018-11-30 10:42 ` Laurent Vivier
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Vivier @ 2018-11-30 10:42 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel; +Cc: Riku Voipio, peter.maydell

On 30/11/2018 11:33, Thomas Huth wrote:
> Clang version 3.4.2 does not know the -Wpragmas option yet and bails
> out with an error when we try to disable it in linux-user/qemu.h.
> Fortunately, clang has a __has_warning() macro which allows us to add
> an explicit check for this option to fix this issue.
> 
> Fixes: 850d5e330a9c68cc998cecc02caf8a3c8d1ee8a3
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  Today, I noticed that building the linux-user targets is currently also
>  not working with Clang 3.4 anymore ... so in case we will roll out 3.1-rc4,
>  I think this patch should be considered, too. Otherwise, this certainly
>  does not justify another rc, so it can also be added later via stable.
> 
>  include/qemu/compiler.h | 4 ++++
>  linux-user/qemu.h       | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
> index 6b92710..ca9bc85 100644
> --- a/include/qemu/compiler.h
> +++ b/include/qemu/compiler.h
> @@ -119,6 +119,10 @@
>  #define GCC_FMT_ATTR(n, m)
>  #endif
>  
> +#ifndef __has_warning
> +#define __has_warning(x) 0 /* compatibility with non-clang compilers */
> +#endif
> +
>  #ifndef __has_feature
>  #define __has_feature(x) 0 /* compatibility with non-clang compilers */
>  #endif
> diff --git a/linux-user/qemu.h b/linux-user/qemu.h
> index dd5771c..c7b3c37 100644
> --- a/linux-user/qemu.h
> +++ b/linux-user/qemu.h
> @@ -481,7 +481,7 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
>   *   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83256 -- so we only
>   *   include the warning-suppression pragmas for clang
>   */
> -#ifdef __clang__
> +#if defined(__clang__) && __has_warning("-Wpragmas")

Perhaps we could remove the "-Wpragmas" and only use
"-Waddress-of-packed-member" with
__has_warning("-Waddress-of-packed-member"),
as -Wpragmas warning is there to avoid a complaint about an unknown
warning "-Waddress-of-packed-member"?

Thanks,
Laurent

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-30 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-30 10:33 [Qemu-devel] [PATCH maybe-for-3.1?] linux-user: Fix compilation with clang 3.4 Thomas Huth
2018-11-30 10:42 ` Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).