diff mbox series

[RFC,5/7] kconfig: invoke silentoldconfig when compiler is updated

Message ID 1518106752-29228-6-git-send-email-yamada.masahiro@socionext.com
State New
Headers show
Series Kconfig: add new special property shell= to test compiler options in Kconfig | expand

Commit Message

Masahiro Yamada Feb. 8, 2018, 4:19 p.m. UTC
Moving compiler option tests to Kconfig means you need to re-run
Kconfig when you update your compiler.  All CC_HAS_... symbols
and other symbols that depend on them must be re-calculated.

It will be nice to detect the compiler update and automatically
invoke silentoldconfig.

This can be done by adding one environment.  With this, silentoldconfig
will add something like follows into include/config/auto.conf.cmd:

ifneq "$(CC_VERSION_TEXT)" "gcc (Ubuntu 5.4.0-6ubuntu1~16.04.6) 5.4.0 20160609"
include/config/auto.conf: FORCE
endif

CC_VERSION_TEXT contains the first line of "$(CC) --version".  If this text
is changed, silentoldconfig will be invoked.

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

---

 Makefile     | 2 ++
 init/Kconfig | 9 +++++++++
 2 files changed, 11 insertions(+)

-- 
2.7.4

Comments

Masahiro Yamada Feb. 8, 2018, 5:19 p.m. UTC | #1
2018-02-09 1:19 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> Moving compiler option tests to Kconfig means you need to re-run

> Kconfig when you update your compiler.  All CC_HAS_... symbols

> and other symbols that depend on them must be re-calculated.

>

> It will be nice to detect the compiler update and automatically

> invoke silentoldconfig.

>

> This can be done by adding one environment.  With this, silentoldconfig

> will add something like follows into include/config/auto.conf.cmd:

>

> ifneq "$(CC_VERSION_TEXT)" "gcc (Ubuntu 5.4.0-6ubuntu1~16.04.6) 5.4.0 20160609"

> include/config/auto.conf: FORCE

> endif

>

> CC_VERSION_TEXT contains the first line of "$(CC) --version".  If this text

> is changed, silentoldconfig will be invoked.

>

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



Currently, the updated compiler
is detected only when building the kernel.


External modules should be built by the
same compiler as used for building the kernel.

If a different compiler is used,
different options will be specified by
CONFIG_CC_HAS_... options from the .config


Should this be checked?
Or, is it just "Don't do it" thing?


If desired, CONFIG_CC_VERSION_TEXT is cached in .config
then it will be possible to compare it with $(shell $(CC) --version)
when building external modules.



>

>  Makefile     | 2 ++

>  init/Kconfig | 9 +++++++++

>  2 files changed, 11 insertions(+)

>

> diff --git a/Makefile b/Makefile

> index 2ee49c9..9afd617 100644

> --- a/Makefile

> +++ b/Makefile

> @@ -441,6 +441,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/init/Kconfig b/init/Kconfig

> index e37f4b2..64f9dd2 100644

> --- a/init/Kconfig

> +++ b/init/Kconfig

> @@ -16,6 +16,15 @@ config DEFCONFIG_LIST

>         default "$ARCH_DEFCONFIG"

>         default "arch/$ARCH/defconfig"

>

> +# CC_VERSION_TEXT is needed here to invoke Kconfig when compiler is updated

> +config CC_VERSION_TEXT

> +       string

> +       option env="CC_VERSION_TEXT"

> +       help

> +         This is used to detect if the compiler is changed. If the version

> +         text does not match, silentoldconfig will be invoked because we need

> +         to re-compute compiler capabilities and symbols that depends on them.

> +

>  config CONSTRUCTORS

>         bool

>         depends on !UML

> --

> 2.7.4

>




-- 
Best Regards
Masahiro Yamada
Linus Torvalds Feb. 8, 2018, 5:45 p.m. UTC | #2
On Thu, Feb 8, 2018 at 9:19 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>

> Should this be checked?

> Or, is it just "Don't do it" thing?


I think it's probably a "Don't do it".

In fact, maybe we should just make it very explicit that you need to
re-run "make *config" by hand if you have updated your compiler.

So instead of your "run silentoldconfig" if the compiler version has
changed, just literally error out and say "compiler has changed,
re-run configuration".

That way there are no subtle silent failures where you might end up -
by mistake - building just modules with a new compiler and different
options. Because people would be *aware* of the re-configuration.

Anyway, I suspect this is a tiny detail that we don't have to set in
stone right now. Maybe worry about it more when/if it actually becomes
something that people notice?

              Linus
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 2ee49c9..9afd617 100644
--- a/Makefile
+++ b/Makefile
@@ -441,6 +441,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/init/Kconfig b/init/Kconfig
index e37f4b2..64f9dd2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -16,6 +16,15 @@  config DEFCONFIG_LIST
 	default "$ARCH_DEFCONFIG"
 	default "arch/$ARCH/defconfig"
 
+# CC_VERSION_TEXT is needed here to invoke Kconfig when compiler is updated
+config CC_VERSION_TEXT
+	string
+	option env="CC_VERSION_TEXT"
+	help
+	  This is used to detect if the compiler is changed. If the version
+	  text does not match, silentoldconfig will be invoked because we need
+	  to re-compute compiler capabilities and symbols that depends on them.
+
 config CONSTRUCTORS
 	bool
 	depends on !UML