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

Merged

Conversation

MaxandreOgeret
Copy link
Contributor

@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 7 times, most recently from 4c0495d to 31a85b4 Compare May 19, 2025 07:47
@MaxandreOgeret MaxandreOgeret force-pushed the cuda/target-specific-paths branch 3 times, most recently from e458f1c to 80251a0 Compare May 25, 2025 19:59
@eli-schwartz
Copy link
Member

@obilaniu @SoapGentoo

@MaxandreOgeret MaxandreOgeret force-pushed the cuda/target-specific-paths branch from 80251a0 to 16b2c3c Compare May 27, 2025 17:56
@MaxandreOgeret MaxandreOgeret force-pushed the cuda/target-specific-paths branch from 16b2c3c to c1d828b Compare May 27, 2025 18:42
@eli-schwartz eli-schwartz merged commit 7d56790 into mesonbuild:master May 29, 2025
37 of 40 checks passed
@bonzini bonzini added this to the 1.8.2 milestone May 29, 2025
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)
5 participants