diff mbox series

[langdale,09/14] kernel-devsrc: fix mismatched compiler warning

Message ID a122e5b914d59ceaa10ddb66e8611c31f0fb958d.1680210378.git.steve@sakoman.com
State New
Headers show
Series [langdale,01/14] python3-setuptools: fix for CVE-2022-40897 | expand

Commit Message

Steve Sakoman March 30, 2023, 9:13 p.m. UTC
From: Bruce Ashfield <bruce.ashfield@gmail.com>

When building a module on target, we use the native compiler
(always "gcc") versus the same compiler, but named in a cross
compiler manner, for the kernel build.

The kernel captures the compiler string in several places,
some of which we are already fixing, but others we are not
(as they don't cause issues).

But when building an on target module, the main kernel Makefile
compares compiler strings and outputs a warning similar to:

  warning: the compiler differs from the one used to build the kernel
    The kernel was built by: x86_64-poky-linux-gcc (GCC) 11.3.0
    You are using:           gcc (GCC) 11.3.0

We drop the cross compilation prefix from the captured compiler
string, and we avoid the warning.

RP: tweaked one sed expression to fix quoting issue with 5.15
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 70419f281a4571d01975bd79a47a6ed7ae70b1ae)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
 meta/recipes-kernel/linux/kernel-devsrc.bb | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series


diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
index 46d706b955..17ae744d0d 100644
--- a/meta/recipes-kernel/linux/kernel-devsrc.bb
+++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
@@ -308,6 +308,13 @@  do_install() {
     # external modules can be built
     touch -r $kerneldir/build/Makefile $kerneldir/build/include/generated/uapi/linux/version.h
+    # This fixes a warning that the compilers don't match when building a module
+    # Change: CONFIG_CC_VERSION_TEXT="x86_64-poky-linux-gcc (GCC) 12.2.0" to "gcc (GCC) 12.2.0"
+    #         #define CONFIG_CC_VERSION_TEXT "x86_64-poky-linux-gcc (GCC) 12.2.0" to "gcc (GCC) 12.2.0"
+    sed -i 's/CONFIG_CC_VERSION_TEXT=".*\(gcc.*\)"/CONFIG_CC_VERSION_TEXT="\1"/' "$kerneldir/build/.config"
+    sed -i 's/#define CONFIG_CC_VERSION_TEXT ".*\(gcc.*\)"/#define CONFIG_CC_VERSION_TEXT "\1"/' $kerneldir/build/include/generated/autoconf.h
+    sed -i 's/CONFIG_CC_VERSION_TEXT=".*\(gcc.*\)"/CONFIG_CC_VERSION_TEXT="\1"/' $kerneldir/build/include/config/auto.conf
     # make sure these are at least as old as the .config, or rebuilds will trigger
     touch -r $kerneldir/build/.config $kerneldir/build/include/generated/autoconf.h 2>/dev/null || :
     touch -r $kerneldir/build/.config $kerneldir/build/include/config/auto.conf* 2>/dev/null || :