lkml.org 
[lkml]   [2014]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] gcc: clamp gcc version to most highest specific header version available
Date
As announced in [1] gcc will increase its major number yearly but we don't
need to include gcc version specific quirks for every version normally.

This patch allows to compile every kernel with all new versions of gcc
without adding a specific compiler-gccX.h header. We do so by clamping
the __GNUC__ version to the most specific version dependent header file.

If someone adds a new gccX.h file __GCC_CLAMP_VERSION_HEADER also needs
to be modified.

The decision if chained including of header files (e.g. gcc5.h includes
gcc4.h) is necessary or should be avoided can be postponed until more
experience in using the official gcc release is gained.

Tested with gcc4 and gcc5.

[1] https://gcc.gnu.org/develop.html#num_scheme

Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: akpm@linuxfoundation.org
Cc: mingo@kernel.org
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Joe Perches <joe@perches.com>
Cc: Richard Weinberger <richard.weinberger@gmail.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
include/linux/{compiler-gcc.h => compiler-gcc/gcc.h} | 12 ++++++++++--
include/linux/{compiler-gcc3.h => compiler-gcc/gcc3.h} | 0
include/linux/{compiler-gcc4.h => compiler-gcc/gcc4.h} | 0
include/linux/compiler.h | 2 +-
4 files changed, 11 insertions(+), 3 deletions(-)
rename include/linux/{compiler-gcc.h => compiler-gcc/gcc.h} (91%)
rename include/linux/{compiler-gcc3.h => compiler-gcc/gcc3.h} (100%)
rename include/linux/{compiler-gcc4.h => compiler-gcc/gcc4.h} (100%)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc/gcc.h
similarity index 91%
rename from include/linux/compiler-gcc.h
rename to include/linux/compiler-gcc/gcc.h
index 02ae99e..0681fa3 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc/gcc.h
@@ -1,5 +1,5 @@
#ifndef __LINUX_COMPILER_H
-#error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
+#error "Please don't include <linux/compiler-gcc/gcc.h> directly, include <linux/compiler.h> instead."
#endif

/*
@@ -101,9 +101,17 @@
#define __always_unused __attribute__((unused))

#define __gcc_header(x) #x
-#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
+#define _gcc_header(x) __gcc_header(linux/compiler-gcc/gcc##x.h)
#define gcc_header(x) _gcc_header(x)
+
+/* increase this if you add a new compiler-gcc/gccX.h header file */
+#define __GCC_CLAMP_VERSION_HEADER 4
+
+#if __GNUC__ > __GCC_CLAMP_VERSION_HEADER
+#include gcc_header(__GCC_CLAMP_VERSION_HEADER)
+#else
#include gcc_header(__GNUC__)
+#endif

#if !defined(__noclone)
#define __noclone /* not needed */
diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc/gcc3.h
similarity index 100%
rename from include/linux/compiler-gcc3.h
rename to include/linux/compiler-gcc/gcc3.h
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc/gcc4.h
similarity index 100%
rename from include/linux/compiler-gcc4.h
rename to include/linux/compiler-gcc/gcc4.h
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index d5ad7b1..06be28b 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -51,7 +51,7 @@ extern void __chk_io_ptr(const volatile void __iomem *);
#ifdef __KERNEL__

#ifdef __GNUC__
-#include <linux/compiler-gcc.h>
+#include <linux/compiler-gcc/gcc.h>
#endif

#define notrace __attribute__((no_instrument_function))
--
1.9.3


\
 
 \ /
  Last update: 2014-09-05 23:01    [W:0.060 / U:0.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site