Assume GCC v4.8 and Clang v3.4 as minimum compiler
Subsystems (2)
v2 cover Assume GCC v4.8 and Clang v3.4 as minimum compiler
It's unlikely that any of the developers still uses an older version than GCC 4.8 or Clang 3.4, since all supported distributions have at least these versions nowadays, so let's add a proper sanity check for these versions and get rid of code that is only there for older versions.
Note: I did not remove all "#if QEMU_GNUC_PREREQ(4, <8)" checks yet since some of them still apply to Clang, which reports itself as GCC 4.2. We should replace those checks with proper checks for the Clang version instead, in case newer versions of Clang support the corresponding feature - but that needs some time-consuming research first which I'll only start if this patch series gets accepted first.
v2:
- Don't remove CONFIG_INT128 sections, they are still required for 32-bit hosts
- Check for Apple's Xcode version of Clang
Thomas Huth (7):
configure: Add a test for the minimum compiler version
configure: Remove obsolete check for Clang < 3.2
configure: Remove old -fno-gcse workaround for GCC 4.6.x and 4.7.[012] tcg/tcg.h: Remove GCC check for tcg_debug_assert() macro audio/alsaaudio: Remove compiler check around pragma
includes: Replace QEMU_GNUC_PREREQ with "__has_builtin ||
!defined(__clang__)"
Remove QEMU_ARTIFICIAL macro
Makefile.target | 3 --- audio/alsaaudio.c | 2 -- configure | 57 ++++++++++++++++++++-------------------------- include/qemu/compiler.h | 8 +------ include/qemu/host-utils.h | 4 ++-- scripts/checkpatch.pl | 1 - scripts/cocci-macro-file.h | 1 - tcg/tcg.h | 4 +--- 8 files changed, 29 insertions(+), 51 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/7 configure: Add a test for the minimum compiler version
So far we only had implicit requirements for the minimum compiler version, e.g. we require at least GCC 4.1 for the support of atomics. However, such old compiler versions are not tested anymore by the developers, so they are not really supported anymore. Since we recently declared explicitly what platforms we intend to support, we can also get more explicit on the compiler version now. The supported distributions use the following version of GCC:
RHEL-7: 4.8.5
Debian (Stretch): 6.3.0
Debian (Jessie): 4.8.4
OpenBSD (ports): 4.9.4
FreeBSD (ports): 8.2.0
OpenSUSE Leap 15: 7.3.1
Ubuntu (Xenial): 5.3.1
macOS (Homebrew): 8.2.0So we can safely assume GCC 4.8 these days. For Clang, the situation is a little bit more ambiguous, since it is sometimes not available in the main distros but rather third party repositories. At least Debian Jessie uses version 3.5, and EPEL7 for RHEL7 uses 3.4, so let's use 3.4 as minimum Clang version now - we still can adjust this later if necessary.
Unfortunately Apple uses different version numbers for the Clang that is included in their Xcode suite, so we need to check the version numbers for Xcode separately. Xcode 5.1 seems to be the first one that has been shipped with LLVM 3.4, so use this version as the minimum there.
--- configure | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
configure +25 -0
@@ -1840,6 +1840,31 @@ if test "$bogus_os" = "yes"; then error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" fi +# Check whether the compiler matches our minimum requirements: +cat > $TMPC << EOF +#if defined(__clang_major__) && defined(__clang_minor__) +# ifdef __apple_build_version__ +# if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1) +# error You need at least XCode Clang v5.1 to compile QEMU +# endif +# else +# if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4) +# error You need at least Clang v3.4 to compile QEMU +# endif +# endif +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8) +# error You need at least GCC v4.8 to compile QEMU +# endif +#else +# error You either need GCC or Clang to compiler QEMU +#endif +int main (void) { return 0; } +EOF +if ! compile_prog "" "" ; then + error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)" +fi + gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits" gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags" gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH for-4.0 v2 1/7] configure: Add a test for the minimum compiler version
Quoted 14 lines · Thomas Huth
configure +14
-0+# Check whether the compiler matches our minimum requirements: +cat > $TMPC << EOF +#if defined(__clang_major__) && defined(__clang_minor__) +# ifdef __apple_build_version__ +# if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1) +# error You need at least XCode Clang v5.1 to compile QEMU +# endif +# else +# if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4) +# error You need at least Clang v3.4 to compile QEMU +# endif +# endif +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
configure if test "$bogus_os" = "yes"; then · line 1866
Quoted 10 lines
configure +10
-0+# error You need at least GCC v4.8 to compile QEMU +# endif +#else +# error You either need GCC or Clang to compiler QEMU +#endif +int main (void) { return 0; } +EOF +if ! compile_prog "" "" ; then + error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)" +fi
I wonder if we could capture the actual error message that you used during the test and feed that back to the user. That said,
r~
PATCH v2 2/7 configure: Remove obsolete check for Clang < 3.2
In reply to Thomas HuthSince we have got a check for Clang >= 3.4 now, we do not need to check for older Clang versions in the configure test for 128-bit ints anymore.
--- configure | 5 ----- 1 file changed, 5 deletions(-)
configure +0 -5
@@ -5148,11 +5148,6 @@ fi int128=no cat > $TMPC << EOF -#if defined(__clang_major__) && defined(__clang_minor__) -# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2)) -# error __int128_t does not work in CLANG before 3.2 -# endif -#endif __int128_t a; __uint128_t b; int main (void) {
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH for-4.0 v2 2/7] configure: Remove obsolete check for Clang < 3.2
Quoted 8 lines · Thomas Huth
Since we have got a check for Clang >= 3.4 now, we do not need to check for older Clang versions in the configure test for 128-bit ints anymore.
Signed-off-by Thomas Huth <[email protected]>--- configure | 5 ----- 1 file changed, 5 deletions(-)
r~
PATCH v2 3/7 configure: Remove old -fno-gcse workaround for GCC 4.6.x and 4.7.[012]
In reply to Thomas HuthNow that we require at least GCC 4.8, we don't need this als workaround for 4.6 and 4.7 anymore.
--- Makefile.target | 3 --- configure | 27 --------------------------- 2 files changed, 30 deletions(-)
Makefile.target +0 -3
@@ -158,9 +158,6 @@ GENERATED_FILES += hmp-commands.h hmp-commands-info.h endif # CONFIG_SOFTMMU -# Workaround for http://gcc.gnu.org/PR55489, see configure. -%/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS) - dummy := $(call unnest-vars,,obj-y) all-obj-y := $(obj-y)
configure +0 -27
@@ -1936,32 +1936,6 @@ else QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" fi -# Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and -# large functions that use global variables. The bug is in all releases of -# GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in -# 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013. -cat > $TMPC << EOF -#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2)) -int main(void) { return 0; } -#else -#error No bug in this compiler. -#endif -EOF -if compile_prog "-Werror -fno-gcse" "" ; then - TRANSLATE_OPT_CFLAGS=-fno-gcse -fi - -if test "$static" = "yes" ; then - if test "$modules" = "yes" ; then - error_exit "static and modules are mutually incompatible" - fi - if test "$pie" = "yes" ; then - error_exit "static and pie are mutually incompatible" - else - pie="no" - fi -fi - # Unconditional check for compiler __thread support cat > $TMPC << EOF static __thread int tls_var;
@@ -6983,7 +6957,6 @@ echo "LIBS_QGA+=$libs_qga" >> $config_host_mak echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak echo "POD2MAN=$POD2MAN" >> $config_host_mak -echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak if test "$gcov" = "yes" ; then echo "CONFIG_GCOV=y" >> $config_host_mak echo "GCOV=$gcov_tool" >> $config_host_mak
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH for-4.0 v2 3/7] configure: Remove old -fno-gcse workaround for GCC 4.6.x and 4.7.[012]
Quoted 47 lines · Thomas Huth
Now that we require at least GCC 4.8, we don't need this als workaround for 4.6 and 4.7 anymore.
Reviewed-by Richard Henderson <[email protected]>Signed-off-by Thomas Huth <[email protected]>--- Makefile.target | 3 --- configure | 27 --------------------------- 2 files changed, 30 deletions(-)Makefile.target +0
-3@@ -158,9 +158,6 @@ GENERATED_FILES += hmp-commands.h hmp-commands-info.h endif # CONFIG_SOFTMMU -# Workaround for http://gcc.gnu.org/PR55489, see configure. -%/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS) - dummy := $(call unnest-vars,,obj-y) all-obj-y := $(obj-y)configure +0
-15@@ -1936,32 +1936,6 @@ else QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" fi -# Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and -# large functions that use global variables. The bug is in all releases of -# GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in -# 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013. -cat > $TMPC << EOF -#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2)) -int main(void) { return 0; } -#else -#error No bug in this compiler. -#endif -EOF -if compile_prog "-Werror -fno-gcse" "" ; then - TRANSLATE_OPT_CFLAGS=-fno-gcse -fi -
configure else · line 1963
Quoted 10 lines
configure +0
-10-if test "$static" = "yes" ; then - if test "$modules" = "yes" ; then - error_exit "static and modules are mutually incompatible" - fi - if test "$pie" = "yes" ; then - error_exit "static and pie are mutually incompatible" - else - pie="no" - fi -fi
For the records: I just noticed that the last 10 lines do not belong to the gcse workaround - I'll remove them from the patch again.
Thomas
PATCH v2 4/7 tcg/tcg.h: Remove GCC check for tcg_debug_assert() macro
In reply to Thomas HuthBoth GCC v4.8 and Clang v3.4 support (our minimum versions) support __builtin_unreachable(), so we can remove the version check here now.
--- tcg/tcg.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tcg/tcg.h +1 -3
@@ -230,11 +230,9 @@ typedef uint64_t tcg_insn_unit;#if definedCONFIG_DEBUG_TCG || definedQEMU_STATIC_ANALYSIS # define tcg_debug_assert (X ) do { assert(X); } while (0) -#elif QEMU_GNUC_PREREQ (4 ,5 ) +#else # define tcg_debug_assert (X ) \ do { if (!(X)) { __builtin_unreachable(); } } while (0) -#else -# define tcg_debug_assert (X ) do { (void)(X); } while (0)#endif typedef struct TCGRelocation {
Signature · 1 line
1.8.3.1
PATCH v2 5/7 audio/alsaaudio: Remove compiler check around pragma
In reply to Thomas HuthBoth GCC v4.8 and Clang v3.4 support the -Waddress option, so we do not need the compiler version check here anymore.
--- audio/alsaaudio.c | 2 -- 1 file changed, 2 deletions(-)
audio/alsaaudio.c +0 -2
@@ -28,9 +28,7 @@#include "audio.h" #include "trace.h" -#if QEMU_GNUC_PREREQ (4 ,3 )#pragma GCC diagnostic ignored "-Waddress" -#endif #define AUDIO_CAP "alsa"#include "audio_int.h"
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH for-4.0 v2 5/7] audio/alsaaudio: Remove compiler check around pragma
Quoted 7 lines · Thomas Huth
Both GCC v4.8 and Clang v3.4 support the -Waddress option, so we do not need the compiler version check here anymore.
Signed-off-by Thomas Huth <[email protected]>--- audio/alsaaudio.c | 2 -- 1 file changed, 2 deletions(-)
r~
PATCH v2 6/7 includes: Replace QEMU_GNUC_PREREQ with "__has_builtin || !defined(__clang__)"
In reply to Thomas HuthSince we require GCC version 4.8 or newer now, we can be sure that the builtin functions are always available on GCC. And for Clang, we can check the availablility with __has_builtin instead.
--- include/qemu/compiler.h | 2 +- include/qemu/host-utils.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
include/qemu/compiler.h +1 -1
@@ -127,7 +127,7 @@#define __has_builtin (x) 0/* compatibility with non-clang compilers */ #endif -#if __has_builtin (__builtin_assume_aligned) ||QEMU_GNUC_PREREQ (4 ,7 ) +#if __has_builtin (__builtin_assume_aligned) || !defined(__clang__)#define HAS_ASSUME_ALIGNED #endif
include/qemu/host-utils.h +2 -2
@@ -207,7 +207,7 @@ static inline int cto64(uint64_t val)*/ static inline int clrsb32 (uint32_t val) { -#if QEMU_GNUC_PREREQ (4 ,7 ) +#if __has_builtin (__builtin_clrsb) || !defined(__clang__)return __builtin_clrsb (val);#else return clz32 (val ^ ((int32_t )val >>1 )) -1 ;
@@ -223,7 +223,7 @@ static inline int clrsb32(uint32_t val)*/ static inline int clrsb64 (uint64_t val) { -#if QEMU_GNUC_PREREQ (4 ,7 ) +#if __has_builtin (__builtin_clrsbll) || !defined(__clang__)return __builtin_clrsbll (val);#else return clz64 (val ^ ((int64_t )val >>1 )) -1 ;
Signature · 1 line
1.8.3.1
PATCH v2 7/7 Remove QEMU_ARTIFICIAL macro
In reply to Thomas HuthThe code that used it has already been removed a while ago with commit dc41aa7d34989b552ef ("tcg: Remove GET_TCGV_* and MAKE_TCGV_*").
--- include/qemu/compiler.h | 6 ------ scripts/checkpatch.pl | 1 - scripts/cocci-macro-file.h | 1 - 3 files changed, 8 deletions(-)
include/qemu/compiler.h +0 -6
@@ -28,12 +28,6 @@#define QEMU_SENTINEL __attribute__((sentinel)) -#if QEMU_GNUC_PREREQ (4 ,3 ) -#define QEMU_ARTIFICIAL __attribute__((always_inline, artificial)) -#else -#define QEMU_ARTIFICIAL -#endif -#if defined(_WIN32)# define QEMU_PACKED __attribute__((gcc_struct, packed))#else
scripts/checkpatch.pl +0 -1
@@ -202,7 +202,6 @@ our $Attribute = qr{ QEMU_NORETURN| QEMU_WARN_UNUSED_RESULT| QEMU_SENTINEL| - QEMU_ARTIFICIAL| QEMU_PACKED| GCC_FMT_ATTR }x;
scripts/cocci-macro-file.h +0 -1
@@ -23,7 +23,6 @@#define QEMU_NORETURN __attribute__ ((__noreturn__))#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))#define QEMU_SENTINEL __attribute__((sentinel)) -#define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))#define QEMU_PACKED __attribute__((gcc_struct, packed))#define cat (x,y) x ## y
Signature · 1 line
1.8.3.1