From a47b422205a1be173e14ffa216e974b3d8c44a6a Mon Sep 17 00:00:00 2001 From: shawnz Date: Wed, 11 Jun 2025 16:32:09 +0800 Subject: [PATCH] Update CHANGELOG.md and README.md for QNX cross build --- CHANGELOG.md | 1 + README.md | 11 ++++++++--- cmake/toolchains/toolchain-aarch64-qnx.cmake | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19cc5391..cb70c6f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ * `simpleCUFFT_2d_MGPU` * `simpleCUFFT_MGPU` * `simpleCUFFT_callback` +* Updated toolchain for cross-compilation for Tegra QNX platforms. ### CUDA 12.9 * Updated toolchain for cross-compilation for Tegra Linux platforms. diff --git a/README.md b/README.md index 6c45cca9..e8deb49e 100644 --- a/README.md +++ b/README.md @@ -135,9 +135,14 @@ $ cmake -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DCMAKE_LIBRARY_PATH=/usr ### QNX -Note that in the current branch sample cross-compilation for QNX is not fully validated. This placeholder will be updated in the -near future with QNX cross-compilation instructions. In the meantime, if you want to cross-compile for QNX please check out one -of the previous tags prior to the CMake build system transition in 12.8. +The sample cross-compilation for QNX is supported since v13.0 CUDA Samples. An example build for Tegra Thor QNX platform might like this: + +``` +$ mkdir build +$ cd build + +QNX_HOST=/path/to/qnx/host QNX_TARGET=/path/to/qnx/target cmake .. -DBUILD_TEGRA=True -DCMAKE_CUDA_COMPILER=/usr/local/cuda-safe-13.0/bin/nvcc -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/toolchain-aarch64-qnx.cmake -DCMAKE_LIBRARY_PATH=/usr/local/cuda-safe-13.0/thor/targets/aarch64-qnx/lib/stubs/ -DCMAKE_INCLUDE_PATH=/usr/local/cuda-safe-13.0/thor/targets/aarch64-qnx/include/ +``` ## Running All Samples as Tests diff --git a/cmake/toolchains/toolchain-aarch64-qnx.cmake b/cmake/toolchains/toolchain-aarch64-qnx.cmake index 55cf5fbe..df9839b8 100644 --- a/cmake/toolchains/toolchain-aarch64-qnx.cmake +++ b/cmake/toolchains/toolchain-aarch64-qnx.cmake @@ -1,18 +1,28 @@ set(CMAKE_SYSTEM_NAME QNX) set(CMAKE_SYSTEM_PROCESSOR aarch64) +# Need to set the QNX_HOST and QNX_TARGET environment variables set(QNX_HOST $ENV{QNX_HOST}) set(QNX_TARGET $ENV{QNX_TARGET}) message(STATUS "QNX_HOST = ${QNX_HOST}") message(STATUS "QNX_TARGET = ${QNX_TARGET}") -set(CMAKE_C_COMPILER ${QNX_HOST}/usr/bin/qcc) -set(CMAKE_CXX_COMPILER ${QNX_HOST}/usr/bin/q++) +find_program(QNX_QCC NAMES qcc PATHS "${QNX_HOST}/usr/bin") +find_program(QNX_QPLUS NAMES q++ PATHS "${QNX_HOST}/usr/bin") + +if(NOT QNX_QCC OR NOT QNX_QPLUS) + message(FATAL_ERROR "Could not find qcc or q++ in QNX_HOST=${QNX_HOST}/usr/bin") +endif() + +# Specify the cross-compilers +set(CMAKE_C_COMPILER ${QNX_QCC}) +set(CMAKE_CXX_COMPILER ${QNX_QPLUS}) set(CMAKE_C_COMPILER_TARGET aarch64) set(CMAKE_CXX_COMPILER_TARGET aarch64) +# Set compiler flags set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING "" FORCE) set(CMAKE_CUDA_COMPILER_ID_TEST_FLAGS_FIRST "-nodlink -L${CUDA_ROOT}/lib64 -L${CUDA_ROOT}/lib -I${CUDA_ROOT}/include")