2022-08-31 15:55:29

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH] powerpc/math_emu/efp: Include module.h

When building with a recent version of clang, there are a couple of
errors around the call to module_init():

arch/powerpc/math-emu/math_efp.c:927:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
module_init(spe_mathemu_init);
^
int
arch/powerpc/math-emu/math_efp.c:927:13: error: a parameter list without types is only allowed in a function definition
module_init(spe_mathemu_init);
^
2 errors generated.

module_init() is a macro, which is not getting expanded because module.h
is not included in this file. Add the include so that the macro can
expand properly, clearing up the build failure.

Reported-by: kernel test robot <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
---

No Fixes tag because it seems likely that this is a transient include
issue (the code builds with GCC). The robot blamed commit e8c07082a810
("Kbuild: move to -std=gnu11") but I think that just exposed these
errors, not caused them.

arch/powerpc/math-emu/math_efp.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/math-emu/math_efp.c b/arch/powerpc/math-emu/math_efp.c
index 39b84e7452e1..aa3bb8da1cb9 100644
--- a/arch/powerpc/math-emu/math_efp.c
+++ b/arch/powerpc/math-emu/math_efp.c
@@ -17,6 +17,7 @@

#include <linux/types.h>
#include <linux/prctl.h>
+#include <linux/module.h>

#include <linux/uaccess.h>
#include <asm/reg.h>

base-commit: dcf8e5633e2e69ad60b730ab5905608b756a032f
--
2.37.3


2022-09-01 05:50:26

by Christophe Leroy

[permalink] [raw]
Subject: Re: [PATCH] powerpc/math_emu/efp: Include module.h



Le 31/08/2022 à 17:20, Nathan Chancellor a écrit :
> When building with a recent version of clang, there are a couple of
> errors around the call to module_init():
>
> arch/powerpc/math-emu/math_efp.c:927:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
> module_init(spe_mathemu_init);
> ^
> int
> arch/powerpc/math-emu/math_efp.c:927:13: error: a parameter list without types is only allowed in a function definition
> module_init(spe_mathemu_init);
> ^
> 2 errors generated.
>
> module_init() is a macro, which is not getting expanded because module.h
> is not included in this file. Add the include so that the macro can
> expand properly, clearing up the build failure.
>
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: Nathan Chancellor <[email protected]>
> ---
>
> No Fixes tag because it seems likely that this is a transient include
> issue (the code builds with GCC). The robot blamed commit e8c07082a810
> ("Kbuild: move to -std=gnu11") but I think that just exposed these
> errors, not caused them.

Well spoted.

Seems like a GCC bug. The code builds fine but silently ignores the
issue and the following section is missing:

8 .initcall6.init 00000004 00000000 00000000 00008b30 2**2
CONTENTS, ALLOC, LOAD, RELOC, DATA

It means spe_mathemu_init() is never called.

I think it would be worth a GCC bug report.

And by the way:

Reviewed-by: Christophe Leroy <[email protected]>
Fixes: ac6f120369ff ("powerpc/85xx: Workaroudn e500 CPU erratum A005")


>
> arch/powerpc/math-emu/math_efp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/powerpc/math-emu/math_efp.c b/arch/powerpc/math-emu/math_efp.c
> index 39b84e7452e1..aa3bb8da1cb9 100644
> --- a/arch/powerpc/math-emu/math_efp.c
> +++ b/arch/powerpc/math-emu/math_efp.c
> @@ -17,6 +17,7 @@
>
> #include <linux/types.h>
> #include <linux/prctl.h>
> +#include <linux/module.h>
>
> #include <linux/uaccess.h>
> #include <asm/reg.h>
>
> base-commit: dcf8e5633e2e69ad60b730ab5905608b756a032f

2022-09-01 20:08:31

by Segher Boessenkool

[permalink] [raw]
Subject: Re: [PATCH] powerpc/math_emu/efp: Include module.h

On Thu, Sep 01, 2022 at 05:41:33AM +0000, Christophe Leroy wrote:
> I think it would be worth a GCC bug report.

We need a stand-alone testcase for this. When you have created one, at
least 98% of the time you discover the bug is in user code after all.

Which is a very good thing, it means the problem can be fixed simpler,
cheaper, and a lot faster :-)


Segher

2022-09-02 09:04:57

by Christophe Leroy

[permalink] [raw]
Subject: Re: [PATCH] powerpc/math_emu/efp: Include module.h



Le 01/09/2022 à 21:47, Segher Boessenkool a écrit :
> On Thu, Sep 01, 2022 at 05:41:33AM +0000, Christophe Leroy wrote:
>> I think it would be worth a GCC bug report.
>
> We need a stand-alone testcase for this. When you have created one, at
> least 98% of the time you discover the bug is in user code after all.
>
> Which is a very good thing, it means the problem can be fixed simpler,
> cheaper, and a lot faster :-)

Easy to reproduce with a .c file that has a single line:

non_existing_macro(xxx);


Apparently that's due to the -w option in arch/powerpc/math_emu/Makefile:

ccflags-y = -w

Was introduced by commit d2b194ed8208 ("powerpc/math-emu: Use kernel
generic math-emu code")

If I understand correctly it means 'ignore all warnings'. Then it seems
CLANG doesn't honor that request.

Christophe

2022-09-02 14:55:09

by Segher Boessenkool

[permalink] [raw]
Subject: Re: [PATCH] powerpc/math_emu/efp: Include module.h

On Fri, Sep 02, 2022 at 08:43:49AM +0000, Christophe Leroy wrote:
> Le 01/09/2022 ? 21:47, Segher Boessenkool a ?crit?:
> > On Thu, Sep 01, 2022 at 05:41:33AM +0000, Christophe Leroy wrote:
> >> I think it would be worth a GCC bug report.
> >
> > We need a stand-alone testcase for this. When you have created one, at
> > least 98% of the time you discover the bug is in user code after all.
> >
> > Which is a very good thing, it means the problem can be fixed simpler,
> > cheaper, and a lot faster :-)
>
> Easy to reproduce with a .c file that has a single line:
>
> non_existing_macro(xxx);

That was fast (and cheap and simple) :-)

> Apparently that's due to the -w option in arch/powerpc/math_emu/Makefile:
>
> ccflags-y = -w
>
> Was introduced by commit d2b194ed8208 ("powerpc/math-emu: Use kernel
> generic math-emu code")
>
> If I understand correctly it means 'ignore all warnings'. Then it seems
> CLANG doesn't honor that request.

'-w'
Inhibit all warning messages.

GCC's initial commit has this already (1992).


Segher

2022-09-09 12:48:55

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH] powerpc/math_emu/efp: Include module.h

On Wed, 31 Aug 2022 08:20:15 -0700, Nathan Chancellor wrote:
> When building with a recent version of clang, there are a couple of
> errors around the call to module_init():
>
> arch/powerpc/math-emu/math_efp.c:927:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
> module_init(spe_mathemu_init);
> ^
> int
> arch/powerpc/math-emu/math_efp.c:927:13: error: a parameter list without types is only allowed in a function definition
> module_init(spe_mathemu_init);
> ^
> 2 errors generated.
>
> [...]

Applied to powerpc/next.

[1/1] powerpc/math_emu/efp: Include module.h
https://git.kernel.org/powerpc/c/cfe0d370e0788625ce0df3239aad07a2506c1796

cheers