Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,818
    • Issues 3,818
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 8
    • Merge requests 8
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #19702
Closed
Open
Created Sep 12, 2019 by sthlm58@sthlm58

Ninja generator for CUDA uses too many dependencies for CXX_SHARED_LIBRARY_DEVICE_LINKER

Short read:
When building a shared library containing CUDA code, Ninja build step to produce the cmake_device_link.obj (via CXX_SHARED_LIBRARY_DEVICE_LINKER__* rule) uses too many files as input (e.g. all the object files resulting from compiling *.cpp files). This is not needed and e.g. Visual Studio generator doesn't do that.

Long read:
I have a Windows shared library project containing CUDA code. When using CMake + Visual Studio 2017 to build, it builds just fine. But when using CMake + Ninja, the build fails when doing the device linking of cmake_device_link.obj because of "The command line is too long" error. Note that I'm already using CMake 3.15 (with the support for the response files). What I found out is that even when using nvcc response file (--options-file), it seems to forward somewhere the contents as a console arguments.

So I tried to understand why the Visual Studio linking succeeds and Ninja fails. After some investigation, the difference seems to be in the input files taken for linking the cmake_device_link.obj.

  • For the Visual Studio device-link (Task "CudaLink") the inputs are only the object files (*.obj) resulting from compilation of *.cu files
  • For the Ninja device-link (build.ninja file) the inputs are both the object files (*.obj) resulting from compilation of .cu files AND the object files (.obj) resulting from compilation of *.cpp file (of the same library)
    • But the *.obj files (of the *.cpp files) are only needed at the final step of linking the *.dll library (and not at the device-link stage)

Question:
Is this something that could be improved on the CMake level? E.g. to modify the inputs/dependencies of the device-link stage of Ninja generator?

Edited Sep 12, 2019 by sthlm58
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking