Fix CUDA toolchain detection for Arch builds#406
Open
IldarMinaev wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix CUDA-enabled Arch builds by making the CUDA toolkit/compiler discovery explicit and by
propagating CUDA toolchain settings into the nested
whisper.cppCMake build.This changes:
arch/git/PKGBUILDandarch/release/PKGBUILDnvccfromCUDACXX,CUDAToolkit_ROOT,CUDA_PATH,CUDA_HOME,PATH, and finally the Archpackage fallback
/opt/cuda/bin/nvcc;CUDA_PATH,CUDAToolkit_ROOT, and the directory containingnvccbefore enablingBUILD_WHISPERCPP_CUBLAS;CUDAToolkit_ROOT,CMAKE_CUDA_COMPILER, and, when available,CMAKE_CUDA_HOST_COMPILER;CUDAHOSTCXX/NVCC_CCBINbefore falling back to Arch'sg++-15.cmake/whispercpp.cmakewhispercppcublasExternalProject;CMAKE_CUDA_STANDARD=17for the nested CUDA build.Problem
AUR package
dsnote-gitcurrently enablesBUILD_WHISPERCPP_CUBLASon Arch when thecudapackage is installed:That check is not sufficient for a non-interactive package build. Arch installs CUDA under
/opt/cuda, and theCUDA package's profile script adds
/opt/cuda/bintoPATHand setsNVCC_CCBIN=/usr/bin/g++-15. Package buildenvironments are not guaranteed to have that profile state loaded.
The result is that
BUILD_WHISPERCPP_CUBLAS=ONcan be enabled while the nestedwhisper.cppCMake configure stepcannot find
nvcc:On systems where
nvccis found, CUDA 13.x / CCCL also requires C++17 for CUDA sources. The top-level project usesC++17, but the nested
whisper.cppExternalProjectdid not receive an explicit CUDA standard. This can fail laterduring CUDA compilation with:
Why this follows upstream/toolchain behavior
CMake documents CUDA toolkit discovery in this order: the enabled CUDA compiler,
CMAKE_CUDA_COMPILER/CUDACXX,CUDAToolkit_ROOT,CUDA_PATH, thenPATH, with platform defaults only after that. See:CMake also documents
CUDAHOSTCXXas the preferred host compiler input for CUDA compilation, which is cached asCMAKE_CUDA_HOST_COMPILER:NVIDIA's Linux installation guide says CUDA post-install setup must put the toolkit
bindirectory inPATH, and itsFAQ explicitly points to missing
PATHsetup whennvccis not found:The Arch
cudapackage matches that model: it installs the toolkit under/opt/cuda, ships/etc/profile.d/cuda.shwith
CUDA_PATH=/opt/cuda, adds/opt/cuda/bintoPATH, and setsNVCC_CCBIN=/usr/bin/g++-15.Why this is not only a local setup issue
The current package logic enables CUDA based only on package presence. That works only if the build environment already
has the CUDA profile loaded. A clean AUR helper / makepkg environment can have
cudainstalled but still not exposenvccthroughPATH.This fix keeps user-configured CUDA locations working (
CUDACXX,CUDAToolkit_ROOT,CUDA_PATH,CUDA_HOME,PATH)and uses
/opt/cudaonly as the Arch-package fallback. It does not require all systems to install CUDA in/opt/cuda.Verification
On Arch/CachyOS with:
cuda 13.3.1gcc15cmake 4.3.4I verified a clean CMake build of the CUDA
ExternalProjectpath:The generated nested configure command includes:
The build completed successfully: