* [PATCH] gcc version 5: add basic definition header for latest gcc version
@ 2014-08-15 19:23 Paul Gortmaker
2014-08-15 19:30 ` Jakub Jelinek
0 siblings, 1 reply; 2+ messages in thread
From: Paul Gortmaker @ 2014-08-15 19:23 UTC (permalink / raw)
To: linux-kernel
Cc: Paul Gortmaker, Ingo Molnar, Jakub Jelinek, Richard Henderson,
Andrew Morton, Linus Torvalds
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
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
new file mode 100644
index 000000000000..f6680fabb62f
--- /dev/null
+++ b/include/linux/compiler-gcc5.h
@@ -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 */
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gcc version 5: add basic definition header for latest gcc version
2014-08-15 19:23 [PATCH] gcc version 5: add basic definition header for latest gcc version Paul Gortmaker
@ 2014-08-15 19:30 ` Jakub Jelinek
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2014-08-15 19:30 UTC (permalink / raw)
To: Paul Gortmaker
Cc: linux-kernel, Ingo Molnar, Richard Henderson, Andrew Morton,
Linus Torvalds
On Fri, Aug 15, 2014 at 03:23:01PM -0400, Paul Gortmaker wrote:
> --- /dev/null
> +++ b/include/linux/compiler-gcc5.h
> @@ -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.
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-15 19:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-15 19:23 [PATCH] gcc version 5: add basic definition header for latest gcc version Paul Gortmaker
2014-08-15 19:30 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®