summarylogtreecommitdiffstats
path: root/0002-CFLAGS-Set-std-gnu17-for-all-compilation-flags.patch
blob: 61fc2e1b7c81227412685b58a9bbbdd90e585bf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 843e7b26f926e243dccf05a45d541b7879fecd0e Mon Sep 17 00:00:00 2001
From: Peter Jung <admin@ptr1337.dev>
Date: Wed, 11 Jun 2025 16:08:29 +0300
Subject: [PATCH] CFLAGS: Set -std=gnu17 for all compilation flags

GCC15 uses C23 by default, which breaks a lot of compatibility with the
kernel and this module. Explicitly use -std=gnu17, which is what the
kernel uses across the project.

Signed-off-by: Peter Jung <admin@ptr1337.dev>
Signed-off-by: Eric Naim <dnaim@cachyos.org>
Signed-off-by: Vasiliy Stelmachenok <ventureo@cachyos.org>
---
 Kbuild      | 1 +
 conftest.sh | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Kbuild b/Kbuild
index 28db89e..bd69c0d 100644
--- a/Kbuild
+++ b/Kbuild
@@ -75,6 +75,7 @@ $(foreach _module, $(NV_KERNEL_MODULES), \
  $(eval include $(src)/$(_module)/$(_module).Kbuild))
 
 
+ccflags-y += -std=gnu17
 ccflags-y += -I$(src)/common/inc
 ccflags-y += -I$(src)
 ccflags-y += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args
diff --git a/conftest.sh b/conftest.sh
index 20f694e..0019e67 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -69,7 +69,7 @@ test_header_presence() {
     # NV_LINUX_FENCE_H_PRESENT, and that is either defined or undefined, in the
     # output (which goes to stdout, just like the rest of this file).
 
-    TEST_CFLAGS="-E -M $CFLAGS"
+    TEST_CFLAGS="-std=gnu17 -E -M $CFLAGS"
 
     file="$1"
     file_define=NV_`echo $file | tr '/.-' '___' | tr 'a-z' 'A-Z'`_PRESENT
@@ -94,7 +94,7 @@ test_header_presence() {
 
 build_cflags() {
     ISYSTEM=`$CC -print-file-name=include 2> /dev/null`
-    BASE_CFLAGS="-O2 -D__KERNEL__ \
+    BASE_CFLAGS="-std=gnu17 -O2 -D__KERNEL__ \
 -DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \
 -nostdinc -isystem $ISYSTEM \
 -Wno-implicit-function-declaration -Wno-strict-prototypes"
-- 
2.49.0