gcc version 5: add basic definition header for latest gcc version
PATCH 1/1 gcc version 5: add basic definition header for latest gcc version
The infrastructure for gcc version 5 was under consideration back in the early days of 2009[1] and now it is finally here.
I've taken the compiler-gcc4.h file, and deleted anything that was an issue with a closed bound within gcc4. For any tests that were looking for things like "#if GCC_VERSION >= 40300" I've made them unconditional, since statements like the above will always evaluate to true.
The extra asm("") in our gcc4 implementation of asm_volatile_goto has been removed, since that should not be necessary for > 4.8.2 according to the comments.
With this in place, what essentially amounts to what will be v3.17-rc1 (in a couple days) builds and boots defconfig on an older Dell dual core box without any oops or WARN or similar:
$ cat /proc/version Linux version 3.16.0-11383-gc9d26423e56c (paul@yow-pgortmak-d2) (gcc version 5.0.0 20140815 (experimental) (GCC) ) #3 SMP Fri Aug 15 14:05:10 EDT 2014 $
This was with a fresh build of today's git://gcc.gnu.org/git/gcc.git
While any sane individual would be hesitant to deploy something this green on anything they cared about, it does give those wishing to play with experimental stuff a way to do so as it matures.
[1] https://lkml.org/lkml/2009/1/2/209
include/linux/compiler-gcc5.h new file +52 -0
@@ -0,0 +1,52 @@ +#ifndef __LINUX_COMPILER_H +#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead." +#endif + +#define __used __attribute__((__used__)) +#define __must_check __attribute__((warn_unused_result)) +#define __compiler_offsetof (a, b) __builtin_offsetof(a, b) + +/* Mark functions as cold. gcc will assume any path leading to a call +to them will be unlikely. This means a lot of manual unlikely()s +are unnecessary now for any paths leading to the usual suspects +like BUG(), printk(), panic() etc. [but let's keep them for now for +older compilers] + +Early snapshots of gcc 4.3 don't support this and we can't detect this +in the preprocessor, but we can live with this because they're unreleased. +Maketime probing would be overkill here. + +gcc also has a __attribute__((__hot__)) to move hot functions into +a special section, but I don't see any sense in this right now in +the kernel context */ +#define __cold __attribute__((__cold__)) + +#define __UNIQUE_ID (prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) + +#ifndef __CHECKER__ +# define __compiletime_warning (message) __attribute__((warning(message))) +# define __compiletime_error (message) __attribute__((error(message))) +#endif /* __CHECKER__ */ + +/* +* Mark a position in code as unreachable. This can be used to +* suppress control flow warnings after asm blocks that transfer +* control elsewhere. +*/ +#define unreachable () __builtin_unreachable() + +/* Mark a function definition as prohibited from being cloned. */ +#define __noclone __attribute__((__noclone__)) + +/* +* Tell the optimizer that something else uses this function or variable. +*/ +#define __visible __attribute__((externally_visible)) + +#define asm_volatile_goto(x...) asm goto(x) + +#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP +#define __HAVE_BUILTIN_BSWAP32__ +#define __HAVE_BUILTIN_BSWAP64__ +#define __HAVE_BUILTIN_BSWAP16__ +#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
Signature · 1 line
1.9.1
Quoted 10 lines · Paul Gortmaker
include/linux/compiler-gcc5.h new file +7
-0@@ -0,0 +1,52 @@ +#ifndef __LINUX_COMPILER_H +#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead." +#endif + +#define __used __attribute__((__used__)) +#define __must_check __attribute__((warn_unused_result)) +#define __compiler_offsetof (a, b) __builtin_offsetof(a, b)
include/linux/compiler-gcc5.h line 17
Quoted 10 lines
include/linux/compiler-gcc5.h new file +10
-0+ +/* Mark functions as cold. gcc will assume any path leading to a call +to them will be unlikely. This means a lot of manual unlikely()s +are unnecessary now for any paths leading to the usual suspects +like BUG(), printk(), panic() etc. [but let's keep them for now for +older compilers] + +Early snapshots of gcc 4.3 don't support this and we can't detect this +in the preprocessor, but we can live with this because they're unreleased. +Maketime probing would be overkill here.
The above 4 lines are probably unnecessary.
More importantly, is it a good idea to store the gcc major number in the header? gcc 5.x will be released next year, but the year after that we'll have gcc 6.x, so you'd need to copy this header each year.
Jakub