All of lore.kernel.org
 help / color / mirror / Atom feed
* Kbuild: CC= handling broken for tools/
@ 2016-11-11 11:23 Jiri Slaby
  2016-11-11 12:38 ` Michal Marek
  2016-11-11 14:00 ` Jiri Olsa
  0 siblings, 2 replies; 8+ messages in thread
From: Jiri Slaby @ 2016-11-11 11:23 UTC (permalink / raw)
  To: Michal Marek, linux-kbuild, Linux kernel mailing list

Hi,

I am trying a new gcc with new warnings enabled:

make O=../a/gcc7/ CC='gcc-7' V=1 kernel/exit.o
EXTRA_CFLAGS='-Wimplicit-fallthrough=3'

But the build fails when building under tools/:
...
make -f /home/latest/linux/tools/build/Makefile.build dir=. obj=fixdep
  gcc
-Wp,-MD,/home/latest/a/gcc7/tools/objtool/.exec-cmd.o.d,-MT,/home/latest/a/gcc7/tools/objtool/exec-cmd.o
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked
-Wredundant-decls -Wshadow -Wstrict-aliasing=3 -Wstrict-prototypes
-Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat
-Wimplicit-fallthrough=3 -ggdb3 -Wall -Wextra -std=gnu99 -O6
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -Werror
-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
-I/home/latest/linux/tools/include/ -I/home/latest/linux/include/uapi
-I/home/latest/linux/include -D"BUILD_STR(s)=#s"   -c -o
/home/latest/a/gcc7/tools/objtool/exec-cmd.o exec-cmd.c
gcc: error: unrecognized command line option ‘-Wimplicit-fallthrough=3’;
did you mean ‘-Wno-fallthrough’?


Apparently, CC is not respected for tools/ dir.

Well, it is used (tools/build/Makefile.build):
# Compile command
quiet_cmd_cc_o_c = CC       $@
      cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<


But I don't know why CFLAGS propagate from Makefile to tools/, but CC
doesn't (both are exported)? Any ideas?

thanks,
-- 
js
suse labs

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

* Re: Kbuild: CC= handling broken for tools/
  2016-11-11 11:23 Kbuild: CC= handling broken for tools/ Jiri Slaby
@ 2016-11-11 12:38 ` Michal Marek
  2016-11-11 14:00 ` Jiri Olsa
  1 sibling, 0 replies; 8+ messages in thread
From: Michal Marek @ 2016-11-11 12:38 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linux-kbuild, Linux kernel mailing list, Jiri Olsa

On 2016-11-11 12:23, Jiri Slaby wrote:
> Hi,
> 
> I am trying a new gcc with new warnings enabled:
> 
> make O=../a/gcc7/ CC='gcc-7' V=1 kernel/exit.o
> EXTRA_CFLAGS='-Wimplicit-fallthrough=3'

Note that EXTRA_CFLAGS is a makefile variable read by both kbuild and
tools/build apparently.

> 
> But the build fails when building under tools/:
[...]
> gcc: error: unrecognized command line option ‘-Wimplicit-fallthrough=3’;
> did you mean ‘-Wno-fallthrough’?
> 
> 
> Apparently, CC is not respected for tools/ dir.

Jiri can better explain the behavior of the tools/ Makefiles, but if you
want to use extra flags for kernel compilation, you should be using the
KCFLAGS variable (see Documentation/kbuild/kbuild.txt).

Michal

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

* Re: Kbuild: CC= handling broken for tools/
  2016-11-11 11:23 Kbuild: CC= handling broken for tools/ Jiri Slaby
  2016-11-11 12:38 ` Michal Marek
@ 2016-11-11 14:00 ` Jiri Olsa
  2016-11-11 14:04   ` Jiri Slaby
  1 sibling, 1 reply; 8+ messages in thread
From: Jiri Olsa @ 2016-11-11 14:00 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Michal Marek, linux-kbuild, Linux kernel mailing list

On Fri, Nov 11, 2016 at 12:23:25PM +0100, Jiri Slaby wrote:
> Hi,
> 
> I am trying a new gcc with new warnings enabled:
> 
> make O=../a/gcc7/ CC='gcc-7' V=1 kernel/exit.o
> EXTRA_CFLAGS='-Wimplicit-fallthrough=3'
> 
> But the build fails when building under tools/:
> ...
> make -f /home/latest/linux/tools/build/Makefile.build dir=. obj=fixdep
>   gcc
> -Wp,-MD,/home/latest/a/gcc7/tools/objtool/.exec-cmd.o.d,-MT,/home/latest/a/gcc7/tools/objtool/exec-cmd.o
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked
> -Wredundant-decls -Wshadow -Wstrict-aliasing=3 -Wstrict-prototypes
> -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat
> -Wimplicit-fallthrough=3 -ggdb3 -Wall -Wextra -std=gnu99 -O6
> -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -Werror
> -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
> -I/home/latest/linux/tools/include/ -I/home/latest/linux/include/uapi
> -I/home/latest/linux/include -D"BUILD_STR(s)=#s"   -c -o
> /home/latest/a/gcc7/tools/objtool/exec-cmd.o exec-cmd.c
> gcc: error: unrecognized command line option ‘-Wimplicit-fallthrough=3’;
> did you mean ‘-Wno-fallthrough’?
> 
> 
> Apparently, CC is not respected for tools/ dir.
> 
> Well, it is used (tools/build/Makefile.build):
> # Compile command
> quiet_cmd_cc_o_c = CC       $@
>       cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
> 
> 
> But I don't know why CFLAGS propagate from Makefile to tools/, but CC
> doesn't (both are exported)? Any ideas?

so the root Makefile assign CC directly:
  CC              = $(CROSS_COMPILE)gcc

we are trying to be a little bit smarter in perf
and set it only if it's not set by user

# Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix.
$(call allow-override,CC,$(CROSS_COMPILE)gcc)
$(call allow-override,AR,$(CROSS_COMPILE)ar)
$(call allow-override,LD,$(CROSS_COMPILE)ld)

I did not check the other tools..

thanks,
jirka

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

* Re: Kbuild: CC= handling broken for tools/
  2016-11-11 14:00 ` Jiri Olsa
@ 2016-11-11 14:04   ` Jiri Slaby
  2016-11-11 15:14     ` Jiri Olsa
  0 siblings, 1 reply; 8+ messages in thread
From: Jiri Slaby @ 2016-11-11 14:04 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: Michal Marek, linux-kbuild, Linux kernel mailing list

On 11/11/2016, 03:00 PM, Jiri Olsa wrote:
> On Fri, Nov 11, 2016 at 12:23:25PM +0100, Jiri Slaby wrote:
>> Hi,
>>
>> I am trying a new gcc with new warnings enabled:
>>
>> make O=../a/gcc7/ CC='gcc-7' V=1 kernel/exit.o
>> EXTRA_CFLAGS='-Wimplicit-fallthrough=3'
>>
>> But the build fails when building under tools/:
>> ...
>> make -f /home/latest/linux/tools/build/Makefile.build dir=. obj=fixdep
>>   gcc
>> -Wp,-MD,/home/latest/a/gcc7/tools/objtool/.exec-cmd.o.d,-MT,/home/latest/a/gcc7/tools/objtool/exec-cmd.o
>> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security
>> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes
>> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked
>> -Wredundant-decls -Wshadow -Wstrict-aliasing=3 -Wstrict-prototypes
>> -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat
>> -Wimplicit-fallthrough=3 -ggdb3 -Wall -Wextra -std=gnu99 -O6
>> -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -Werror
>> -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
>> -I/home/latest/linux/tools/include/ -I/home/latest/linux/include/uapi
>> -I/home/latest/linux/include -D"BUILD_STR(s)=#s"   -c -o
>> /home/latest/a/gcc7/tools/objtool/exec-cmd.o exec-cmd.c
>> gcc: error: unrecognized command line option ‘-Wimplicit-fallthrough=3’;
>> did you mean ‘-Wno-fallthrough’?
>>
>>
>> Apparently, CC is not respected for tools/ dir.
>>
>> Well, it is used (tools/build/Makefile.build):
>> # Compile command
>> quiet_cmd_cc_o_c = CC       $@
>>       cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
>>
>>
>> But I don't know why CFLAGS propagate from Makefile to tools/, but CC
>> doesn't (both are exported)? Any ideas?
> 
> so the root Makefile assign CC directly:
>   CC              = $(CROSS_COMPILE)gcc
> 
> we are trying to be a little bit smarter in perf
> and set it only if it's not set by user
> 
> # Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix.
> $(call allow-override,CC,$(CROSS_COMPILE)gcc)
> $(call allow-override,AR,$(CROSS_COMPILE)ar)
> $(call allow-override,LD,$(CROSS_COMPILE)ld)
> 
> I did not check the other tools..

Note that I don't care about tools at all. objtool (see the dump above)
is apparently needed to build the kernel proper, so it is built as a
part of kernel.

BTW shouldn't it use HOSTCC anyway?

thanks,
-- 
js
suse labs

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

* Re: Kbuild: CC= handling broken for tools/
  2016-11-11 14:04   ` Jiri Slaby
@ 2016-11-11 15:14     ` Jiri Olsa
  2016-11-11 15:30       ` Josh Poimboeuf
  0 siblings, 1 reply; 8+ messages in thread
From: Jiri Olsa @ 2016-11-11 15:14 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Michal Marek, linux-kbuild, Linux kernel mailing list, Josh Poimboeuf

On Fri, Nov 11, 2016 at 03:04:35PM +0100, Jiri Slaby wrote:
> On 11/11/2016, 03:00 PM, Jiri Olsa wrote:
> > On Fri, Nov 11, 2016 at 12:23:25PM +0100, Jiri Slaby wrote:
> >> Hi,
> >>
> >> I am trying a new gcc with new warnings enabled:
> >>
> >> make O=../a/gcc7/ CC='gcc-7' V=1 kernel/exit.o
> >> EXTRA_CFLAGS='-Wimplicit-fallthrough=3'
> >>
> >> But the build fails when building under tools/:
> >> ...
> >> make -f /home/latest/linux/tools/build/Makefile.build dir=. obj=fixdep
> >>   gcc
> >> -Wp,-MD,/home/latest/a/gcc7/tools/objtool/.exec-cmd.o.d,-MT,/home/latest/a/gcc7/tools/objtool/exec-cmd.o
> >> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security
> >> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes
> >> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked
> >> -Wredundant-decls -Wshadow -Wstrict-aliasing=3 -Wstrict-prototypes
> >> -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat
> >> -Wimplicit-fallthrough=3 -ggdb3 -Wall -Wextra -std=gnu99 -O6
> >> -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -Werror
> >> -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
> >> -I/home/latest/linux/tools/include/ -I/home/latest/linux/include/uapi
> >> -I/home/latest/linux/include -D"BUILD_STR(s)=#s"   -c -o
> >> /home/latest/a/gcc7/tools/objtool/exec-cmd.o exec-cmd.c
> >> gcc: error: unrecognized command line option ‘-Wimplicit-fallthrough=3’;
> >> did you mean ‘-Wno-fallthrough’?
> >>
> >>
> >> Apparently, CC is not respected for tools/ dir.
> >>
> >> Well, it is used (tools/build/Makefile.build):
> >> # Compile command
> >> quiet_cmd_cc_o_c = CC       $@
> >>       cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
> >>
> >>
> >> But I don't know why CFLAGS propagate from Makefile to tools/, but CC
> >> doesn't (both are exported)? Any ideas?
> > 
> > so the root Makefile assign CC directly:
> >   CC              = $(CROSS_COMPILE)gcc
> > 
> > we are trying to be a little bit smarter in perf
> > and set it only if it's not set by user
> > 
> > # Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix.
> > $(call allow-override,CC,$(CROSS_COMPILE)gcc)
> > $(call allow-override,AR,$(CROSS_COMPILE)ar)
> > $(call allow-override,LD,$(CROSS_COMPILE)ld)
> > 
> > I did not check the other tools..
> 
> Note that I don't care about tools at all. objtool (see the dump above)
> is apparently needed to build the kernel proper, so it is built as a
> part of kernel.
> 
> BTW shouldn't it use HOSTCC anyway?

hum, probably.. adding Josh to the loop

jirka

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

* Re: Kbuild: CC= handling broken for tools/
  2016-11-11 15:14     ` Jiri Olsa
@ 2016-11-11 15:30       ` Josh Poimboeuf
  2016-11-11 17:08         ` Jiri Slaby
  0 siblings, 1 reply; 8+ messages in thread
From: Josh Poimboeuf @ 2016-11-11 15:30 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Slaby, Michal Marek, linux-kbuild, Linux kernel mailing list

On Fri, Nov 11, 2016 at 04:14:27PM +0100, Jiri Olsa wrote:
> On Fri, Nov 11, 2016 at 03:04:35PM +0100, Jiri Slaby wrote:
> > On 11/11/2016, 03:00 PM, Jiri Olsa wrote:
> > > On Fri, Nov 11, 2016 at 12:23:25PM +0100, Jiri Slaby wrote:
> > >> Hi,
> > >>
> > >> I am trying a new gcc with new warnings enabled:
> > >>
> > >> make O=../a/gcc7/ CC='gcc-7' V=1 kernel/exit.o
> > >> EXTRA_CFLAGS='-Wimplicit-fallthrough=3'
> > >>
> > >> But the build fails when building under tools/:
> > >> ...
> > >> make -f /home/latest/linux/tools/build/Makefile.build dir=. obj=fixdep
> > >>   gcc
> > >> -Wp,-MD,/home/latest/a/gcc7/tools/objtool/.exec-cmd.o.d,-MT,/home/latest/a/gcc7/tools/objtool/exec-cmd.o
> > >> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security
> > >> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes
> > >> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked
> > >> -Wredundant-decls -Wshadow -Wstrict-aliasing=3 -Wstrict-prototypes
> > >> -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat
> > >> -Wimplicit-fallthrough=3 -ggdb3 -Wall -Wextra -std=gnu99 -O6
> > >> -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -Werror
> > >> -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
> > >> -I/home/latest/linux/tools/include/ -I/home/latest/linux/include/uapi
> > >> -I/home/latest/linux/include -D"BUILD_STR(s)=#s"   -c -o
> > >> /home/latest/a/gcc7/tools/objtool/exec-cmd.o exec-cmd.c
> > >> gcc: error: unrecognized command line option ‘-Wimplicit-fallthrough=3’;
> > >> did you mean ‘-Wno-fallthrough’?
> > >>
> > >>
> > >> Apparently, CC is not respected for tools/ dir.
> > >>
> > >> Well, it is used (tools/build/Makefile.build):
> > >> # Compile command
> > >> quiet_cmd_cc_o_c = CC       $@
> > >>       cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
> > >>
> > >>
> > >> But I don't know why CFLAGS propagate from Makefile to tools/, but CC
> > >> doesn't (both are exported)? Any ideas?
> > > 
> > > so the root Makefile assign CC directly:
> > >   CC              = $(CROSS_COMPILE)gcc
> > > 
> > > we are trying to be a little bit smarter in perf
> > > and set it only if it's not set by user
> > > 
> > > # Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix.
> > > $(call allow-override,CC,$(CROSS_COMPILE)gcc)
> > > $(call allow-override,AR,$(CROSS_COMPILE)ar)
> > > $(call allow-override,LD,$(CROSS_COMPILE)ld)
> > > 
> > > I did not check the other tools..
> > 
> > Note that I don't care about tools at all. objtool (see the dump above)
> > is apparently needed to build the kernel proper, so it is built as a
> > part of kernel.
> > 
> > BTW shouldn't it use HOSTCC anyway?
> 
> hum, probably.. adding Josh to the loop

Does it work if you use KCFLAGS instead of EXTRA_CFLAGS?

-- 
Josh

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

* Re: Kbuild: CC= handling broken for tools/
  2016-11-11 15:30       ` Josh Poimboeuf
@ 2016-11-11 17:08         ` Jiri Slaby
  2016-11-11 17:21           ` Josh Poimboeuf
  0 siblings, 1 reply; 8+ messages in thread
From: Jiri Slaby @ 2016-11-11 17:08 UTC (permalink / raw)
  To: Josh Poimboeuf, Jiri Olsa
  Cc: Michal Marek, linux-kbuild, Linux kernel mailing list

On 11/11/2016, 04:30 PM, Josh Poimboeuf wrote:
> Does it work if you use KCFLAGS instead of EXTRA_CFLAGS?

Yes, the kernel builds with the flags now.

But objtool is unexpectedly still built by a different compiler.

I would also prefer the flags (like the warning above) to be passed even
when building host commands.

thanks,
-- 
js
suse labs

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

* Re: Kbuild: CC= handling broken for tools/
  2016-11-11 17:08         ` Jiri Slaby
@ 2016-11-11 17:21           ` Josh Poimboeuf
  0 siblings, 0 replies; 8+ messages in thread
From: Josh Poimboeuf @ 2016-11-11 17:21 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Jiri Olsa, Michal Marek, linux-kbuild, Linux kernel mailing list

On Fri, Nov 11, 2016 at 06:08:24PM +0100, Jiri Slaby wrote:
> On 11/11/2016, 04:30 PM, Josh Poimboeuf wrote:
> > Does it work if you use KCFLAGS instead of EXTRA_CFLAGS?
> 
> Yes, the kernel builds with the flags now.
> 
> But objtool is unexpectedly still built by a different compiler.
> 
> I would also prefer the flags (like the warning above) to be passed even
> when building host commands.

In that case, if you want to build *everything* in tools and kernel with
the new compiler and new flags, I think you'll need to set HOSTCC,
HOSTCFLAGS, and CFLAGS, in addition to CC and KCFLAGS.

objtool uses the host compiler, but it doesn't support setting HOSTCC or
HOSTCFLAGS yet.  It always just uses 'gcc'.  I'll add HOSTCC/HOSTCFLAGS
to the TODO list, though feel free to work up a patch.

-- 
Josh

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

end of thread, other threads:[~2016-11-11 17:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-11 11:23 Kbuild: CC= handling broken for tools/ Jiri Slaby
2016-11-11 12:38 ` Michal Marek
2016-11-11 14:00 ` Jiri Olsa
2016-11-11 14:04   ` Jiri Slaby
2016-11-11 15:14     ` Jiri Olsa
2016-11-11 15:30       ` Josh Poimboeuf
2016-11-11 17:08         ` Jiri Slaby
2016-11-11 17:21           ` Josh Poimboeuf

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.