Skip to content

fix: make the CUDA language link the shared runtime (Windows sm_70 LNK1169, #585) - #717

Closed
noahark wants to merge 1 commit into
Niko1221:mainfrom
noahark:fix-win-sm70-cudart-link
Closed

noahark wants to merge 1 commit into
Niko1221:mainfrom
noahark:fix-win-sm70-cudart-link

Conversation

@noahark

@noahark noahark commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #585.

The final link of strata.exe failed on a Windows sm_70 source build (MSVC 14.44, CUDA 12.4):
cudart_static.lib(...) raised LNK2005 for every runtime symbol already defined in
cudart.lib(cudart64_12.dll), ending in LNK1169. Root cause: enable_language(CUDA) links the
runtime per CMAKE_CUDA_RUNTIME_LIBRARY (default Static -> cudart_static.lib), while the
project also links the imported CUDA::cudart target explicitly - both libraries on one link line.
GNU ld tolerates the duplicates, which is why the Pascal/Volta path (#295, tested on Linux) never
hit this on Linux.

The fix sets the language runtime to Shared so it agrees with the explicit CUDA::cudart
links, guarded by if(NOT DEFINED ...) so a user's explicit -D still wins.

Verified on the reporting machine (V100-PCIE-32GB, Windows, CUDA 12.4 + MSVC):

The CUDA language's default runtime link is static (CMAKE_CUDA_RUNTIME_LIBRARY
defaults to "Static", cudart_static.lib) while the targets link the imported
CUDA::cudart explicitly, so both libraries land on the link line. MSVC rejects
the duplicated runtime symbols (LNK2005/LNK1169) - seen on a Windows sm_70
source build - while GNU ld tolerates them, so Linux builds never noticed.
"Shared" makes the language rule agree with CUDA::cudart; an explicit -D
still wins.
@noahark

noahark commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing — the official fix landed in v0.1.39: CMakeLists now sets CMAKE_CUDA_RUNTIME_LIBRARY Shared (under an MSVC AND STRATA_EXPERIMENTAL_SM60 guard, -D still wins) before enable_language(CUDA), which covers the sm_70 MSVC path reported in #585. Verified equivalent to this PR's approach on our box. Thanks for tracking it.

@noahark noahark closed this Oct 4, 2026
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.

Windows: source build for sm_70 (Volta) fails to link - LNK1169 (cudart_static.lib vs cudart.lib)

1 participant