Skip to content

samples/nvcuda: support Linux arm64 cross-compilation - #7420

Merged
AenBleidd merged 1 commit into
BOINC:masterfrom
qixuancao:fix/issue-7162
Nov 6, 2026
Merged

AenBleidd merged 1 commit into
BOINC:masterfrom
qixuancao:fix/issue-7162

Conversation

@qixuancao

@qixuancao qixuancao commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Currently, the samples/nvcuda sample application (example_app_nvcuda) is only built in Linux CI for native x86_64 (apps and apps-vcpkg), and is not cross-compiled for Linux arm64 (apps-arm64 and apps-vcpkg-arm64).

Change

Enable cross-compilation of samples/nvcuda/example_app_nvcuda for Linux arm64 (aarch64) using the NVIDIA CUDA SBSA cross-compilation toolkit:

  • .github/workflows/linux.yml:
    • Run the host CUDA toolkit installation step (cuda-toolkit-${{ env.CUDA_VERSION_MM }}) for apps-arm64 and apps-vcpkg-arm64 in addition to apps and apps-vcpkg so /usr/local/cuda/bin/nvcc and host build tools are available.
    • Add an Install CUDA for apps-arm64 and apps-vcpkg-arm64 step that installs cuda-repo-cross-sbsa-$distro_name-${{ env.CUDA_VERSION_MM }}-local_${{ env.CUDA_VERSION_MMP }}-1_all.deb and cuda-cross-sbsa-${{ env.CUDA_VERSION_MM }} (which populates /usr/local/cuda/targets/sbsa-linux/{include,lib}).
  • m4/cuda.m4 & samples/Makefile.am:
    • Select $cuda_root/targets/sbsa-linux (or $cuda_root/targets/aarch64-linux) as the target CUDA directory when $host_cpu is aarch64 or arm64, and choose lib64 or lib accordingly.
    • Verify that -lcudart links (AC_CHECK_LIB([cudart], [cudaMalloc], ...)) in addition to checking cuda_runtime.h, determine CUDA_CCBIN (falling back to ${CUDA_CCBIN##* } if CXX contains a compiler wrapper such as ccache), substitute CUDA_CCBIN via AC_SUBST, and export it in samples/Makefile.am.
  • samples/nvcuda/Makefile:
    • Detect arm64/aarch64 cross-compilation via RELEASE_ARCH, TARGET_ARCH, or aarch64 in CXX, and set CUDA_INCLUDE_PATH and CUDA_LIB_PATH to $(CUDA_INSTALL_PATH)/targets/sbsa-linux/{include,lib} (or targets/aarch64-linux).
    • Pass -ccbin "$(CUDA_CCBIN)" (defaulting CUDA_CCBIN ?= $(CXX) for standalone invokes) and the target include/library directories to $(CUDA_NVCC) when compiling cuda_kernel.cu.
    • Add an explicit cuda.o: cuda.cpp rule so GNU Make's built-in .cpp.o rule does not pass $(TARGET_ARCH) as a compiler flag if TARGET_ARCH is set in the environment.

Testing

  • Cross-compiled samples/nvcuda/example_app_nvcuda on Linux x86_64 targeting aarch64-linux-gnu (./configure --host=aarch64-linux ... with CXX=aarch64-linux-gnu-g++ and CUDA 13.3 + cuda-cross-sbsa-13-3):
    • Verified configure detects CUDA 13.3, cuda_runtime.h, -lcudart, and nvcc -ccbin aarch64-linux-gnu-g++.
    • Verified samples/nvcuda/example_app_nvcuda is built as an ELF 64-bit LSB pie executable, ARM aarch64 linked against libcudart.so.13.
  • Built samples/nvcuda/example_app_nvcuda natively on Linux x86_64 with CUDA 13.3 and verified the resulting x86-64 ELF executable.

Fixes #7162


Summary by cubic

Enables cross-compiling samples/nvcuda/example_app_nvcuda for Linux arm64 (aarch64) using the NVIDIA CUDA SBSA cross-compilation toolkit.

  • Installs cuda-toolkit and cuda-cross-sbsa in the Linux CI workflow for the apps-arm64 and apps-vcpkg-arm64 jobs.
  • Updates m4/cuda.m4 to select targets/sbsa-linux (or targets/aarch64-linux) CUDA directories when cross-compiling for arm64, verifies -lcudart links for the target, and checks nvcc works with -ccbin $CXX.
  • Exports CUDA_CCBIN from samples/Makefile.am so the sample Makefile picks up the host compiler.
  • Updates samples/nvcuda/Makefile to pass -ccbin "$(CUDA_CCBIN)" to nvcc and use target-specific CUDA include and library paths for arm64.

Fixes #7162

Written for commit d5ff887. Summary will update on new commits.

View guided diff

@qixuancao
qixuancao force-pushed the fix/issue-7162 branch 2 times, most recently from 94b0ddc to a84c448 Compare November 6, 2026 11:30
@qixuancao
qixuancao marked this pull request as ready for review November 6, 2026 11:30

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread m4/cuda.m4 Resolved
Comment thread m4/cuda.m4 Resolved
Enable cross-compiling samples/nvcuda/example_app_nvcuda for Linux arm64
(aarch64) using the NVIDIA CUDA SBSA cross-compilation toolkit:

- Install cuda-toolkit and cuda-cross-sbsa in the Linux CI workflow for
  apps-arm64 and apps-vcpkg-arm64 jobs.
- Update m4/cuda.m4 to select the target CUDA directory (targets/sbsa-linux
  or targets/aarch64-linux) when cross-compiling for arm64/aarch64, check
  that libcudart links for the target architecture, and verify nvcc works
  with -ccbin $CXX.
- Update samples/nvcuda/Makefile to pass -ccbin $(CXX) to nvcc and use the
  target-specific CUDA include and library directories when targeting
  arm64/aarch64.

Refs: BOINC#7162
Assisted-by: Antigravity:Gemini-4-Argon
@AenBleidd AenBleidd added this to the Client/Manager 8.2.16 milestone Nov 6, 2026
@github-project-automation github-project-automation Bot moved this to In progress in Client/Manager Nov 6, 2026
@AenBleidd
AenBleidd merged commit 9e1e215 into BOINC:master Nov 6, 2026
271 of 272 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Merged in Client/Manager Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

Cross-compile samples/nvcuda for Linux arm64

2 participants