diff mbox

kbuild: move cc-option and cc-disable-warning after incl. arch Makefile

Message ID 1511784913-3396-1-git-send-email-yamada.masahiro@socionext.com (mailing list archive)
State New, archived
Headers show

Commit Message

Masahiro Yamada Nov. 27, 2017, 12:15 p.m. UTC
Geert reported commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before
incl. arch Makefile") broke cross-compilation using a cross-compiler
that supports less compiler options than the host compiler.

For example,

  cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"

This problem happens on architectures that setup CROSS_COMPILE in their
arch/*/Makefile.

Move the cc-option and cc-disable-warning back to the original position,
but keep the Clang target options.

Fixes: ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 Makefile | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

Comments

Geert Uytterhoeven Nov. 27, 2017, 12:25 p.m. UTC | #1
Hi Yamada-san,

On Mon, Nov 27, 2017 at 1:15 PM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Geert reported commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before
> incl. arch Makefile") broke cross-compilation using a cross-compiler
> that supports less compiler options than the host compiler.
>
> For example,
>
>   cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"
>
> This problem happens on architectures that setup CROSS_COMPILE in their
> arch/*/Makefile.
>
> Move the cc-option and cc-disable-warning back to the original position,
> but keep the Clang target options.
>
> Fixes: ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Thanks for the quick response!

Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Masahiro Yamada Dec. 10, 2017, 5:28 a.m. UTC | #2
2017-11-27 21:25 GMT+09:00 Geert Uytterhoeven <geert@linux-m68k.org>:
> Hi Yamada-san,
>
> On Mon, Nov 27, 2017 at 1:15 PM, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> Geert reported commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before
>> incl. arch Makefile") broke cross-compilation using a cross-compiler
>> that supports less compiler options than the host compiler.
>>
>> For example,
>>
>>   cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"
>>
>> This problem happens on architectures that setup CROSS_COMPILE in their
>> arch/*/Makefile.
>>
>> Move the cc-option and cc-disable-warning back to the original position,
>> but keep the Clang target options.
>>
>> Fixes: ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")
>> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>
> Thanks for the quick response!
>
> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
>
> Gr{oetje,eeting}s,
>
>                         Geert


Applied to linux-kbuild/fixes.
Geert Uytterhoeven Jan. 10, 2018, 4:21 p.m. UTC | #3
Hi Yamada-san,

On Sun, Dec 10, 2017 at 6:28 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 2017-11-27 21:25 GMT+09:00 Geert Uytterhoeven <geert@linux-m68k.org>:
>> On Mon, Nov 27, 2017 at 1:15 PM, Masahiro Yamada
>> <yamada.masahiro@socionext.com> wrote:
>>> Geert reported commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before
>>> incl. arch Makefile") broke cross-compilation using a cross-compiler
>>> that supports less compiler options than the host compiler.
>>>
>>> For example,
>>>
>>>   cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"
>>>
>>> This problem happens on architectures that setup CROSS_COMPILE in their
>>> arch/*/Makefile.
>>>
>>> Move the cc-option and cc-disable-warning back to the original position,
>>> but keep the Clang target options.
>>>
>>> Fixes: ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")
>>> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>
>> Thanks for the quick response!
>>
>> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
>
> Applied to linux-kbuild/fixes.

Any chance this will be fixed in v4.15?
It fixes a regression introduced in v4.15-rc1.

Thanks again!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Masahiro Yamada Jan. 10, 2018, 4:39 p.m. UTC | #4
2018-01-11 1:21 GMT+09:00 Geert Uytterhoeven <geert@linux-m68k.org>:
> Hi Yamada-san,
>
> On Sun, Dec 10, 2017 at 6:28 AM, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> 2017-11-27 21:25 GMT+09:00 Geert Uytterhoeven <geert@linux-m68k.org>:
>>> On Mon, Nov 27, 2017 at 1:15 PM, Masahiro Yamada
>>> <yamada.masahiro@socionext.com> wrote:
>>>> Geert reported commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before
>>>> incl. arch Makefile") broke cross-compilation using a cross-compiler
>>>> that supports less compiler options than the host compiler.
>>>>
>>>> For example,
>>>>
>>>>   cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"
>>>>
>>>> This problem happens on architectures that setup CROSS_COMPILE in their
>>>> arch/*/Makefile.
>>>>
>>>> Move the cc-option and cc-disable-warning back to the original position,
>>>> but keep the Clang target options.
>>>>
>>>> Fixes: ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")
>>>> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
>>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>>
>>> Thanks for the quick response!
>>>
>>> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
>>
>> Applied to linux-kbuild/fixes.
>
> Any chance this will be fixed in v4.15?
> It fixes a regression introduced in v4.15-rc1.
>

Yes, of course.

I have queued up just two patches to the fixes branch.
I am expecting a little more fixes for make-cache issues,
but otherwise, I will send a pull request in a few days.
diff mbox

Patch

diff --git a/Makefile b/Makefile
index aa67428..ac2d4e1 100644
--- a/Makefile
+++ b/Makefile
@@ -484,26 +484,6 @@  CLANG_GCC_TC	:= --gcc-toolchain=$(GCC_TOOLCHAIN)
 endif
 KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
 KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
-KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
-KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
-KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
-# Quiet clang warning: comparison of unsigned expression < 0 is always false
-KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
-# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
-# source of a reference will be _MergedGlobals and not on of the whitelisted names.
-# See modpost pattern 2
-KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
-KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
-KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
-KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
-else
-
-# These warnings generated too much noise in a regular build.
-# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
 endif
 
 ifeq ($(config-targets),1)
@@ -715,6 +695,29 @@  ifdef CONFIG_CC_STACKPROTECTOR
 endif
 KBUILD_CFLAGS += $(stackp-flag)
 
+ifeq ($(cc-name),clang)
+KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
+KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
+KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+# Quiet clang warning: comparison of unsigned expression < 0 is always false
+KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
+# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
+# source of a reference will be _MergedGlobals and not on of the whitelisted names.
+# See modpost pattern 2
+KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
+KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
+KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
+KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
+else
+
+# These warnings generated too much noise in a regular build.
+# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
+endif
+
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
 else