[linux-yocto] [PATCH 02/14] lto: Add __noreorder and mark initcalls __noreorder

Alejandro Hernandez alejandro.hernandez at linux.intel.com
Mon Feb 13 12:41:15 PST 2017


From: Andi Kleen <ak at linux.intel.com>

gcc 5 has a new no_reorder attribute that prevents top level
reordering only for that symbol.

Kernels don't like any reordering of initcalls between files, as several
initcalls depend on each other. LTO previously needed to use
-fno-toplevel-reordering to prevent boot failures.

Add a __noreorder wrapper for the no_reorder attribute and use
it for initcalls.

Signed-off-by: Andi Kleen <ak at linux.intel.com>
Signed-off-by: Tom Zanussi <tom.zanussi at linux.intel.com>
---
 include/linux/compiler-gcc.h | 5 +++++
 include/linux/compiler.h     | 4 ++++
 include/linux/init.h         | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 287e698..6b4c48b 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -278,6 +278,11 @@
 #define __no_sanitize_address
 #endif
 
+#if __GNUC__ >= 6
+/* Avoid reordering a top level statement */
+#define __noreorder    __attribute__((no_reorder))
+#endif
+
 /*
  * A trick to suppress uninitialized variable warning without generating any
  * code
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 6fc9a6d..5a7070d 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -369,6 +369,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 #define noinline
 #endif
 
+#ifndef __noreorder
+#define __noreorder		/* unimplemented */
+#endif
+
 /*
  * Rather then using noinline to prevent stack consumption, use
  * noinline_for_stack instead.  For documentation reasons.
diff --git a/include/linux/init.h b/include/linux/init.h
index b449f37..dd889e8 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -180,7 +180,7 @@ extern bool initcall_debug;
  */
 
 #define __define_initcall(fn, id) \
-	static initcall_t __initcall_##fn##id __used \
+	static initcall_t __initcall_##fn##id __used __noreorder \
 	__attribute__((__section__(".initcall" #id ".init"))) = fn; \
 	LTO_REFERENCE_INITCALL(__initcall_##fn##id)
 
-- 
2.6.6



More information about the linux-yocto mailing list