Skip to content

cuda: use target-specific paths under CUDA Toolkit on Linux #14612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MaxandreOgeret
Copy link

@MaxandreOgeret MaxandreOgeret commented May 15, 2025

fix #14595

This PR updates the cuda dependency to use target-specific include and library paths, such as /usr/local/cuda/targets/aarch64-linux/lib and /usr/local/cuda/targets/aarch64-linux/include, instead of defaulting to the host's /usr/local/cuda/lib64.

When cross-compiling, Meson currently:

  • Detects the CUDA library directory using the build machine's architecture, not the target's.
  • Hardcodes lib64 for aarch64, even though NVIDIA's toolchain uses lib under the target-specific path.
  • Ignores the targets/<arch>-<os> layout entirely, making it impossible to use
    CUDA_PATH=/usr/local/cuda/targets/aarch64-linux as a workaround.

This causes incorrect link paths and build failures when targeting non-x86_64 platforms.

Fix:

  • Use for_machine to determine the target architecture, not the host.
  • On Linux, always use lib under the target path, matching NVIDIA's layout.
  • Introduce self.target_path to resolve targets/- subdirectories for both include and lib paths.
  • Preserve existing behavior on Windows and macOS.

This fix only applies to Linux.

Tested with jetpack cuda 12.6 & jetpack cuda 10.2
I cannot test it on Windows or other.

Todo:

  • Add test for cuda cross

@MaxandreOgeret MaxandreOgeret requested a review from jpakkane as a code owner May 15, 2025 18:17
@MaxandreOgeret MaxandreOgeret force-pushed the cuda/target-specific-paths branch from c67e384 to 8fdd06b Compare May 15, 2025 18:24
@MaxandreOgeret MaxandreOgeret force-pushed the cuda/target-specific-paths branch 2 times, most recently from 9c73e90 to 2c30808 Compare May 15, 2025 18:59
@MaxandreOgeret MaxandreOgeret force-pushed the cuda/target-specific-paths branch 4 times, most recently from 1c2d0d3 to 4c0495d Compare May 18, 2025 19:45
@MaxandreOgeret MaxandreOgeret force-pushed the cuda/target-specific-paths branch from 4c0495d to 31a85b4 Compare May 19, 2025 07:47
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.

Meson CUDA dependency ignores target-specific CUDA library paths during cross-compilation (aarch64)
2 participants