diff mbox series

[v5,21/31] kconfig: show compiler version text in the top comment

Message ID 1527499328-13213-22-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 21c54b774744719c386fbdc829b0e7759edb8ece
Headers show
Series kconfig: move compiler capability tests to Kconfig | expand

Commit Message

Masahiro Yamada May 28, 2018, 9:21 a.m. UTC
The kernel configuration phase is now tightly coupled with the compiler
in use.  It will be nice to show the compiler information in Kconfig.

The compiler information will be displayed like this:

  $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- config
  scripts/kconfig/conf  --oldaskconfig Kconfig
  *
  * Linux/arm64 4.16.0-rc1 Kernel Configuration
  *
  *
  * Compiler: aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011
  *
  *
  * General setup
  *
  Compile also drivers which will not load (COMPILE_TEST) [N/y/?]

If you use GUI methods such as menuconfig, it will be displayed in the
top menu.

This is simply implemented by using the 'comment' statement.  So, it
will be saved into the .config file as well.

This commit has a very important meaning.  If the compiler is upgraded,
Kconfig must be re-run since different compilers have different sets
of supported options.

All referenced environments are written to include/config/auto.conf.cmd
so that any environment change triggers syncconfig, and prompt the user
to input new values if needed.

With this commit, something like follows will be added to
include/config/auto.conf.cmd

  ifneq "$(CC_VERSION_TEXT)" "aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011"
  include/config/auto.conf: FORCE
  endif

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

---

Changes in v5: None
Changes in v4:
  - Add comment to arch/x86/um/Kconfig as well

Changes in v3: None
Changes in v2: None

 Kconfig             | 2 ++
 Makefile            | 2 ++
 arch/x86/um/Kconfig | 2 ++
 3 files changed, 6 insertions(+)

-- 
2.7.4

Comments

Geert Uytterhoeven June 7, 2018, 8:42 a.m. UTC | #1
Hi Yamada-san,

On Mon, May 28, 2018 at 11:21 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> The kernel configuration phase is now tightly coupled with the compiler

> in use.  It will be nice to show the compiler information in Kconfig.

>

> The compiler information will be displayed like this:

>

>   $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- config

>   scripts/kconfig/conf  --oldaskconfig Kconfig

>   *

>   * Linux/arm64 4.16.0-rc1 Kernel Configuration

>   *

>   *

>   * Compiler: aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011

>   *

>   *

>   * General setup

>   *

>   Compile also drivers which will not load (COMPILE_TEST) [N/y/?]

>

> If you use GUI methods such as menuconfig, it will be displayed in the

> top menu.

>

> This is simply implemented by using the 'comment' statement.  So, it

> will be saved into the .config file as well.

>

> This commit has a very important meaning.  If the compiler is upgraded,

> Kconfig must be re-run since different compilers have different sets

> of supported options.

>

> All referenced environments are written to include/config/auto.conf.cmd

> so that any environment change triggers syncconfig, and prompt the user

> to input new values if needed.

>

> With this commit, something like follows will be added to

> include/config/auto.conf.cmd

>

>   ifneq "$(CC_VERSION_TEXT)" "aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011"

>   include/config/auto.conf: FORCE

>   endif

>

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> Reviewed-by: Kees Cook <keescook@chromium.org>


This is now commit 21c54b774744719c ("kconfig: show compiler version text
in the top comment") upstream.

This commit broke cross-compilation for me:

    $ make ARCH=m68k
    scripts/kconfig/conf  --syncconfig Kconfig
    scripts/kconfig/conf  --syncconfig Kconfig
    scripts/kconfig/conf  --syncconfig Kconfig
    scripts/kconfig/conf  --syncconfig Kconfig
    ...

with O=:

      GEN     ./Makefile
     scripts/kconfig/conf  --syncconfig Kconfig
      GEN     ./Makefile
    scripts/kconfig/conf  --syncconfig Kconfig
      GEN     ./Makefile
    scripts/kconfig/conf  --syncconfig Kconfig
      GEN     ./Makefile
    ...

.config gained (both with/without O=):

    #
    # Compiler: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
    #

which is definitely wrong when cross-compiling for m68k.

Reverting the commit, and fixing up the conflicts, fixes the issue for me

Do you have a clue?
Thanks!

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
Masahiro Yamada June 7, 2018, 8:58 a.m. UTC | #2
Hi Geert,


2018-06-07 17:42 GMT+09:00 Geert Uytterhoeven <geert@linux-m68k.org>:
> Hi Yamada-san,

>

> On Mon, May 28, 2018 at 11:21 AM, Masahiro Yamada

> <yamada.masahiro@socionext.com> wrote:

>> The kernel configuration phase is now tightly coupled with the compiler

>> in use.  It will be nice to show the compiler information in Kconfig.

>>

>> The compiler information will be displayed like this:

>>

>>   $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- config

>>   scripts/kconfig/conf  --oldaskconfig Kconfig

>>   *

>>   * Linux/arm64 4.16.0-rc1 Kernel Configuration

>>   *

>>   *

>>   * Compiler: aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011

>>   *

>>   *

>>   * General setup

>>   *

>>   Compile also drivers which will not load (COMPILE_TEST) [N/y/?]

>>

>> If you use GUI methods such as menuconfig, it will be displayed in the

>> top menu.

>>

>> This is simply implemented by using the 'comment' statement.  So, it

>> will be saved into the .config file as well.

>>

>> This commit has a very important meaning.  If the compiler is upgraded,

>> Kconfig must be re-run since different compilers have different sets

>> of supported options.

>>

>> All referenced environments are written to include/config/auto.conf.cmd

>> so that any environment change triggers syncconfig, and prompt the user

>> to input new values if needed.

>>

>> With this commit, something like follows will be added to

>> include/config/auto.conf.cmd

>>

>>   ifneq "$(CC_VERSION_TEXT)" "aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011"

>>   include/config/auto.conf: FORCE

>>   endif

>>

>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>> Reviewed-by: Kees Cook <keescook@chromium.org>

>

> This is now commit 21c54b774744719c ("kconfig: show compiler version text

> in the top comment") upstream.

>

> This commit broke cross-compilation for me:

>

>     $ make ARCH=m68k

>     scripts/kconfig/conf  --syncconfig Kconfig

>     scripts/kconfig/conf  --syncconfig Kconfig

>     scripts/kconfig/conf  --syncconfig Kconfig

>     scripts/kconfig/conf  --syncconfig Kconfig

>     ...

>

> with O=:

>

>       GEN     ./Makefile

>      scripts/kconfig/conf  --syncconfig Kconfig

>       GEN     ./Makefile

>     scripts/kconfig/conf  --syncconfig Kconfig

>       GEN     ./Makefile

>     scripts/kconfig/conf  --syncconfig Kconfig

>       GEN     ./Makefile

>     ...

>

> .config gained (both with/without O=):

>

>     #

>     # Compiler: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

>     #

>

> which is definitely wrong when cross-compiling for m68k.

>

> Reverting the commit, and fixing up the conflicts, fixes the issue for me

>

> Do you have a clue?

> Thanks!



Agh, I missed the case where CROSS_COMPILE is
set by arch/$(SRCARCH)/Makefile.


I will fix it.  Thanks for the report!






-- 
Best Regards
Masahiro Yamada
Masahiro Yamada June 8, 2018, 7:04 a.m. UTC | #3
Hi Geert,


2018-06-07 17:58 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> Hi Geert,

>

>

> 2018-06-07 17:42 GMT+09:00 Geert Uytterhoeven <geert@linux-m68k.org>:

>> Hi Yamada-san,

>>

>> On Mon, May 28, 2018 at 11:21 AM, Masahiro Yamada

>> <yamada.masahiro@socionext.com> wrote:

>>> The kernel configuration phase is now tightly coupled with the compiler

>>> in use.  It will be nice to show the compiler information in Kconfig.

>>>

>>> The compiler information will be displayed like this:

>>>

>>>   $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- config

>>>   scripts/kconfig/conf  --oldaskconfig Kconfig

>>>   *

>>>   * Linux/arm64 4.16.0-rc1 Kernel Configuration

>>>   *

>>>   *

>>>   * Compiler: aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011

>>>   *

>>>   *

>>>   * General setup

>>>   *

>>>   Compile also drivers which will not load (COMPILE_TEST) [N/y/?]

>>>

>>> If you use GUI methods such as menuconfig, it will be displayed in the

>>> top menu.

>>>

>>> This is simply implemented by using the 'comment' statement.  So, it

>>> will be saved into the .config file as well.

>>>

>>> This commit has a very important meaning.  If the compiler is upgraded,

>>> Kconfig must be re-run since different compilers have different sets

>>> of supported options.

>>>

>>> All referenced environments are written to include/config/auto.conf.cmd

>>> so that any environment change triggers syncconfig, and prompt the user

>>> to input new values if needed.

>>>

>>> With this commit, something like follows will be added to

>>> include/config/auto.conf.cmd

>>>

>>>   ifneq "$(CC_VERSION_TEXT)" "aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011"

>>>   include/config/auto.conf: FORCE

>>>   endif

>>>

>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>>> Reviewed-by: Kees Cook <keescook@chromium.org>

>>

>> This is now commit 21c54b774744719c ("kconfig: show compiler version text

>> in the top comment") upstream.

>>

>> This commit broke cross-compilation for me:

>>

>>     $ make ARCH=m68k

>>     scripts/kconfig/conf  --syncconfig Kconfig

>>     scripts/kconfig/conf  --syncconfig Kconfig

>>     scripts/kconfig/conf  --syncconfig Kconfig

>>     scripts/kconfig/conf  --syncconfig Kconfig

>>     ...

>>

>> with O=:

>>

>>       GEN     ./Makefile

>>      scripts/kconfig/conf  --syncconfig Kconfig

>>       GEN     ./Makefile

>>     scripts/kconfig/conf  --syncconfig Kconfig

>>       GEN     ./Makefile

>>     scripts/kconfig/conf  --syncconfig Kconfig

>>       GEN     ./Makefile

>>     ...

>>

>> .config gained (both with/without O=):

>>

>>     #

>>     # Compiler: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

>>     #

>>

>> which is definitely wrong when cross-compiling for m68k.

>>

>> Reverting the commit, and fixing up the conflicts, fixes the issue for me

>>

>> Do you have a clue?

>> Thanks!

>

>

> Agh, I missed the case where CROSS_COMPILE is

> set by arch/$(SRCARCH)/Makefile.

>

>

> I will fix it.  Thanks for the report!



I posted a patch.
https://patchwork.kernel.org/patch/10453685/

I hope it will fix your problem.


Thanks,

-- 
Best Regards
Masahiro Yamada
Geert Uytterhoeven June 8, 2018, 8:22 a.m. UTC | #4
Hi Yamada-san,

On Fri, Jun 8, 2018 at 9:04 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 2018-06-07 17:58 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:

>> 2018-06-07 17:42 GMT+09:00 Geert Uytterhoeven <geert@linux-m68k.org>:

>>> On Mon, May 28, 2018 at 11:21 AM, Masahiro Yamada

>>> <yamada.masahiro@socionext.com> wrote:

>>>> The kernel configuration phase is now tightly coupled with the compiler

>>>> in use.  It will be nice to show the compiler information in Kconfig.


[...]

>>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>>>> Reviewed-by: Kees Cook <keescook@chromium.org>

>>>

>>> This is now commit 21c54b774744719c ("kconfig: show compiler version text

>>> in the top comment") upstream.

>>>

>>> This commit broke cross-compilation for me:

>>>

>>>     $ make ARCH=m68k

>>>     scripts/kconfig/conf  --syncconfig Kconfig

>>>     scripts/kconfig/conf  --syncconfig Kconfig

>>>     scripts/kconfig/conf  --syncconfig Kconfig

>>>     scripts/kconfig/conf  --syncconfig Kconfig

>>>     ...

>>>

>>> with O=:

>>>

>>>       GEN     ./Makefile

>>>      scripts/kconfig/conf  --syncconfig Kconfig

>>>       GEN     ./Makefile

>>>     scripts/kconfig/conf  --syncconfig Kconfig

>>>       GEN     ./Makefile

>>>     scripts/kconfig/conf  --syncconfig Kconfig

>>>       GEN     ./Makefile

>>>     ...

>>>

>>> .config gained (both with/without O=):

>>>

>>>     #

>>>     # Compiler: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

>>>     #

>>>

>>> which is definitely wrong when cross-compiling for m68k.

>>>

>>> Reverting the commit, and fixing up the conflicts, fixes the issue for me

>>>

>>> Do you have a clue?

>>> Thanks!

>>

>>

>> Agh, I missed the case where CROSS_COMPILE is

>> set by arch/$(SRCARCH)/Makefile.

>>

>>

>> I will fix it.  Thanks for the report!

>

> I posted a patch.

> https://patchwork.kernel.org/patch/10453685/

>

> I hope it will fix your problem.


Yes it has. Thanks!

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
diff mbox series

Patch

diff --git a/Kconfig b/Kconfig
index 4af1b42..5b55d87 100644
--- a/Kconfig
+++ b/Kconfig
@@ -5,4 +5,6 @@ 
 #
 mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration"
 
+comment "Compiler: $(CC_VERSION_TEXT)"
+
 source "arch/$(SRCARCH)/Kconfig"
diff --git a/Makefile b/Makefile
index 58afa07..defb383 100644
--- a/Makefile
+++ b/Makefile
@@ -442,6 +442,8 @@  export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
 export KBUILD_ARFLAGS
 
+export CC_VERSION_TEXT := $(shell $(CC) --version | head -n 1)
+
 # When compiling out-of-tree modules, put MODVERDIR in the module
 # tree rather than in the kernel tree. The kernel tree might
 # even be read-only.
diff --git a/arch/x86/um/Kconfig b/arch/x86/um/Kconfig
index 6a15c4d..a992f8e 100644
--- a/arch/x86/um/Kconfig
+++ b/arch/x86/um/Kconfig
@@ -1,6 +1,8 @@ 
 # SPDX-License-Identifier: GPL-2.0
 mainmenu "User Mode Linux/$(SUBARCH) $(KERNELVERSION) Kernel Configuration"
 
+comment "Compiler: $(CC_VERSION_TEXT)"
+
 source "arch/um/Kconfig.common"
 
 menu "UML-specific options"