Re: [PATCH] kbuild: fix kernel/bounds.c 'W=1' warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/10/18 10:07, Arnd Bergmann wrote:
> On Fri, Oct 5, 2018 at 10:52 AM David Laight <David.Laight@xxxxxxxxxx> wrote:
>>
>> From: Arnd Bergmann
>>> Sent: 05 October 2018 09:33
>>>
>>> Building any configuration with 'make W=1' produces a warning:
>>>
>>> kernel/bounds.c:16:6: warnign: no previous prototype for 'foo' [-Wmissing-prototypes]
>>>
>>> When also passing -Werror, this prevents us from building any
>>> other files. Nobody ever calls the function, but we can't make
>>> it 'static' either since we want the compiler output.
>>>
>>> Calling it 'main' instead however avoids the warning, because gcc
>>> does not insist on having a declaration for main.
>>
>> Ugg.
>> main() might be special in other ways too.
>> It wouldn't surprise me if some linkers don't do special stuff for it.

I worried about this but didn't think it would be too much of an issue.
But perhaps we should check...

<compile bounds.s in both configurations> as bounds.s.foo and bounds.s.main:


 diff -Nurp bounds.s.*
--- bounds.s.foo        2018-10-05 10:20:53.269941404 +0100
+++ bounds.s.main       2018-10-05 10:20:31.375891260 +0100
@@ -108,11 +108,12 @@

        .global _mcount
 #NO_APP
+       .section        .text.startup,"ax",@progbits
        .align  2
        .p2align 3,,7
-       .global foo
-       .type   foo, %function
-foo:
+       .global main
+       .type   main, %function
+main:
        stp     x29, x30, [sp, -16]!    //,,,
        add     x29, sp, 0      //,,
 // /home/linuxembedded/iob/renesas/vsp1/sources/linux/kernel/bounds.c:17: {
@@ -139,10 +140,11 @@ foo:

 .ascii "->SPINLOCK_SIZE 56 sizeof(spinlock_t)" //
 // 0 "" 2
-// /home/linuxembedded/iob/renesas/vsp1/sources/linux/kernel/bounds.c:26: }
+// /home/linuxembedded/iob/renesas/vsp1/sources/linux/kernel/bounds.c:28: }
 #NO_APP
+       mov     w0, 0   //,
        ldp     x29, x30, [sp], 16      //,,,
        ret
-       .size   foo, .-foo
+       .size   main, .-main
        .ident  "GCC: (Ubuntu/Linaro 7.3.0-16ubuntu3) 7.3.0"
        .section        .note.GNU-stack,"",@progbits



compiled with aarch64-linux-gnu-gcc, and with no debug enabled.

Other than the entry point rename (and section name) and the return
value being added, I can't see anything problematic here.

And as far as I know - this file gets processed after to extract
definitions which should be independent. This file is not executed or
further compiled as far as I am aware.

--
Kieran



>>
>> What is wrong with just putting and extra "void foo(void);" before
>> the function?
> 
> Greg objected to that on the basis that we don't want declarations
> in .c files -- they should be in a shared header:
> 
> https://lkml.org/lkml/2018/9/21/735
> 
> I don't see what could go wrong here with calling it main(), after
> all we are just interested in the assembler output, not even
> creating an object file.
> 
>       Arnd
> 




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux