All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Disable -Wbuiltin-requires-header when setjmp is used
@ 2018-09-17  7:46 Joel Stanley
  2018-09-17 17:13 ` Nick Desaulniers
  2018-10-15  4:01 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Joel Stanley @ 2018-09-17  7:46 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nick Desaulniers

The powerpc kernel uses setjmp which causes a warning when building with
clang:

    CC      arch/powerpc/xmon/xmon.o
  In file included from arch/powerpc/xmon/xmon.c:51:
  ./arch/powerpc/include/asm/setjmp.h:15:13: error: declaration of
  built-in function 'setjmp' requires inclusion of the header <setjmp.h>
        [-Werror,-Wbuiltin-requires-header]
  extern long setjmp(long *);
              ^
  ./arch/powerpc/include/asm/setjmp.h:16:13: error: declaration of
  built-in function 'longjmp' requires inclusion of the header <setjmp.h>
        [-Werror,-Wbuiltin-requires-header]
  extern void longjmp(long *, long);
              ^

This *is* the header and we're not using the built-in setjump but
rather the one in arch/powerpc/kernel/misc.S. As the compiler warning
does not make sense, it for the files where setjmp is used.

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
We could instead disable this for all of the kernel as I don't think the
warning is going to ever provide useful information for the kernel.

 arch/powerpc/kernel/Makefile | 3 +++
 arch/powerpc/xmon/Makefile   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 1e64cfe22a83..9845a94f5f68 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -7,6 +7,9 @@ CFLAGS_ptrace.o		+= -DUTS_MACHINE='"$(UTS_MACHINE)"'
 
 subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
 
+# Disable clang warning for using setjmp without setjmp.h header
+CFLAGS_crash.o		+= $(call cc-disable-warning, builtin-requires-header)
+
 ifdef CONFIG_PPC64
 CFLAGS_prom_init.o	+= $(NO_MINIMAL_TOC)
 endif
diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
index 93cc1f1b8b61..a38db48f9f6d 100644
--- a/arch/powerpc/xmon/Makefile
+++ b/arch/powerpc/xmon/Makefile
@@ -14,6 +14,9 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)
 
 obj-y			+= xmon.o nonstdio.o spr_access.o
 
+# Disable clang warning for using setjmp without setjmp.h header
+subdir-ccflags-y := $(call cc-disable-warning, builtin-requires-header)
+
 ifdef CONFIG_XMON_DISASSEMBLY
 obj-y			+= ppc-dis.o ppc-opc.o
 obj-$(CONFIG_SPU_BASE)	+= spu-dis.o spu-opc.o
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc: Disable -Wbuiltin-requires-header when setjmp is used
  2018-09-17  7:46 [PATCH] powerpc: Disable -Wbuiltin-requires-header when setjmp is used Joel Stanley
@ 2018-09-17 17:13 ` Nick Desaulniers
  2018-10-15  4:01 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2018-09-17 17:13 UTC (permalink / raw)
  To: joel; +Cc: linuxppc-dev, Stephen Hines

On Mon, Sep 17, 2018 at 12:46 AM Joel Stanley <joel@jms.id.au> wrote:
>
> The powerpc kernel uses setjmp which causes a warning when building with
> clang:
>
>     CC      arch/powerpc/xmon/xmon.o
>   In file included from arch/powerpc/xmon/xmon.c:51:
>   ./arch/powerpc/include/asm/setjmp.h:15:13: error: declaration of
>   built-in function 'setjmp' requires inclusion of the header <setjmp.h>
>         [-Werror,-Wbuiltin-requires-header]
>   extern long setjmp(long *);
>               ^
>   ./arch/powerpc/include/asm/setjmp.h:16:13: error: declaration of
>   built-in function 'longjmp' requires inclusion of the header <setjmp.h>
>         [-Werror,-Wbuiltin-requires-header]
>   extern void longjmp(long *, long);
>               ^
>
> This *is* the header and we're not using the built-in setjump but
> rather the one in arch/powerpc/kernel/misc.S. As the compiler warning
> does not make sense, it for the files where setjmp is used.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>

Joel, thanks for reporting the issue in
https://github.com/ClangBuiltLinux/linux/issues/59
and sending the patch to fix.  I think it would be good to credit
Stephen with the Suggested-by tag:

Suggested-by: Stephen Hines <srhines@google.com>

> ---
> We could instead disable this for all of the kernel as I don't think the
> warning is going to ever provide useful information for the kernel.

I'd be curious to see more than one failure to be able to discern
whether this flag should always be disabled or if it could flag actual
bugs.  I assume the intent of the flag is "don't name
functions/headers that would conflict with the C standard library."
While the kernel uses `-nostdinc`, I still kind of empathize with the
intent of the flag.  I worry about system headers somehow getting
included rather than the kernel provided ones, especially because some
Makefiles in the kernel overwrite KBUILD_CFLAGS.

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
>  arch/powerpc/kernel/Makefile | 3 +++
>  arch/powerpc/xmon/Makefile   | 3 +++
>  2 files changed, 6 insertions(+)
>
> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> index 1e64cfe22a83..9845a94f5f68 100644
> --- a/arch/powerpc/kernel/Makefile
> +++ b/arch/powerpc/kernel/Makefile
> @@ -7,6 +7,9 @@ CFLAGS_ptrace.o         += -DUTS_MACHINE='"$(UTS_MACHINE)"'
>
>  subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
>
> +# Disable clang warning for using setjmp without setjmp.h header
> +CFLAGS_crash.o         += $(call cc-disable-warning, builtin-requires-header)
> +
>  ifdef CONFIG_PPC64
>  CFLAGS_prom_init.o     += $(NO_MINIMAL_TOC)
>  endif
> diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
> index 93cc1f1b8b61..a38db48f9f6d 100644
> --- a/arch/powerpc/xmon/Makefile
> +++ b/arch/powerpc/xmon/Makefile
> @@ -14,6 +14,9 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)
>
>  obj-y                  += xmon.o nonstdio.o spr_access.o
>
> +# Disable clang warning for using setjmp without setjmp.h header
> +subdir-ccflags-y := $(call cc-disable-warning, builtin-requires-header)
> +
>  ifdef CONFIG_XMON_DISASSEMBLY
>  obj-y                  += ppc-dis.o ppc-opc.o
>  obj-$(CONFIG_SPU_BASE) += spu-dis.o spu-opc.o
> --
> 2.17.1
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: powerpc: Disable -Wbuiltin-requires-header when setjmp is used
  2018-09-17  7:46 [PATCH] powerpc: Disable -Wbuiltin-requires-header when setjmp is used Joel Stanley
  2018-09-17 17:13 ` Nick Desaulniers
@ 2018-10-15  4:01 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-10-15  4:01 UTC (permalink / raw)
  To: Joel Stanley, linuxppc-dev; +Cc: Nick Desaulniers

On Mon, 2018-09-17 at 07:46:21 UTC, Joel Stanley wrote:
> The powerpc kernel uses setjmp which causes a warning when building with
> clang:
> 
>     CC      arch/powerpc/xmon/xmon.o
>   In file included from arch/powerpc/xmon/xmon.c:51:
>   ./arch/powerpc/include/asm/setjmp.h:15:13: error: declaration of
>   built-in function 'setjmp' requires inclusion of the header <setjmp.h>
>         [-Werror,-Wbuiltin-requires-header]
>   extern long setjmp(long *);
>               ^
>   ./arch/powerpc/include/asm/setjmp.h:16:13: error: declaration of
>   built-in function 'longjmp' requires inclusion of the header <setjmp.h>
>         [-Werror,-Wbuiltin-requires-header]
>   extern void longjmp(long *, long);
>               ^
> 
> This *is* the header and we're not using the built-in setjump but
> rather the one in arch/powerpc/kernel/misc.S. As the compiler warning
> does not make sense, it for the files where setjmp is used.
> 
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/aea447141c7e7824b81b49acd1bc78

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-15  4:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-17  7:46 [PATCH] powerpc: Disable -Wbuiltin-requires-header when setjmp is used Joel Stanley
2018-09-17 17:13 ` Nick Desaulniers
2018-10-15  4:01 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.