diff --git a/CMakeLists.txt b/CMakeLists.txt index 88e03e81b..4626a2392 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -656,6 +656,32 @@ IF (NOT JFJOCH_WRITER_ONLY AND NOT JFJOCH_PORTABLE_ONLY) INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/frontend/dist/ DESTINATION share/jfjoch/frontend COMPONENT jfjoch ) ENDIF() +# libcufft_static.a carries a relocatable-device-code object (separate_callback.o), so an executable +# linking it needs a CUDA device-link step -- without it the host link fails on an undefined +# __cudaRegisterLinkedBinary_* symbol. CUDA 13 no longer ships libcufft_static_nocallback.a, which +# used to be the way around it. CUDA_RESOLVE_DEVICE_SYMBOLS makes CMake emit that step while leaving +# the host link driver alone, so the -march/-flto flags CI passes still apply. Set on every executable +# and shared library of this source tree, as nearly all of them link the image analysis. +FUNCTION(JFJOCH_RESOLVE_DEVICE_SYMBOLS dir) + GET_PROPERTY(_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) + FOREACH(_target IN LISTS _targets) + GET_TARGET_PROPERTY(_type ${_target} TYPE) + IF (_type MATCHES "EXECUTABLE|SHARED_LIBRARY|MODULE_LIBRARY") + SET_TARGET_PROPERTIES(${_target} PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON) + ENDIF() + ENDFOREACH() + GET_PROPERTY(_subdirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) + FOREACH(_subdir IN LISTS _subdirs) + STRING(FIND "${_subdir}" "${CMAKE_SOURCE_DIR}/" _position) + IF (_position EQUAL 0) # not the fetched dependencies + JFJOCH_RESOLVE_DEVICE_SYMBOLS(${_subdir}) + ENDIF() + ENDFOREACH() +ENDFUNCTION() +IF (JFJOCH_CUDA_AVAILABLE AND TARGET CUDA::cufft_static) + JFJOCH_RESOLVE_DEVICE_SYMBOLS(${CMAKE_SOURCE_DIR}) +ENDIF() + # Windows has no static cuFFT (the toolkit ships no cufft_static.lib), so there the indexer links # the import library and the self-contained products must carry the DLL beside the executable -- # the same idea the Linux builds no longer need, since they link libcufft_static.a. CUDA 13 keeps diff --git a/image_analysis/geom_refinement/CMakeLists.txt b/image_analysis/geom_refinement/CMakeLists.txt index a82fee507..74659539b 100644 --- a/image_analysis/geom_refinement/CMakeLists.txt +++ b/image_analysis/geom_refinement/CMakeLists.txt @@ -47,7 +47,7 @@ IF (JFJOCH_CUDA_AVAILABLE) BeamCenterBackgroundGPU.cu BeamCenterBackgroundGPU.h) # Same static/dynamic cuFFT choice as the FFT indexer, and for the same reasons - see the long # note in image_analysis/indexing/CMakeLists.txt. - IF (JFJOCH_PORTABLE_ONLY AND TARGET CUDA::cufft_static) + IF (TARGET CUDA::cufft_static) TARGET_LINK_LIBRARIES(JFJochGeomRefinement CUDA::cufft_static) ELSE() TARGET_LINK_LIBRARIES(JFJochGeomRefinement CUDA::cufft) diff --git a/image_analysis/indexing/CMakeLists.txt b/image_analysis/indexing/CMakeLists.txt index e7d787197..66f005b10 100644 --- a/image_analysis/indexing/CMakeLists.txt +++ b/image_analysis/indexing/CMakeLists.txt @@ -51,10 +51,10 @@ IF (JFJOCH_CUDA_AVAILABLE) # and the dynamic library is the only option; the top-level CMakeLists installs the DLL beside # the executable for the self-contained builds. Test the target rather than the platform, so a # toolkit that gains or loses the static library is handled without another special case. - # Both halves matter: the server build keeps the shared library (its .deb/.rpm take CUDA from the - # distro, and every executable there -- broker, tests, tools -- would otherwise need the device - # link below), and Windows has no static cuFFT to link even for the portable products. - IF (JFJOCH_PORTABLE_ONLY AND TARGET CUDA::cufft_static) + # The server build links it statically too, so its executables (broker, tools copied to another + # machine) need no CUDA toolkit library; the top-level CMakeLists gives every executable the device + # link this needs. + IF (TARGET CUDA::cufft_static) TARGET_LINK_LIBRARIES(JFJochIndexing fast_indexer_static CUDA::cufft_static) ELSE() TARGET_LINK_LIBRARIES(JFJochIndexing fast_indexer_static CUDA::cufft) diff --git a/rugnux/CMakeLists.txt b/rugnux/CMakeLists.txt index 12db3d061..132d93764 100644 --- a/rugnux/CMakeLists.txt +++ b/rugnux/CMakeLists.txt @@ -66,14 +66,6 @@ IF(APPLE AND JFJOCH_MACOS_SIGNING_IDENTITY) COMPONENT rugnux) ENDIF() -# libcufft_static.a carries a relocatable-device-code object (separate_callback.o), so an executable -# linking it needs a CUDA device-link step -- without it the host link fails on an undefined -# __cudaRegisterLinkedBinary_* symbol. CUDA 13 no longer ships libcufft_static_nocallback.a, which -# used to be the way around it. CUDA_RESOLVE_DEVICE_SYMBOLS makes CMake emit that step while leaving -# the host link driver alone, so the -march/-flto flags CI passes still apply. -IF (JFJOCH_PORTABLE_ONLY AND JFJOCH_CUDA_AVAILABLE AND TARGET CUDA::cufft_static) - SET_TARGET_PROPERTIES(rugnux PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON) -ENDIF() # On Windows this CLI gets getopt/getopt_long from the vendored wingetopt shim (libc has none). diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f30cb28c6..ed7af1f68 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -47,10 +47,6 @@ ADD_EXECUTABLE(jfjoch_portable_test EXCLUDE_FROM_ALL target_link_libraries(jfjoch_portable_test Catch2WithMain JFJochRugnux JFJochReader JFJochImageAnalysis JFJochWriter JFJochAPIConvert JFJochCommon) target_include_directories(jfjoch_portable_test PRIVATE .) -# Same device-link step as rugnux (see rugnux/CMakeLists.txt): a portable CUDA build links cuFFT statically. -IF (JFJOCH_PORTABLE_ONLY AND JFJOCH_CUDA_AVAILABLE AND TARGET CUDA::cufft_static) - SET_TARGET_PROPERTIES(jfjoch_portable_test PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON) -ENDIF() # The CPU vs GPU test of the fast-feedback indexer reads the library's own test spot lists IF (JFJOCH_CUDA_AVAILABLE) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9fdf2e2a9..74d302a1c 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -18,10 +18,6 @@ TARGET_LINK_LIBRARIES(jfjoch_extract_hkl JFJochReader) # measuring the refinement on battery outputs without processing anything again. ADD_EXECUTABLE(rugnux_refine_test rugnux_refine_test.cpp) TARGET_LINK_LIBRARIES(rugnux_refine_test JFJochStructureRefinement JFJochCommon gemmi) -# Same device-link step as rugnux (see rugnux/CMakeLists.txt): a portable CUDA build links cuFFT statically. -IF (JFJOCH_PORTABLE_ONLY AND JFJOCH_CUDA_AVAILABLE AND TARGET CUDA::cufft_static) - SET_TARGET_PROPERTIES(rugnux_refine_test PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON) -ENDIF() # In-place re-compress /entry/data/data of a _data file from bitshuffle/LZ4 to bitshuffle/zstd. ADD_EXECUTABLE(jfjoch_recompress jfjoch_recompress.cpp) diff --git a/viewer/CMakeLists.txt b/viewer/CMakeLists.txt index 0345b7587..ec62a3b68 100644 --- a/viewer/CMakeLists.txt +++ b/viewer/CMakeLists.txt @@ -184,14 +184,6 @@ IF(APPLE) PATTERN "COLLECT.sh" EXCLUDE) ENDIF() -# libcufft_static.a carries a relocatable-device-code object (separate_callback.o), so an executable -# linking it needs a CUDA device-link step -- without it the host link fails on an undefined -# __cudaRegisterLinkedBinary_* symbol. CUDA 13 no longer ships libcufft_static_nocallback.a, which -# used to be the way around it. CUDA_RESOLVE_DEVICE_SYMBOLS makes CMake emit that step while leaving -# the host link driver alone, so the -march/-flto flags CI passes still apply. -IF (JFJOCH_PORTABLE_ONLY AND JFJOCH_CUDA_AVAILABLE AND TARGET CUDA::cufft_static) - SET_TARGET_PROPERTIES(jfjoch_viewer PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON) -ENDIF() IF(JFJOCH_VIEWER_DBUS)