blob: 6b8f9ca37c63113f0bcdb176969e3947d12ab44a (
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
|
Adapted from https://gitlab.archlinux.org/archlinux/packaging/packages/nvidia-utils/-/blob/11deaedbd194cacd732c44a902699a56d2d59d4b/0002-CFLAGS-Set-std-gnu17-for-all-compilation-flags.patch
"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."
diff --git a/Kbuild b/Kbuild
index 57eae87..b7cdfdf 100644
--- a/Kbuild
+++ b/Kbuild
@@ -68,6 +68,7 @@ $(foreach _module, $(NV_KERNEL_MODULES), \
# $(EXTRA_CFLAGS) to ccflags-y for compatibility.
#
+EXTRA_CFLAGS += -std=gnu17
EXTRA_CFLAGS += -I$(src)/common/inc
EXTRA_CFLAGS += -I$(src)
EXTRA_CFLAGS += -Wall -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-error -Wno-format-extra-args
diff --git a/conftest.sh b/conftest.sh
index c9a36e8..fc6a227 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -75,7 +75,7 @@ test_header_presence() {
# or more occurrences of "-MD" or "-MG", surrounded by whitespace to avoid
# accidental matches with tokens that happen to contain either of those
# strings, without special handling of the beginning or the end of the line.
- TEST_CFLAGS=`echo "-E -M $CFLAGS " | sed -e 's/\( -M[DG]\)* / /g'`
+ TEST_CFLAGS=`echo "-std=gnu17 -E -M $CFLAGS " | sed -e 's/\( -M[DG]\)* / /g'`
file="$1"
file_define=NV_`echo $file | tr '/.' '_' | tr '-' '_' | tr 'a-z' 'A-Z'`_PRESENT
@@ -99,7 +99,7 @@ test_header_presence() {
}
build_cflags() {
- 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"
|