Skip to content

Detect the host compiler instead of hardcoding gcc-15 - #2

Merged
TGPSKI merged 1 commit into
mainfrom
fix/host-compiler-detection
Aug 4, 2026
Merged

Detect the host compiler instead of hardcoding gcc-15#2
TGPSKI merged 1 commit into
mainfrom
fix/host-compiler-detection

Conversation

@TGPSKI

@TGPSKI TGPSKI commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Follow-on to #1, found by running the first build through to its next failure.

make check-env passed, then twelve minutes of clone and submodule sync later cmake said:

The CMAKE_CXX_COMPILER: /usr/bin/g++-15
is not a full path to an existing compiler tool.

cuda-env.sh hardcoded CC=/usr/bin/gcc-15, and check-env printed that path without ever testing it. On a host that never installed gcc 15 — CUDA runfile run directly, rather than through install-cuda-toolkit.sh, which does check — the gate passed on a machine that could not compile.

Changes

  • cuda-env.sh probes for the host compiler: gcc-15, gcc-14, gcc-13, then plain gcc. Versioned first is deliberate — nvcc refuses a host compiler newer than the cap in its own crt/host_config.h, CUDA 13.3 stops at gcc 15, and a rolling distro's default runs ahead of that (Manjaro is on 16). The unversioned binary is the fallback, not the preference. CC/CXX still win if already exported.
  • check-env validates the result: CC and CXX must be executable, and the resolved gcc major must not exceed the cap parsed out of $CUDA_HOME/include/crt/host_config.h. Both failures name the package to install.
  • README: prerequisites now state the gcc cap and what check-env enforces.

Verification

On a box with gcc 16 as the system default and gcc15 installed alongside: detection resolves /usr/bin/gcc-15; a nonexistent CC fails check-env with the install hint; CC=/usr/bin/gcc (16) fails with is gcc 16, and this CUDA supports up to gcc 15; and the probe falls back to the unversioned binary only when no versioned one exists. make check passes with the CI-pinned shellcheck 0.11.0.

cuda-env.sh hardcoded CC=/usr/bin/gcc-15, and check-env printed that path
without ever testing it. On a host that never installed gcc 15 — the CUDA
runfile installed directly rather than through install-cuda-toolkit.sh, which
does check — the gate passed, and the build died in cmake twelve minutes
later, after a 1.4 GB clone and a full submodule sync:

  The CMAKE_CXX_COMPILER: /usr/bin/g++-15
  is not a full path to an existing compiler tool.

The compiler is now probed: gcc-15, gcc-14, gcc-13, then plain gcc. Versioned
binaries come first deliberately. nvcc refuses a host compiler newer than the
cap in its own crt/host_config.h, CUDA 13.3 stops at gcc 15, and a rolling
distro's default runs ahead of that — Manjaro is on 16 — so the unversioned
binary is the fallback, not the preference.

check-env now earns its "fails fast on anything missing" claim for the
compiler too: CC and CXX must be executable, and the resolved gcc major must
not exceed the cap parsed out of the toolkit's own host_config.h. Both
failures name the package to install.

Verified on this machine: detection resolves gcc-15 with gcc 16 as the system
default, a missing compiler and an over-cap compiler each fail check-env with
an actionable message, and the probe falls back to the unversioned binary only
when no versioned one exists.
@TGPSKI
TGPSKI merged commit f3d36d7 into main Aug 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant