Re: [PATCH 2/3] [PATCH] param: Stop gcc from inlining empty weak functions

Rusty Russell
2008-12-05T08:28:30Z

On Thursday 04 December 2008 03:02:12 David Howells wrote:
> Stop gcc from inlining empty weak functions by making them non-empty. The gcc
> I have for FRV (4.1.2) will inline empty weak functions that are in the same
> file, even if those functions are marked 'noinline'.
>
> Without this patch, the default arch_get_boot_command_line() is rolled into
> start_kernel(), and the arch specific one is not called, thus making the
> kernel unbootable.
>
> Signed-off-by: David Howells <dhowells@redhat.com>

Ouch. I'd prefer to fix this by moving the weak noop version to
kernel/params.c. You may still need to fix the rest.

Here's what I ended up with (I'll eventually fold it):

commit 4858874241391aa62b5818781f702883e4ddf4ed
Author: Rusty Russell <rusty@rustcorp.com.au>
Date: Fri Dec 5 18:56:34 2008 +1030

Move arch_get_boot_command_line out of init/main.c for broken gccs.

diff --git a/include/linux/init.h b/include/linux/init.h
index 71cd0f5..8cd1a93 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -150,7 +150,7 @@ extern unsigned int reset_devices;

/* used by init/main.c */
void setup_arch(void);
-void arch_get_cmdline(char *cmdline);
+void arch_get_boot_command_line(void);
void prepare_namespace(void);

extern void (*late_time_init)(void);
diff --git a/init/main.c b/init/main.c
index 9595dba..f6032ba 100644
--- a/init/main.c
+++ b/init/main.c
@@ -528,11 +528,6 @@ void __init __weak thread_info_cache_init(void)
{
}

-/* If the arch already sets boot_command_line, we need do nothing. */
-void __init __weak arch_get_boot_command_line(void)
-{
-}
-
/* Ideally, this would take a 'const char *cmdline' param. */
asmlinkage void __init start_kernel(void)
{
diff --git a/kernel/params.c b/kernel/params.c
index 69dd623..7fac630 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -30,6 +30,15 @@
#define DEBUGP(fmt, a...)
#endif

+/*
+ * If the arch already sets boot_command_line, we need do nothing.
+ * This is not in init/main.c because David Howells reports that on FRV
+ * gcc 4.1.2 will inline empty functions, ignoring noinline and weak.
+ */
+void __init __weak arch_get_boot_command_line(void)
+{
+}
+
static inline char dash2underscore(char c)
{
if (c == '-')