Skip to content

cmake add_custom_command() is not passing the ccbin flag to nvcc for the Fatbin and PTX cuda samples #446

Description

@philmcm

Using Version 13.3 of CUDA Toolkit on Fedora 44. The default GCC/G++ is version 16 and is unsupported by the cuda toolkit (> 15 not supported)

After generation of makefiles using the following command which passes older GCC/G++ compiler versions:
cmake -D CMAKE_C_COMPILER=gcc-15 -D CMAKE_CXX_COMPILER=g++-15 -D CMAKE_CUDA_HOST_COMPILER:STRING=g++-15 ..

nvcc is not receiving the correct compiler version via the cmake custom commands in a few samples. This only affects the samples involving the cmake custom commands used by fatbin and PTX related code. All other samples compile fine and run correctly.

I've introduced a workaround to the each of the affected CMakeLists.txt files to pass the compiler version:

Changed from:
add_custom_command(
...
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}
...
)

To:
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets -ccbin=${CMAKE_CUDA_HOST_COMPILER} ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}

Although I think there might be a more appropriate option to pass in this case.

The affected examples are:
0_Introduction/
matrixMulDrv
simpleDrvRuntime
simpleTextureDrv
vectorAddDrv
vectorAddMMAP
2_Concepts_and_Techniques/
threadMigration
3_CUDA_Features/
memMapIPCDrv
ptxjit

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions