Remove GCC < 4.8 checks
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 >=3D 4.8.
Marc-Andr=C3=A9 Lureau (2):
Remove GCC version checks (all < 4.8)
compiler.h: remove QEMU_GNUC_PREREQ macro
include/qemu/atomic.h | 17 ----------------- include/qemu/compiler.h | 33 ++++++--------------------------- include/qemu/qemu-plugin.h | 9 ++------- scripts/cocci-macro-file.h | 1 - tools/virtiofsd/fuse_common.h | 4 +--- accel/tcg/cpu-exec.c | 2 +- tests/tcg/arm/fcvt.c | 8 +++----- 7 files changed, 13 insertions(+), 61 deletions(-)
--=20
2.29.0
PATCH 1/2 Remove GCC version checks (all < 4.8)
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.
--- include/qemu/atomic.h | 17 ----------------- include/qemu/compiler.h | 22 ++++++---------------- include/qemu/qemu-plugin.h | 9 ++------- tools/virtiofsd/fuse_common.h | 4 +--- accel/tcg/cpu-exec.c | 2 +- tests/tcg/arm/fcvt.c | 8 +++----- 6 files changed, 13 insertions(+), 49 deletions(-)
include/qemu/atomic.h +0 -17
@@ -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
include/qemu/compiler.h +6 -16
@@ -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
@@ -104,20 +100,14 @@ 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 +# 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) +# define GCC_FMT_ATTR (n, m)#endif #ifndef __has_warning
include/qemu/qemu-plugin.h +2 -7
@@ -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 ;
tools/virtiofsd/fuse_common.h +1 -3
@@ -810,9 +810,7 @@ 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 +#if defined(__GNUC__) && !defined __cplusplus_Static_assert (sizeof (off_t) ==8 ,"fuse: off_t must be 64bit" );#else struct _fuse_off_t_must_be_64bit_dummy_struct {
accel/tcg/cpu-exec.c +1 -1
@@ -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.
tests/tcg/arm/fcvt.c +3 -5
@@ -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
PATCH 2/2 compiler.h: remove QEMU_GNUC_PREREQ macro
In reply to [email protected]From: Marc-André Lureau <[email protected]>
(eventually, future checks could be done with G_GNUC_CHECK_VERSION)
--- include/qemu/compiler.h | 11 ----------- scripts/cocci-macro-file.h | 1 - 2 files changed, 12 deletions(-)
include/qemu/compiler.h +0 -11
@@ -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
@@ -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
Quoted 4 lines · On Tue, Nov 24, 2020 at 4:54 PM <[email protected]> wrote:
From: Marc-André Lureau <[email protected]>
Hi,
Quoted 9 lines
Since commit efc6c07 ("configure: Add a test for the minimum compiler version=
"),
QEMU explicitely depends on GCC >=3D 4.8.Marc-Andr=C3=A9 Lureau (2):
Remove GCC version checks (all < 4.8)
compiler.h: removeQEMU_GNUC_PREREQmacro
There is some double-encoding going on with my cover letters, lovely...
Quoted 15 lines
include/qemu/atomic.h | 17 ----------------- include/qemu/compiler.h | 33 ++++++--------------------------- include/qemu/qemu-plugin.h | 9 ++------- scripts/cocci-macro-file.h | 1 - tools/virtiofsd/fuse_common.h | 4 +--- accel/tcg/cpu-exec.c | 2 +- tests/tcg/arm/fcvt.c | 8 +++----- 7 files changed, 13 insertions(+), 61 deletions(-)--=20
2.29.0
Signature · 1 line
Marc-André Lureau
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 0/2] 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
- [tag update] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
c9fd76f compiler.h: remove QEMU_GNUC_PREREQ macro
4428f55 Remove GCC version checks (all < 4.8)
=== OUTPUT BEGIN ===
1/2 Checking commit 4428f552871c (Remove GCC version checks (all < 4.8))
WARNING: architecture specific defines should be avoided #22: FILE: accel/tcg/cpu-exec.c:727:
+#if defined(__clang__)
WARNING: Block comments use a leading /* on a separate line #86: FILE: include/qemu/compiler.h:105:
+ /* Map __printf__ to __gnu_printf__ because we want standard format strings
WARNING: Block comments use a trailing */ on a separate line #87: FILE: include/qemu/compiler.h:106:
+ * even when MinGW or GLib include files use __printf__. */
ERROR: space prohibited between function name and open parenthesis '(' #129: FILE: tests/tcg/arm/fcvt.c:76:
+# define SNANF (__builtin_nansf (""))
ERROR: space prohibited between function name and open parenthesis '(' #130: FILE: tests/tcg/arm/fcvt.c:77:
+# define SNAN (__builtin_nans (""))
ERROR: space prohibited between function name and open parenthesis '(' #131: FILE: tests/tcg/arm/fcvt.c:78:
+# define SNANL (__builtin_nansl (""))
WARNING: architecture specific defines should be avoided #146: FILE: tools/virtiofsd/fuse_common.h:813:
+#if defined(__GNUC__) && !defined __cplusplus
total: 3 errors, 4 warnings, 106 lines checked
Patch 1/2 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
2/2 Checking commit c9fd76f82866 (compiler.h: remove QEMU_GNUC_PREREQ macro) === 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]
Quoted 8 lines · On Tue, 24 Nov 2020 at 12:52, <[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.
You need to be a bit cautious about removing QEMU_GNUC_PREREQ() checks, because clang advertises itself as GCC 4.2 via the __GNUC__ and __GNUC_MINOR__ macros that QEMU_GNUC_PREREQ() tests, and so unless the code has explicitly handled clang via a different ifdef or feature test clang will be using the fallback codepath in cases like this. So you also need to find out whether all our supported versions of clang are OK with the gcc-4.4-and-up version of the code before removing any particular ifdef.
Compare this previous (not-applied) patchset from Philippe:
https://patchew.org/QEMU/[email protected]/
which dealt with two of these ifdefs, one of which is "clearly OK" and the other of which is "needs more analysis". The path forward I think is along those lines -- we need one patch per ifdef we're trying to remove, and the commit message can then include the information about why in this case it is OK for clang too (or switch the ifdef to check for something else, eg one of clang's feature-specific test macros).
thanks
-- PMM
Quoted 21 lines · Peter Maydell
Quoted 6 lines · On Tue, 24 Nov 2020 at 12:52, <[email protected]> wrote:
From: Marc-André Lureau <[email protected]>
Hi,
Since commit efc6c07 ("configure: Add a test for the minimum compiler
version=
Quoted 2 lines
"),
QEMU explicitely depends on GCC >= 4.8.You need to be a bit cautious about removing
QEMU_GNUC_PREREQ()checks, because clang advertises itself as GCC 4.2 via the__GNUC__and__GNUC_MINOR__macros thatQEMU_GNUC_PREREQ()tests, and so unless the code has explicitly handled clang via a different ifdef or feature test clang will be using the fallback codepath in cases like this. So you also need to find out whether all our supported versions of clang are OK with the gcc-4.4-and-up version of the code before removing any particular ifdef.
Quoted 11 lines
Compare this previous (not-applied) patchset from Philippe:
https://patchew.org/QEMU/[email protected]/
which dealt with two of these ifdefs, one of which is "clearly OK" and the other of which is "needs more analysis". The path forward I think is along those lines -- we need one patch per ifdef we're trying to remove, and the commit message can then include the information about why in this case it is OK for clang too (or switch the ifdef to check for something else, eg one of clang's feature-specific test macros).
Thanks for pointing out the series, I missed it. Ok, I'll try to do some more research.
Signature · 1 line
Marc-André Lureau