[PATCH] Make 2.4 boot when built with a newer compiler

Stephen Rothwell sfr at canb.auug.org.au
Tue Mar 30 15:54:31 EST 2004


Hi Anton,

This is a backport of the __attribute_used__ stuff from 2.6 so
that 2.4 will build with the GCC hammer branch and 3.4 etc.

Built and booted for iSeries - without this patch, it does not
boot when built with gcc 3.3.3-hammer.

Please apply to AmesLab.
--
Cheers,
Stephen Rothwell                    sfr at canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN ppc64-linux-2.4/include/linux/compiler.h ppc64-linux-2.4.used/include/linux/compiler.h
--- ppc64-linux-2.4/include/linux/compiler.h	2003-08-22 12:30:56.000000000 +1000
+++ ppc64-linux-2.4.used/include/linux/compiler.h	2004-03-30 15:15:18.000000000 +1000
@@ -13,4 +13,18 @@
 #define likely(x)	__builtin_expect((x),1)
 #define unlikely(x)	__builtin_expect((x),0)

+#if __GNUC__ > 3
+#define __attribute_used__	__attribute((__used__))
+#elif __GNUC__ == 3
+#if  __GNUC_MINOR__ >= 3
+# define __attribute_used__	__attribute__((__used__))
+#else
+# define __attribute_used__	__attribute__((__unused__))
+#endif /* __GNUC_MINOR__ >= 3 */
+#elif __GNUC__ == 2
+#define __attribute_used__	__attribute__((__unused__))
+#else
+#define __attribute_used__	/* not implemented */
+#endif /* __GNUC__ */
+
 #endif /* __LINUX_COMPILER_H */
diff -ruN ppc64-linux-2.4/include/linux/init.h ppc64-linux-2.4.used/include/linux/init.h
--- ppc64-linux-2.4/include/linux/init.h	2003-08-22 12:30:56.000000000 +1000
+++ ppc64-linux-2.4.used/include/linux/init.h	2004-03-30 15:22:50.000000000 +1000
@@ -2,6 +2,7 @@
 #define _LINUX_INIT_H

 #include <linux/config.h>
+#include <linux/compiler.h>

 /* These macros are used to mark some functions or
  * initialized data (doesn't apply to uninitialized data)
@@ -51,7 +52,7 @@
 extern initcall_t __initcall_start, __initcall_end;

 #define __initcall(fn)								\
-	static initcall_t __initcall_##fn __init_call = fn
+	static initcall_t __initcall_##fn __attribute_used__ __init_call = fn
 #define __exitcall(fn)								\
 	static exitcall_t __exitcall_##fn __exit_call = fn

@@ -67,7 +68,7 @@

 #define __setup(str, fn)								\
 	static char __setup_str_##fn[] __initdata = str;				\
-	static struct kernel_param __setup_##fn __attribute__((unused)) __initsetup = { __setup_str_##fn, fn }
+	static struct kernel_param __setup_##fn __attribute_used__ __initsetup = { __setup_str_##fn, fn }

 #endif /* __ASSEMBLY__ */

@@ -76,12 +77,12 @@
  * or exit time.
  */
 #define __init		__attribute__ ((__section__ (".text.init")))
-#define __exit		__attribute__ ((unused, __section__(".text.exit")))
+#define __exit		__attribute_used__ __attribute__ (( __section__(".text.exit")))
 #define __initdata	__attribute__ ((__section__ (".data.init")))
-#define __exitdata	__attribute__ ((unused, __section__ (".data.exit")))
-#define __initsetup	__attribute__ ((unused,__section__ (".setup.init")))
-#define __init_call	__attribute__ ((unused,__section__ (".initcall.init")))
-#define __exit_call	__attribute__ ((unused,__section__ (".exitcall.exit")))
+#define __exitdata	__attribute_used__ __attribute__ ((__section__ (".data.exit")))
+#define __initsetup	__attribute_used__ __attribute__ ((__section__ (".setup.init")))
+#define __init_call	__attribute_used__ __attribute__ ((__section__ (".initcall.init")))
+#define __exit_call	__attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))

 /* For assembly routines */
 #define __INIT		.section	".text.init","ax"
diff -ruN ppc64-linux-2.4/include/linux/module.h ppc64-linux-2.4.used/include/linux/module.h
--- ppc64-linux-2.4/include/linux/module.h	2003-08-22 12:30:56.000000000 +1000
+++ ppc64-linux-2.4.used/include/linux/module.h	2004-03-30 15:24:25.000000000 +1000
@@ -254,9 +254,9 @@
  */
 #define MODULE_GENERIC_TABLE(gtype,name)	\
 static const unsigned long __module_##gtype##_size \
-  __attribute__ ((unused)) = sizeof(struct gtype##_id); \
+  __attribute_used__ = sizeof(struct gtype##_id); \
 static const struct gtype##_id * __module_##gtype##_table \
-  __attribute__ ((unused)) = name
+  __attribute_used__ = name

 /*
  * The following license idents are currently accepted as indicating free
@@ -319,7 +319,7 @@
  */
 #define MODULE_GENERIC_TABLE(gtype,name) \
 static const struct gtype##_id * __module_##gtype##_table \
-  __attribute__ ((unused, __section__(".data.exit"))) = name
+  __attribute_used__ __attribute__ ((__section__(".data.exit"))) = name

 #ifndef __GENKSYMS__

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list