Bug#984929: dkms: export CC pointing to the kernels compiler

2021-03-10 Thread Gianfranco Costamagna
Hello

done, feel free to just team upload when you have patches :)
(and maybe forward upstream please)

G.
On Wed, 10 Mar 2021 14:04:11 +0100 Andreas Beckmann  wrote:
> Package: dkms
> Version: 2.8.4-2
> Severity: important
> Tags: patch
> Control: block 984862 with -1
> Control: block 945506 with -1
> Control: block 946497 with -1
> 
> Third-party kernel module build systems using some kind of configure
> script need to know the compiler to use (which should be the compiler
> used to build the kernel) and usually fall back to CC=gcc.
> 
> The kernel compiler is available as CC inside Kbuild and we can get it
> from .kernelvariables in kernel headers packaged for Debian. There may
> be better and more general ways to get to this value ... but the
> attached patch seems to work well to fix the current failures (packages
> use gcc instead of gcc-X) and don't break other module builds.
> 
> It would be great if we can get this patch into bullseye as we can fix
> at least 3 RC-buggy packages that way.
> 
> Andreas



Bug#984929: dkms: export CC pointing to the kernels compiler

2021-03-10 Thread Andreas Beckmann
Package: dkms
Version: 2.8.4-2
Severity: important
Tags: patch
Control: block 984862 with -1
Control: block 945506 with -1
Control: block 946497 with -1

Third-party kernel module build systems using some kind of configure
script need to know the compiler to use (which should be the compiler
used to build the kernel) and usually fall back to CC=gcc.

The kernel compiler is available as CC inside Kbuild and we can get it
from .kernelvariables in kernel headers packaged for Debian. There may
be better and more general ways to get to this value ... but the
attached patch seems to work well to fix the current failures (packages
use gcc instead of gcc-X) and don't break other module builds.

It would be great if we can get this patch into bullseye as we can fix
at least 3 RC-buggy packages that way.

Andreas
>From 2e2490f29ef255352109010d8d7807f3f7405bd7 Mon Sep 17 00:00:00 2001
From: Andreas Beckmann 
Date: Wed, 10 Mar 2021 13:36:25 +0100
Subject: [PATCH] export CC= for non-Kbuild module build
 systems

---
 debian/changelog   |  8 
 debian/patches/export-CC.patch | 20 
 debian/patches/series  |  1 +
 3 files changed, 29 insertions(+)
 create mode 100644 debian/patches/export-CC.patch

diff --git a/debian/changelog b/debian/changelog
index 1743dcc..5be530d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+dkms (2.8.4-3) UNRELEASED; urgency=medium
+
+  * Export the CC variable from .kernelvariables in the kernel source to allow
+module build systems use the kernel's compiler also outside of Kbuild.
+(Closes: #xx)
+
+ -- Andreas Beckmann   Wed, 10 Mar 2021 12:11:42 +0100
+
 dkms (2.8.4-2) unstable; urgency=medium
 
   [ Gianfranco Costamagna ]
diff --git a/debian/patches/export-CC.patch b/debian/patches/export-CC.patch
new file mode 100644
index 000..1ae7e70
--- /dev/null
+++ b/debian/patches/export-CC.patch
@@ -0,0 +1,20 @@
+Description: export CC pointing to the kernel's compiler
+ export the CC variable from .kernelvariables in the kernel source to allow
+ module build systems use the kernel's compiler also outside of Kbuild
+Author: Andreas Beckmann 
+
+--- dkms-2.8.4.orig/dkms
 dkms-2.8.4/dkms
+@@ -1166,6 +1166,12 @@ prepare_kernel()
+ esac
+ }
+ 
++if [ -f "$kernel_source_dir/.kernelvariables" ]; then
++export CC=$(echo -e "show-%:\n\t@echo \$(\$*)\ninclude 
$kernel_source_dir/.kernelvariables" | make -f - show-CC)
++else
++unset CC
++fi
++
+ [[ $no_prepare_kernel ]] && return
+ 
+ if [[ (! ( $(VER $1) < $(VER 2.6.5) ) || -d /etc/SuSEconfig) && \
diff --git a/debian/patches/series b/debian/patches/series
index f3c2a3b..aa7de72 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 do-not-load-modules.patch
+export-CC.patch
-- 
2.20.1