Re: [PATCH] [SUBMITTED 20170314] [v333kbuild: disable -ffunction-sections on gcc-4.7 with ftrace

From: Arnd Bergmann
Date: Fri Mar 31 2017 - 04:49:03 EST


On Thu, Mar 30, 2017 at 5:42 PM, Masahiro Yamada
<yamada.masahiro@xxxxxxxxxxxxx> wrote:
> 2017-03-29 18:30 GMT+09:00 Arnd Bergmann <arnd@xxxxxxxx>:
>> On Wed, Mar 29, 2017 at 4:07 AM, Masahiro Yamada
>> <yamada.masahiro@xxxxxxxxxxxxx> wrote:
>>> 2017-03-15 6:37 GMT+09:00 Arnd Bergmann <arnd@xxxxxxxx>:
>>> [2]
>>> This question is more technical.
>>>
>>> The cause of the problem seems that GCC warns it cannot support the
>>> two at the same time,
>>> but it does handle it as an error. So, cc-option assumes this
>>> combination is OK.
>>>
>>> Is it a good idea to add -Werror to cc-option checking?
>>
>> Hmm, I've actually been running with that change as a side-effect
>> of having the llvmlinux patches applied, which contain this one:
>>
>> commit 03497934e211325fc2913476897daf7a5ddb008a
>> Author: Mark Charlebois <charlebm@xxxxxxxxx>
>> Date: Mon Sep 22 14:33:05 2014 -0700
>>
>> kbuild, LLVMLinux: Add -Werror to cc-option to support clang
>>
>> Clang will warn about unknown warnings but will not return false
>> unless -Werror is set. GCC will return false if an unknown
>> warning is passed.
>>
>> Adding -Werror make both compiler behave the same.
>>
>> Signed-off-by: Mark Charlebois <charlebm@xxxxxxxxx>
>> Signed-off-by: Behan Webster <behanw@xxxxxxxxxxxxxxxxxx>
>> Reviewed-by: Jan-Simon MÃller <dl9pf@xxxxxx>
>>
>> diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
>> index 285acc57c0a4..3629bd9c7e79 100644
>> --- a/scripts/Kbuild.include
>> +++ b/scripts/Kbuild.include
>> @@ -116,12 +116,12 @@ CC_OPTION_CFLAGS = $(filter-out
>> $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
>> # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
>>
>> cc-option = $(call try-run,\
>> - $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c
>> /dev/null -o "$$TMP",$(1),$(2))
>> + $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c
>> -x c /dev/null -o "$$TMP",$(1),$(2))
>>
>> # cc-option-yn
>> # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
>> cc-option-yn = $(call try-run,\
>> - $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c
>> /dev/null -o "$$TMP",y,n)
>> + $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c
>> -x c /dev/null -o "$$TMP",y,n)
>>
>> # cc-option-align
>> # Prefix align with either -falign or -malign
>> @@ -131,7 +131,7 @@ cc-option-align = $(subst -functions=0,,\
>> # cc-disable-warning
>> # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
>> cc-disable-warning = $(call try-run,\
>> - $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1))
>> -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
>> + $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip
>> $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
>>
>> # cc-name
>> # Expands to either gcc or clang
>>
>> This is identical to your version, except it applies the same
>> thing to cc-disable-warning.
>
> Ah, I see.
>
> I'm also moving
> KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,)
> below
> CC_FLAGS_FTRACE := -pg
> to fix the warning.
>
>
>
>
>> I think this is good to get merged,
>> and there are probably a couple of other patches in that series
>> that we may want to look at again.
>
>
> I agree.
>
>
> At least, 03497934e21 looks good to be merged.
> (I need to get access to Mark, and ask him to send this patch.)
>
> Then, swap the -ffunction-sections and -pg order.
>
> I hope this will make you and clang guys happy.

I may have a number of clang related patches in the future,
and can also forward this patch. I suspect that Mark (added to
Cc) is currently not able to send a tested patch for the latest
kernel, he worked on it in 2014, but I don't think he's following
llvmlinux at the moment.

Arnd