diff mbox series

[v2,12/21] kconfig: show compiler version text in the top comment

Message ID 1522128575-5326-13-git-send-email-yamada.masahiro@socionext.com
State Superseded
Headers show
Series kconfig: move compiler capability tests to Kconfig | expand

Commit Message

Masahiro Yamada March 27, 2018, 5:29 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 'comment'.  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>

---

Changes in v2: None

 Kconfig  | 2 ++
 Makefile | 2 ++
 2 files changed, 4 insertions(+)

-- 
2.7.4

Comments

Kees Cook March 28, 2018, 3:26 a.m. UTC | #1
On Mon, Mar 26, 2018 at 10:29 PM, 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 'comment'.  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>


I like seeing this in the config. Good idea!

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


-Kees

> ---

>

> Changes in v2: None

>

>  Kconfig  | 2 ++

>  Makefile | 2 ++

>  2 files changed, 4 insertions(+)

>

> diff --git a/Kconfig b/Kconfig

> index e6ece5b..99ed4b8 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 5cadffa..3dc9eb8 100644

> --- a/Makefile

> +++ b/Makefile

> @@ -450,6 +450,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.

> --

> 2.7.4

>




-- 
Kees Cook
Pixel Security
diff mbox series

Patch

diff --git a/Kconfig b/Kconfig
index e6ece5b..99ed4b8 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 5cadffa..3dc9eb8 100644
--- a/Makefile
+++ b/Makefile
@@ -450,6 +450,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.