Skip to contentSkip to conversation

Remove GCC < 4.8 checks

PATCH Applied [email protected] 9 participants 33 messages Dec 10, 2020 – Dec 14, 2020 Atomic infrastructure

lore
Share & tools
lore
#0 lore raw

v3 cover Remove GCC < 4.8 checks

From: Marc-André Lureau <[email protected]>

Hi,

Since commit efc6c07 ("configure: Add a test for the minimum compiler version"), QEMU explicitely depends on GCC >= 4.8.

v3:
- drop first patch replacing QEMU_GNUC_PREREQ with G_GNUC_CHECK_VERSION
- add last patch to remove QEMU_GNUC_PREREQ
- tweak commit messages to replace clang 3.8 with clang 3.4
- fix some extra coding style
- collect r-b/a-b tags

v2:
- include reviewed Philippe earlier series
- drop problematic patch to replace GCC_FMT_ATTR, but tweak the check to be clang
- replace QEMU_GNUC_PREREQ with G_GNUC_CHECK_VERSION
- split changes
- add patches to drop __GNUC__ checks (clang advertizes itself as 4.2.1, unless -fgnuc-version=0)

Marc-André Lureau (11):
compiler.h: remove GCC < 3 __builtin_expect fallback qemu-plugin.h: remove GCC < 4
tests: remove GCC < 4 fallbacks
virtiofsd: replace _Static_assert with QEMU_BUILD_BUG_ON compiler.h: explicit case for Clang printf attribute
audio: remove GNUC & MSVC check
poison: remove GNUC check
xen: remove GNUC check
compiler: remove GNUC check
linux-user: remove GNUC check
compiler.h: remove QEMU_GNUC_PREREQ

Philippe Mathieu-Daudé (2):
qemu/atomic: Drop special case for unsupported compiler accel/tcg: Remove special case for GCC < 4.6

 include/exec/poison.h              |  2 --
 include/hw/xen/interface/io/ring.h |  9 ------
 include/qemu/atomic.h              | 17 -----------
 include/qemu/compiler.h            | 45 ++++++++----------------------
 include/qemu/qemu-plugin.h         |  9 ++----
 scripts/cocci-macro-file.h         |  1 -
 tools/virtiofsd/fuse_common.h      | 11 +-------
 accel/tcg/cpu-exec.c               |  2 +-
 audio/audio.c                      |  8 +-----
 linux-user/strace.c                |  4 ---
 tests/tcg/arm/fcvt.c               |  8 ++----
 11 files changed, 20 insertions(+), 96 deletions(-)
Signature · 1 line
2.29.0
#1 lore raw

PATCH v3 1/13 qemu/atomic: Drop special case for unsupported compiler

From: Philippe Mathieu-Daudé <[email protected]>

Since commit efc6c070aca ("configure: Add a test for the minimum compiler version") the minimum compiler version required for GCC is 4.8, which has the GCC BZ#36793 bug fixed.

We can safely remove the special case introduced in commit a281ebc11a6 ("virtio: add missing mb() on notification").

With clang 3.4, __ATOMIC_RELAXED is defined, so the chunk to remove (which is x86-specific), isn't reached either.

---
 include/qemu/atomic.h | 17 -----------------
 1 file changed, 17 deletions(-)
include/qemu/atomic.h +0 -17
index c1d211a351..8f4b3a80fb 100644
@@ -241,23 +241,6 @@
 
 #else /* __ATOMIC_RELAXED */
 
-/*
- * We use GCC builtin if it's available, as that can use mfence on
- * 32-bit as well, e.g. if built with -march=pentium-m. However, on
- * i386 the spec is buggy, and the implementation followed it until
- * 4.3 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36793).
- */
-#if defined(__i386__) || defined(__x86_64__)
-#if !QEMU_GNUC_PREREQ(4, 4)
-#if defined __x86_64__
-#define smp_mb()    ({ asm volatile("mfence" ::: "memory"); (void)0; })
-#else
-#define smp_mb()    ({ asm volatile("lock; addl $0,0(%%esp) " ::: "memory"); (void)0; })
-#endif
-#endif
-#endif
-
-
 #ifdef __alpha__
 #define smp_read_barrier_depends()   asm volatile("mb":::"memory")
 #endif
Signature · 1 line
2.29.0
Reviewed-by on v3 1/13
#2 lore raw

Re: [PATCH v3 01/13] qemu/atomic: Drop special case for unsupported compiler

Quoted 9 lines · On Thu, Dec 10, 2020 at 05:47:40PM +0400, [email protected] wrote:

From: Philippe Mathieu-Daudé <[email protected]>

Since commit efc6c070aca ("configure: Add a test for the minimum compiler version") the minimum compiler version required for GCC is 4.8, which has the GCC BZ#36793 bug fixed.

We can safely remove the special case introduced in commit a281ebc11a6 ("virtio: add missing mb() on notification").

Quoted 8 lines

With clang 3.4, __ATOMIC_RELAXED is defined, so the chunk to remove (which is x86-specific), isn't reached either.

---
 include/qemu/atomic.h | 17 -----------------
 1 file changed, 17 deletions(-)
#3 lore raw

PATCH v3 2/13 accel/tcg: Remove special case for GCC < 4.6

In reply to [email protected]

From: Philippe Mathieu-Daudé <[email protected]>

Since commit efc6c070aca ("configure: Add a test for the minimum compiler version") the minimum compiler version required for GCC is 4.8.

We can safely remove the special case for GCC 4.6 introduced in commit 0448f5f8b81 ("cpu-exec: Fix compiler warning (-Werror=clobbered)").
No change for Clang as we don't know.

---
 accel/tcg/cpu-exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
accel/tcg/cpu-exec.c +1 -1
index 58aea605d8..37a88edb6d 100644
@@ -724,7 +724,7 @@ int cpu_exec(CPUState *cpu)
 
     /* prepare setjmp context for exception handling */
     if (sigsetjmp(cpu->jmp_env, 0) != 0) {
-#if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6)
+#if defined(__clang__)
         /* Some compilers wrongly smash all local variables after
          * siglongjmp. There were bug reports for gcc 4.5.0 and clang.
          * Reload essential local variables here for those compilers.
Signature · 1 line
2.29.0
#4 lore raw

PATCH v3 3/13 compiler.h: remove GCC < 3 __builtin_expect fallback

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Since commit efc6c07 ("configure: Add a test for the minimum compiler version"), QEMU explicitely depends on GCC >= 4.8.

(clang >= 3.4 advertizes itself as GCC >= 4.2 compatible and supports __builtin_expect too)

---
 include/qemu/compiler.h | 4 ----
 1 file changed, 4 deletions(-)
include/qemu/compiler.h +0 -4
index c76281f354..226ead6c90 100644
@@ -44,10 +44,6 @@
 #endif
 
 #ifndef likely
-#if __GNUC__ < 3
-#define __builtin_expect(x, n) (x)
-#endif
-
 #define likely(x)   __builtin_expect(!!(x), 1)
 #define unlikely(x)   __builtin_expect(!!(x), 0)
 #endif
Signature · 1 line
2.29.0
#5 lore raw

Re: [PATCH v3 03/13] compiler.h: remove GCC < 3 __builtin_expect fallback

Quoted 19 lines · On 12/10/20 2:47 PM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Since commit efc6c07 ("configure: Add a test for the minimum compiler version"), QEMU explicitely depends on GCC >= 4.8.

(clang >= 3.4 advertizes itself as GCC >= 4.2 compatible and supports __builtin_expect too)

---
 include/qemu/compiler.h | 4 ----
 1 file changed, 4 deletions(-)
include/qemu/compiler.h +0 -0
index c76281f354..226ead6c90 100644

include/qemu/compiler.h line 49

Quoted 10 lines
include/qemu/compiler.h +0 -4
@@ -44,10 +44,6 @@
 #endif
 
 #ifndef likely
-#if __GNUC__ < 3
-#define __builtin_expect(x, n) (x)
-#endif
-
 #define likely(x)   __builtin_expect(!!(x), 1)
 #define unlikely(x)   __builtin_expect(!!(x), 0)
 #endif

Trying with GCC 10:
warning: implicit declaration of function ‘likely’ [-Wimplicit-function-declaration]

Clang 10:
warning: implicit declaration of function 'likely' is invalid in C99 [-Wimplicit-function-declaration]

Shouldn't it becleaner to test in the configure script or Meson that likely() and unlikely() are not defined, and define them here unconditionally?

Regards,

Phil.

#6 lore raw

Re: [PATCH v3 03/13] compiler.h: remove GCC < 3 __builtin_expect fallback

Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 5 lines · On 12/10/20 2:47 PM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Since commit efc6c07 ("configure: Add a test for the minimum compiler version"), QEMU explicitely depends on GCC >= 4.8.

Quoted 8 lines
Quoted 4 lines

(clang >= 3.4 advertizes itself as GCC >= 4.2 compatible and supports __builtin_expect too)

Shouldn't it becleaner to test in the configure script or Meson that likely() and unlikely() are not defined, and define them here unconditionally?

That sounds like way more infrastructure than we need if just checking "is it already defined" is sufficient...

-- PMM

#7 lore raw

Re: [PATCH v3 03/13] compiler.h: remove GCC < 3 __builtin_expect fallback

Hi

Quoted 12 lines · Peter Maydell
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 8 lines · On 12/10/20 2:47 PM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Since commit efc6c07 ("configure: Add a test for the minimum compiler version"), QEMU explicitely depends on GCC >= 4.8.

(clang >= 3.4 advertizes itself as GCC >= 4.2 compatible and supports __builtin_expect too)

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Shouldn't it becleaner to test in the configure script or Meson that likely() and unlikely() are not defined, and define them here unconditionally?

That sounds like way more infrastructure than we need if just checking "is it already defined" is sufficient...

Eh, I am just removing dead-code "#if __GNUC__ < 3". Further cleanups can be done after.

#8 lore raw

Re: [PATCH v3 03/13] compiler.h: remove GCC < 3 __builtin_expect fallback

In reply to Philippe Mathieu-Daudé
Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 19 lines · On 12/10/20 2:47 PM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Since commit efc6c07 ("configure: Add a test for the minimum compiler version"), QEMU explicitely depends on GCC >= 4.8.

(clang >= 3.4 advertizes itself as GCC >= 4.2 compatible and supports __builtin_expect too)

---
  include/qemu/compiler.h | 4 ----
  1 file changed, 4 deletions(-)
include/qemu/compiler.h +0 -0
index c76281f354..226ead6c90 100644

include/qemu/compiler.h line 49

Quoted 10 lines
include/qemu/compiler.h +0 -4
@@ -44,10 +44,6 @@
  #endif
 
  #ifndef likely
-#if __GNUC__ < 3
-#define __builtin_expect(x, n) (x)
-#endif
-
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x)   __builtin_expect(!!(x), 0)
  #endif

Trying with GCC 10:
warning: implicit declaration of function ‘likely’ [-Wimplicit-function-declaration]

Quoted 7 lines

Clang 10:
warning: implicit declaration of function 'likely' is invalid in C99 [-Wimplicit-function-declaration]

Shouldn't it becleaner to test in the configure script or Meson that likely() and unlikely() are not defined, and define them here unconditionally?

I think the point of the "#ifndef likely" is that some header file (maybe something from Linux?) might be defining them unexpectedly. So it's difficult to do the test at configure/meson time. I would also tend towards removing the #ifndef and seeing if something breaks, but not as part of this series.

Paolo

#9 lore raw

PATCH v3 4/13 qemu-plugin.h: remove GCC < 4

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Since commit efc6c07 ("configure: Add a test for the minimum compiler version"), QEMU explicitely depends on GCC >= 4.8.

(clang >= 3.4 advertizes itself as GCC >= 4.2 compatible)

---
 include/qemu/qemu-plugin.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
include/qemu/qemu-plugin.h +2 -7
index bab8b0d4b3..5775e82c4e 100644
@@ -28,13 +28,8 @@
   #endif
   #define QEMU_PLUGIN_LOCAL
 #else
-  #if __GNUC__ >= 4
-    #define QEMU_PLUGIN_EXPORT __attribute__((visibility("default")))
-    #define QEMU_PLUGIN_LOCAL  __attribute__((visibility("hidden")))
-  #else
-    #define QEMU_PLUGIN_EXPORT
-    #define QEMU_PLUGIN_LOCAL
-  #endif
+  #define QEMU_PLUGIN_EXPORT __attribute__((visibility("default")))
+  #define QEMU_PLUGIN_LOCAL  __attribute__((visibility("hidden")))
 #endif
 
 typedef uint64_t qemu_plugin_id_t;
Signature · 1 line
2.29.0
#10 lore raw

PATCH v3 5/13 tests: remove GCC < 4 fallbacks

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Since commit efc6c07 ("configure: Add a test for the minimum compiler version"), QEMU explicitely depends on GCC >= 4.8.

(clang >= 3.4 advertizes itself as GCC >= 4.2 compatible)

---
 tests/tcg/arm/fcvt.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
tests/tcg/arm/fcvt.c +3 -5
index 617626bc63..7ac47b564e 100644
@@ -73,11 +73,9 @@ static void print_int64(int i, int64_t num)
 
 #ifndef SNANF
 /* Signaling NaN macros, if supported.  */
-# if __GNUC_PREREQ(3, 3)
-#  define SNANF (__builtin_nansf (""))
-#  define SNAN (__builtin_nans (""))
-#  define SNANL (__builtin_nansl (""))
-# endif
+# define SNANF (__builtin_nansf (""))
+# define SNAN (__builtin_nans (""))
+# define SNANL (__builtin_nansl (""))
 #endif
 
 float single_numbers[] = { -SNANF,
Signature · 1 line
2.29.0
#11 lore raw

PATCH v3 6/13 virtiofsd: replace _Static_assert with QEMU_BUILD_BUG_ON

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

This allows to get rid of a check for older GCC version (which was a bit bogus too since it was falling back on c++ version..)

---
 tools/virtiofsd/fuse_common.h | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
tools/virtiofsd/fuse_common.h +1 -10
index 5aee5193eb..a2484060b6 100644
@@ -809,15 +809,6 @@ void fuse_remove_signal_handlers(struct fuse_session *se);
  *
  * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
  */
-
-#if defined(__GNUC__) &&                                      \
-    (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && \
-    !defined __cplusplus
-_Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
-#else
-struct _fuse_off_t_must_be_64bit_dummy_struct {
-    unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1);
-};
-#endif
+QEMU_BUILD_BUG_ON(sizeof(off_t) != 8);
 
 #endif /* FUSE_COMMON_H_ */
Signature · 1 line
2.29.0
Reviewed-by on v3 6/13
#12 lore raw

Re: [PATCH v3 06/13] virtiofsd: replace _Static_assert with QEMU_BUILD_BUG_ON

Quoted 6 lines · * [email protected] ([email protected]) wrote:

From: Marc-André Lureau <[email protected]>

This allows to get rid of a check for older GCC version (which was a bit bogus too since it was falling back on c++ version..)

Yes I think that's OK; this is an imported file, but we've already mangled it into QEMU's style and added includes etc.

Quoted 28 lines
---
 tools/virtiofsd/fuse_common.h | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
tools/virtiofsd/fuse_common.h +1 -10
index 5aee5193eb..a2484060b6 100644
@@ -809,15 +809,6 @@ void fuse_remove_signal_handlers(struct fuse_session *se);
  *
  * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
  */
-
-#if defined(__GNUC__) &&                                      \
-    (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && \
-    !defined __cplusplus
-_Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
-#else
-struct _fuse_off_t_must_be_64bit_dummy_struct {
-    unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1);
-};
-#endif
+QEMU_BUILD_BUG_ON(sizeof(off_t) != 8);
 
 #endif /* FUSE_COMMON_H_ */
Signature · 1 line
2.29.0
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Reviewed-by on v3 6/13
#13 lore raw

Re: [PATCH v3 06/13] virtiofsd: replace _Static_assert with QEMU_BUILD_BUG_ON

In reply to [email protected]
Quoted 9 lines · On Thu, Dec 10, 2020 at 05:47:45PM +0400, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

This allows to get rid of a check for older GCC version (which was a bit bogus too since it was falling back on c++ version..)

---
 tools/virtiofsd/fuse_common.h | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
#14 lore raw

PATCH v3 7/13 compiler.h: explicit case for Clang printf attribute

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Since commit efc6c07 ("configure: Add a test for the minimum compiler version"), QEMU explicitely depends on GCC >= 4.8, we could thus drop earlier version checks. Except clang advertizes itself as GCC 4.2.1.

Since clang doesn't support gnu_printf, make that case explicitely and drop GCC version check.

---
 include/qemu/compiler.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
include/qemu/compiler.h +12 -12
index 226ead6c90..6212295e52 100644
@@ -99,18 +99,18 @@
 #define QEMU_BUILD_BUG_ON_ZERO(x) (sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)) - \
                                    sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)))
 
-#if defined __GNUC__
-# if !QEMU_GNUC_PREREQ(4, 4)
-   /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
-#  define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
-# else
-   /* Use gnu_printf when supported (qemu uses standard format strings). */
-#  define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
-#  if defined(_WIN32)
-    /* Map __printf__ to __gnu_printf__ because we want standard format strings
-     * even when MinGW or GLib include files use __printf__. */
-#   define __printf__ __gnu_printf__
-#  endif
+#if defined(__clang__)
+/* clang doesn't support gnu_printf, so use printf. */
+# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
+#elif defined(__GNUC__)
+/* Use gnu_printf (qemu uses standard format strings). */
+# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
+# if defined(_WIN32)
+/*
+ * Map __printf__ to __gnu_printf__ because we want standard format strings even
+ * when MinGW or GLib include files use __printf__.
+ */
+#  define __printf__ __gnu_printf__
 # endif
 #else
 #define GCC_FMT_ATTR(n, m)
Signature · 1 line
2.29.0
#15 lore raw

Re: [PATCH v3 07/13] compiler.h: explicit case for Clang printf attribute

Quoted 4 lines · 10.12.2020 16:47, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Since clang doesn't support gnu_printf, make that case explicitely and drop GCC version check.

Not a technical comment, - spelling "explicitely", extra "e".

/mjt

#16 lore raw

PATCH v3 8/13 audio: remove GNUC & MSVC check

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

QEMU requires either GCC or Clang, which both advertize __GNUC__. Drop MSVC fallback path.

Note: I intentionally left further cleanups for a later work.

---
 audio/audio.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
audio/audio.c +1 -7
index 46578e4a58..d7a00294de 100644
@@ -122,13 +122,7 @@ int audio_bug (const char *funcname, int cond)
 
 #if defined AUDIO_BREAKPOINT_ON_BUG
 #  if defined HOST_I386
-#    if defined __GNUC__
-        __asm__ ("int3");
-#    elif defined _MSC_VER
-        _asm _emit 0xcc;
-#    else
-        abort ();
-#    endif
+      __asm__ ("int3");
 #  else
         abort ();
 #  endif
Signature · 1 line
2.29.0
#17 lore raw

Re: [PATCH v3 08/13] audio: remove GNUC & MSVC check

Quoted 18 lines · On 12/10/20 2:47 PM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

QEMU requires either GCC or Clang, which both advertize __GNUC__. Drop MSVC fallback path.

Note: I intentionally left further cleanups for a later work.

---
 audio/audio.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
audio/audio.c +0 -0
index 46578e4a58..d7a00294de 100644
@@ -122,13 +122,7 @@ int audio_bug (const char *funcname, int cond)
 

audio/audio.c int audio_bug (const char *funcname, int cond) · line 125

Quoted 10 lines
audio/audio.c +1 -7
 #if defined AUDIO_BREAKPOINT_ON_BUG
 #  if defined HOST_I386
-#    if defined __GNUC__
-        __asm__ ("int3");
-#    elif defined _MSC_VER
-        _asm _emit 0xcc;
-#    else
-        abort ();
-#    endif
+      __asm__ ("int3");

This was 15 years ago... Why not simply use abort() today?

Quoted 4 lines
audio/audio.c +0 -0
 #  else
         abort ();
 #  endif
#18 lore raw

Re: [PATCH v3 08/13] audio: remove GNUC & MSVC check

Quoted 20 lines · Philippe Mathieu-Daudé
Quoted 18 lines · On 12/10/20 2:47 PM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

QEMU requires either GCC or Clang, which both advertize __GNUC__. Drop MSVC fallback path.

Note: I intentionally left further cleanups for a later work.

---
 audio/audio.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
audio/audio.c +0 -0
index 46578e4a58..d7a00294de 100644
@@ -122,13 +122,7 @@ int audio_bug (const char *funcname, int cond)
 
Quoted 12 lines

audio/audio.c int audio_bug (const char *funcname, int cond) · line 125

Quoted 10 lines
audio/audio.c +1 -7
 #if defined AUDIO_BREAKPOINT_ON_BUG
 #  if defined HOST_I386
-#    if defined __GNUC__
-        __asm__ ("int3");
-#    elif defined _MSC_VER
-        _asm _emit 0xcc;
-#    else
-        abort ();
-#    endif
+      __asm__ ("int3");

This was 15 years ago... Why not simply use abort() today?

That's what I suggested when I looked at this patch in the previous version of the patchset, yes...

-- PMM

#19 lore raw

Re: [PATCH v3 08/13] audio: remove GNUC & MSVC check

Quoted 34 lines · Peter Maydell
Quoted 20 lines · Philippe Mathieu-Daudé
Quoted 18 lines · On 12/10/20 2:47 PM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

QEMU requires either GCC or Clang, which both advertize __GNUC__. Drop MSVC fallback path.

Note: I intentionally left further cleanups for a later work.

---
 audio/audio.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
audio/audio.c +0 -0
index 46578e4a58..d7a00294de 100644
@@ -122,13 +122,7 @@ int audio_bug (const char *funcname, int cond)
 
Quoted 12 lines

audio/audio.c int audio_bug (const char *funcname, int cond) · line 125

Quoted 10 lines
audio/audio.c +1 -7
 #if defined AUDIO_BREAKPOINT_ON_BUG
 #  if defined HOST_I386
-#    if defined __GNUC__
-        __asm__ ("int3");
-#    elif defined _MSC_VER
-        _asm _emit 0xcc;
-#    else
-        abort ();
-#    endif
+      __asm__ ("int3");

This was 15 years ago... Why not simply use abort() today?

Quoted 2 lines

That's what I suggested when I looked at this patch in the previous version of the patchset, yes...

Ah, I went back to read v2 thread. Actually I even prefer Gerd's suggestion to remove this dead code.

Regards,

Phil.

#20 lore raw

Re: [PATCH v3 08/13] audio: remove GNUC & MSVC check

Hi

Quoted 36 lines · Philippe Mathieu-Daudé
Quoted 34 lines · Peter Maydell
Quoted 32 lines · Philippe Mathieu-Daudé
Quoted 18 lines · On 12/10/20 2:47 PM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

QEMU requires either GCC or Clang, which both advertize __GNUC__. Drop MSVC fallback path.

Note: I intentionally left further cleanups for a later work.

---
 audio/audio.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
audio/audio.c +0 -0
index 46578e4a58..d7a00294de 100644
@@ -122,13 +122,7 @@ int audio_bug (const char *funcname, int cond)
 

audio/audio.c int audio_bug (const char *funcname, int cond) · line 125

Quoted 10 lines
audio/audio.c +1 -7
 #if defined AUDIO_BREAKPOINT_ON_BUG
 #  if defined HOST_I386
-#    if defined __GNUC__
-        __asm__ ("int3");
-#    elif defined _MSC_VER
-        _asm _emit 0xcc;
-#    else
-        abort ();
-#    endif
+      __asm__ ("int3");

This was 15 years ago... Why not simply use abort() today?

Quoted 6 lines
Quoted 2 lines

That's what I suggested when I looked at this patch in the previous version of the patchset, yes...

Ah, I went back to read v2 thread. Actually I even prefer Gerd's suggestion to remove this dead code.

And I totally agree. However, I don't want to mix concerns. I am just removing dead-code.

#21 lore raw

PATCH v3 9/13 poison: remove GNUC check

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

QEMU requires Clang or GCC, that define and support __GNUC__ extensions

---
 include/exec/poison.h | 2 --
 1 file changed, 2 deletions(-)
include/exec/poison.h +0 -2
index 7b9ac361dc..d7ae1f23e7 100644
@@ -3,7 +3,6 @@
 
 #ifndef HW_POISON_H
 #define HW_POISON_H
-#ifdef __GNUC__
 
 #pragma GCC poison TARGET_I386
 #pragma GCC poison TARGET_X86_64
@@ -93,4 +92,3 @@
 #pragma GCC poison CONFIG_SOFTMMU
 
 #endif
-#endif
Signature · 1 line
2.29.0
Reviewed-by on v3 9/13
#22 lore raw

Re: [PATCH v3 09/13] poison: remove GNUC check

Quoted 9 lines · On 12/10/20 2:47 PM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

QEMU requires Clang or GCC, that define and support __GNUC__ extensions

---
 include/exec/poison.h | 2 --
 1 file changed, 2 deletions(-)
#23 lore raw

PATCH v3 10/13 xen: remove GNUC check

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

QEMU requires Clang or GCC, that define and support __GNUC__ extensions

---
 include/hw/xen/interface/io/ring.h | 9 ---------
 1 file changed, 9 deletions(-)
include/hw/xen/interface/io/ring.h +0 -9
index 5d048b335c..115705f3f4 100644
@@ -206,21 +206,12 @@ typedef struct __name##_back_ring __name##_back_ring_t
 #define RING_HAS_UNCONSUMED_RESPONSES(_r)                               \
     ((_r)->sring->rsp_prod - (_r)->rsp_cons)
 
-#ifdef __GNUC__
 #define RING_HAS_UNCONSUMED_REQUESTS(_r) ({                             \
     unsigned int req = (_r)->sring->req_prod - (_r)->req_cons;          \
     unsigned int rsp = RING_SIZE(_r) -                                  \
         ((_r)->req_cons - (_r)->rsp_prod_pvt);                          \
     req < rsp ? req : rsp;                                              \
 })
-#else
-/* Same as above, but without the nice GCC ({ ... }) syntax. */
-#define RING_HAS_UNCONSUMED_REQUESTS(_r)                                \
-    ((((_r)->sring->req_prod - (_r)->req_cons) <                        \
-      (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ?        \
-     ((_r)->sring->req_prod - (_r)->req_cons) :                         \
-     (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt)))
-#endif
 
 /* Direct access to individual ring elements, by index. */
 #define RING_GET_REQUEST(_r, _idx)                                      \
Signature · 1 line
2.29.0
#24 lore raw

PATCH v3 11/13 compiler: remove GNUC check

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

QEMU requires Clang or GCC, that define and support __GNUC__ extensions.

---
 include/qemu/compiler.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
include/qemu/compiler.h +1 -7
index 6212295e52..5e6cf2c8e8 100644
@@ -64,14 +64,10 @@
     (offsetof(container, field) + sizeof_field(container, field))
 
 /* Convert from a base type to a parent type, with compile time checking.  */
-#ifdef __GNUC__
 #define DO_UPCAST(type, field, dev) ( __extension__ ( { \
     char __attribute__((unused)) offset_must_be_zero[ \
         -offsetof(type, field)]; \
     container_of(dev, type, field);}))
-#else
-#define DO_UPCAST(type, field, dev) container_of(dev, type, field)
-#endif
 
 #define typeof_field(type, field) typeof(((type *)0)->field)
 #define type_check(t1,t2) ((t1*)0 - (t2*)0)
@@ -102,7 +98,7 @@
 #if defined(__clang__)
 /* clang doesn't support gnu_printf, so use printf. */
 # define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
-#elif defined(__GNUC__)
+#else
 /* Use gnu_printf (qemu uses standard format strings). */
 # define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
 # if defined(_WIN32)
@@ -112,8 +108,6 @@
  */
 #  define __printf__ __gnu_printf__
 # endif
-#else
-#define GCC_FMT_ATTR(n, m)
 #endif
 
 #ifndef __has_warning
Signature · 1 line
2.29.0
#25 lore raw

Re: [PATCH v3 11/13] compiler: remove GNUC check

Quoted 48 lines · On Thu, Dec 10, 2020 at 6:14 PM <[email protected]> wrote:

From: Marc-André Lureau <[email protected]>

QEMU requires Clang or GCC, that define and support __GNUC__ extensions.

---
 include/qemu/compiler.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
include/qemu/compiler.h +0 -0
index 6212295e52..5e6cf2c8e8 100644
@@ -64,14 +64,10 @@
     (offsetof(container, field) + sizeof_field(container, field))
 
 /* Convert from a base type to a parent type, with compile time

checking. */

include/qemu/compiler.h +1 -8
-#ifdef __GNUC__
 #define DO_UPCAST(type, field, dev) ( __extension__ ( { \
     char __attribute__((unused)) offset_must_be_zero[ \
         -offsetof(type, field)]; \
     container_of(dev, type, field);}))
-#else
-#define DO_UPCAST(type, field, dev) container_of(dev, type, field)
-#endif
 
 #define typeof_field(type, field) typeof(((type *)0)->field)
 #define type_check(t1,t2) ((t1*)0 - (t2*)0)
@@ -102,7 +98,7 @@
 #if defined(__clang__)
 /* clang doesn't support gnu_printf, so use printf. */
 # define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
-#elif defined(__GNUC__)
+#else
 /* Use gnu_printf (qemu uses standard format strings). */
 # define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
 # if defined(_WIN32)
@@ -112,8 +108,6 @@
  */
 #  define __printf__ __gnu_printf__
 # endif
-#else
-#define GCC_FMT_ATTR(n, m)
 #endif
 
 #ifndef __has_warning
--
Quoted 4 lines

2.29.0

Peter, Paolo, anyone to give a review?
thanks

Signature · 1 line
Marc-André Lureau
Reviewed-by on v3 11/13
#26 lore raw

Re: [PATCH v3 11/13] compiler: remove GNUC check

In reply to [email protected]
Quoted 9 lines · On Thu, 10 Dec 2020 at 13:50, <[email protected]> wrote:

From: Marc-André Lureau <[email protected]>

QEMU requires Clang or GCC, that define and support __GNUC__ extensions.

---
 include/qemu/compiler.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

thanks
-- PMM

#27 lore raw

PATCH v3 12/13 linux-user: remove GNUC check

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

QEMU requires Clang or GCC, that define and support __GNUC__ extensions.

---
 linux-user/strace.c | 4 ----
 1 file changed, 4 deletions(-)
linux-user/strace.c +0 -4
index 11fea14fba..e00275fcb5 100644
@@ -24,7 +24,6 @@ struct syscallname {
                    abi_long, abi_long, abi_long);
 };
 
-#ifdef __GNUC__
 /*
  * It is possible that target doesn't have syscall that uses
  * following flags but we don't want the compiler to warn
@@ -32,9 +31,6 @@ struct syscallname {
  * functions.  It is ok to keep them while not used.
  */
 #define UNUSED __attribute__ ((unused))
-#else
-#define UNUSED
-#endif
 
 /*
  * Structure used to translate flag values into strings.  This is
Signature · 1 line
2.29.0
Reviewed-by on v3 12/13
#28 lore raw

Re: [PATCH v3 12/13] linux-user: remove GNUC check

Quoted 9 lines · On 12/10/20 2:47 PM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

QEMU requires Clang or GCC, that define and support __GNUC__ extensions.

---
 linux-user/strace.c | 4 ----
 1 file changed, 4 deletions(-)
#29 lore raw

PATCH v3 13/13 compiler.h: remove QEMU_GNUC_PREREQ

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

When needed, the G_GNUC_CHECK_VERSION() glib macro can be used instead.

---
 include/qemu/compiler.h    | 11 -----------
 scripts/cocci-macro-file.h |  1 -
 2 files changed, 12 deletions(-)
include/qemu/compiler.h +0 -11
index 5e6cf2c8e8..1b9e58e82b 100644
@@ -11,17 +11,6 @@
 #define QEMU_STATIC_ANALYSIS 1
 #endif
 
-/*----------------------------------------------------------------------------
-| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler.
-| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h.
-*----------------------------------------------------------------------------*/
-#if defined(__GNUC__) && defined(__GNUC_MINOR__)
-# define QEMU_GNUC_PREREQ(maj, min) \
-         ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-#else
-# define QEMU_GNUC_PREREQ(maj, min) 0
-#endif
-
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
 
 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
scripts/cocci-macro-file.h +0 -1
index c6bbc05ba3..20eea6b708 100644
@@ -19,7 +19,6 @@
  */
 
 /* From qemu/compiler.h */
-#define QEMU_GNUC_PREREQ(maj, min) 1
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
 #define QEMU_SENTINEL __attribute__((sentinel))
Signature · 1 line
2.29.0
#30 lore raw

Re: [PATCH v3 13/13] compiler.h: remove QEMU_GNUC_PREREQ

Hi

Quoted 41 lines · On Thu, Dec 10, 2020 at 6:07 PM <[email protected]> wrote:

From: Marc-André Lureau <[email protected]>

When needed, the G_GNUC_CHECK_VERSION() glib macro can be used instead.

---
 include/qemu/compiler.h    | 11 -----------
 scripts/cocci-macro-file.h |  1 -
 2 files changed, 12 deletions(-)
include/qemu/compiler.h +0 -2
index 5e6cf2c8e8..1b9e58e82b 100644
@@ -11,17 +11,6 @@
 #define QEMU_STATIC_ANALYSIS 1
 #endif
 
 
-/*----------------------------------------------------------------------------
-| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C

compiler.
-| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h.

include/qemu/compiler.h +0 -8
-*----------------------------------------------------------------------------*/
-#if defined(__GNUC__) && defined(__GNUC_MINOR__)
-# define QEMU_GNUC_PREREQ(maj, min) \
-         ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-#else
-# define QEMU_GNUC_PREREQ(maj, min) 0
-#endif
-
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
 
 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
scripts/cocci-macro-file.h +0 -0
index c6bbc05ba3..20eea6b708 100644

scripts/cocci-macro-file.h line 24

Quoted 7 lines
scripts/cocci-macro-file.h +0 -1
@@ -19,7 +19,6 @@
  */
 
 /* From qemu/compiler.h */
-#define QEMU_GNUC_PREREQ(maj, min) 1
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
 #define QEMU_SENTINEL __attribute__((sentinel))

ping, thanks

Signature · 1 line
Marc-André Lureau
#31 lore raw
In reply to [email protected]
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH v3 00/13] Remove GCC < 4.8 checks

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu

   5e7b204..180834d  master     -> master
 - [tag update]      patchew/[email protected] -> patchew/[email protected]
 - [tag update]      patchew/[email protected] -> patchew/[email protected]
 * [new tag]         patchew/[email protected] -> patchew/[email protected]
 * [new tag]         patchew/[email protected] -> patchew/[email protected]

Switched to a new branch 'test'
778a2e3 compiler.h: remove QEMU_GNUC_PREREQ
0a3f410 linux-user: remove GNUC check
9678c1e compiler: remove GNUC check
a0138f8 xen: remove GNUC check
40f3170 poison: remove GNUC check
b80f5cb audio: remove GNUC & MSVC check
b635f5f compiler.h: explicit case for Clang printf attribute d52f3c4 virtiofsd: replace _Static_assert with QEMU_BUILD_BUG_ON 9bbe2a0 tests: remove GCC < 4 fallbacks
7c330cb qemu-plugin.h: remove GCC < 4
434de5d compiler.h: remove GCC < 3 __builtin_expect fallback 0699e78 accel/tcg: Remove special case for GCC < 4.6 03e2318 qemu/atomic: Drop special case for unsupported compiler

=== OUTPUT BEGIN ===
1/13 Checking commit 03e23183fb55 (qemu/atomic: Drop special case for unsupported compiler) 2/13 Checking commit 0699e78a25fb (accel/tcg: Remove special case for GCC < 4.6)
WARNING: architecture specific defines should be avoided
#30: FILE: accel/tcg/cpu-exec.c:727:
+#if defined(__clang__)

total: 0 errors, 1 warnings, 8 lines checked

Patch 2/13 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/13 Checking commit 434de5d2441a (compiler.h: remove GCC < 3 __builtin_expect fallback) 4/13 Checking commit 7c330cb6e44c (qemu-plugin.h: remove GCC < 4)
5/13 Checking commit 9bbe2a00a228 (tests: remove GCC < 4 fallbacks)
ERROR: space prohibited between function name and open parenthesis '(' #30: FILE: tests/tcg/arm/fcvt.c:76:
+# define SNANF (__builtin_nansf (""))

ERROR: space prohibited between function name and open parenthesis '(' #31: FILE: tests/tcg/arm/fcvt.c:77:
+# define SNAN (__builtin_nans (""))

ERROR: space prohibited between function name and open parenthesis '(' #32: FILE: tests/tcg/arm/fcvt.c:78:
+# define SNANL (__builtin_nansl (""))

total: 3 errors, 0 warnings, 14 lines checked

Patch 5/13 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

6/13 Checking commit d52f3c49e7f8 (virtiofsd: replace _Static_assert with QEMU_BUILD_BUG_ON) 7/13 Checking commit b635f5f0f1c0 (compiler.h: explicit case for Clang printf attribute)
WARNING: architecture specific defines should be avoided
#38: FILE: include/qemu/compiler.h:102:
+#if defined(__clang__)

total: 0 errors, 1 warnings, 30 lines checked

Patch 7/13 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
8/13 Checking commit b80f5cb153ae (audio: remove GNUC & MSVC check) 9/13 Checking commit 40f31706c554 (poison: remove GNUC check) 10/13 Checking commit a0138f8b8ca1 (xen: remove GNUC check) 11/13 Checking commit 9678c1e1b0d8 (compiler: remove GNUC check) 12/13 Checking commit 0a3f4102bcfa (linux-user: remove GNUC check) 13/13 Checking commit 778a2e31c5ce (compiler.h: remove QEMU_GNUC_PREREQ) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#32 lore raw
In reply to [email protected]
Quoted 39 lines · On 10/12/20 14:47, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Hi,

Since commit efc6c07 ("configure: Add a test for the minimum compiler version"), QEMU explicitely depends on GCC >= 4.8.

v3:
- drop first patch replacing QEMU_GNUC_PREREQ with G_GNUC_CHECK_VERSION
- add last patch to remove QEMU_GNUC_PREREQ
- tweak commit messages to replace clang 3.8 with clang 3.4
- fix some extra coding style
- collect r-b/a-b tags

v2:
- include reviewed Philippe earlier series
- drop problematic patch to replace GCC_FMT_ATTR, but tweak the check to be clang
- replace QEMU_GNUC_PREREQ with G_GNUC_CHECK_VERSION
- split changes
- add patches to drop __GNUC__ checks (clang advertizes itself as 4.2.1, unless

    -fgnuc-version=0)

Marc-André Lureau (11):
compiler.h: remove GCC < 3 __builtin_expect fallback qemu-plugin.h: remove GCC < 4
tests: remove GCC < 4 fallbacks
virtiofsd: replace _Static_assert with QEMU_BUILD_BUG_ON compiler.h: explicit case for Clang printf attribute
audio: remove GNUC & MSVC check
poison: remove GNUC check
xen: remove GNUC check
compiler: remove GNUC check
linux-user: remove GNUC check
compiler.h: remove QEMU_GNUC_PREREQ

Philippe Mathieu-Daudé (2):
qemu/atomic: Drop special case for unsupported compiler accel/tcg: Remove special case for GCC < 4.6

Quoted 13 lines
  include/exec/poison.h              |  2 --
  include/hw/xen/interface/io/ring.h |  9 ------
  include/qemu/atomic.h              | 17 -----------
  include/qemu/compiler.h            | 45 ++++++++----------------------
  include/qemu/qemu-plugin.h         |  9 ++----
  scripts/cocci-macro-file.h         |  1 -
  tools/virtiofsd/fuse_common.h      | 11 +-------
  accel/tcg/cpu-exec.c               |  2 +-
  audio/audio.c                      |  8 +-----
  linux-user/strace.c                |  4 ---
  tests/tcg/arm/fcvt.c               |  8 ++----
  11 files changed, 20 insertions(+), 96 deletions(-)

Queued, thanks.

Paolo