NVIDIA / NVIDIA/open-gpu-kernel-modules

C standard not set for conftest, results in build issues with gcc 15

Open
#827 0 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build-problem
Dominant language
C
Stars
17.4k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

NVIDIA Open GPU Kernel Modules Version

Version included with driver 570.133.07

Operating System and Version

Fedora release 42 (Adams)

Kernel Release

Linux ryzen9m 6.14.2-300.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Apr 10 21:50:55 UTC 2025 x86_64 GNU/Linux

Please confirm you are running a stable release kernel (e.g. not a -rc). We do not accept bug reports for unreleased kernels.
  • I am running on a stable kernel release.
Build Command

make modules

Terminal output/Build Log

out.txt

More Info

conftest.h fails to set a c standard version using -std=xyz.
In gcc 15 and up, which is being distributed with fedora 42, this defaults to c23.
The kernel currently requires gnu11 to compile. As version c23 is not backwards compatible the configuration tests will fail to compile.

Unfortunately the error produced barely relates to the issue so it ended up being quite arduous to find the cause.
Adding -std=gnu11 to the start of the $CFLAGS fixed this issue. Here the changes I've taken to make the project build:

@@ -69,10 +69,10 @@
     # 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="-std=gnu11 -E -M $CFLAGS"
-    TEST_CFLAGS="-E -M $CFLAGS"
 
     file="$1"
     file_define=NV_`echo $file | awk '{ gsub(/\.|\/|-/, "_", $1); print toupper($0) }'`_PRESENT
 
     CODE="#include <$file>"
 
@@ -94,7 +94,7 @@
 
 build_cflags() {
     ISYSTEM=`$CC -print-file-name=include 2> /dev/null`
+    BASE_CFLAGS="-std=gnu11 -O2 -D__KERNEL__ \
-    BASE_CFLAGS="-O2 -D__KERNEL__ \
 -DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \
 -nostdinc -isystem $ISYSTEM \
 -Wno-implicit-function-declaration -Wno-strict-prototypes"

Thanks for taking your time to resolve this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in conftest.h, focusing on the TEST_CFLAGS and build_cflags entry points shown in the report. Check how the compiler standard is selected, then run make modules with GCC 15; done means the configuration tests compile using the kernel-compatible standard and the reported build failure is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.