SixTrack / sixtracklib

Library for single charged particle simulations in accelerators
GNU Lesser General Public License v2.1
12 stars 16 forks source link

Linking problem with host portion of CUDA kernels for CMake >= 3.15 #109

Closed martinschwinzerl closed 3 years ago

martinschwinzerl commented 4 years ago

It seems that the mangled c++ symbols for the host side of cuda kernels are not exported by the shared library and causes problems during linking of applications (even non-cuda ones):

Scanning dependencies of target dump_cbuffer
[ 27%] Building C object tools/CMakeFiles/dump_cbuffer.dir/dump_cbuffer.c.o
[ 27%] Linking C executable dump_cbuffer
../sixtracklib/libsixtrack.so: undefined reference to `__cudaRegisterLinkedBinary_55_tmpxft_000026c9_00000000_6_managed_buffer_remap_cpp1_ii_da9df0a7'
../sixtracklib/libsixtrack.so: undefined reference to `__cudaRegisterLinkedBinary_57_tmpxft_000026ae_00000000_6_extract_particles_addr_cpp1_ii_90dc0973'
../sixtracklib/libsixtrack.so: undefined reference to `__cudaRegisterLinkedBinary_64_tmpxft_00002678_00000000_6_be_monitors_assign_out_buffer_cpp1_ii_54dd6e05'
../sixtracklib/libsixtrack.so: undefined reference to `__cudaRegisterLinkedBinary_50_tmpxft_000026e4_00000000_6_track_particles_cpp1_ii_c22b58a6'
../sixtracklib/libsixtrack.so: undefined reference to `__cudaRegisterLinkedBinary_65_tmpxft_00002693_00000000_6_elem_by_elem_assign_out_buffer_cpp1_ii_2a58a681'
collect2: error: ld returned 1 exit status
tools/CMakeFiles/dump_cbuffer.dir/build.make:88: recipe for target 'tools/dump_cbuffer' failed
make[2]: *** [tools/dump_cbuffer] Error 1
CMakeFiles/Makefile2:2253: recipe for target 'tools/CMakeFiles/dump_cbuffer.dir/all' failed
make[1]: *** [tools/CMakeFiles/dump_cbuffer.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

The same source code compiles and links successfully under cmake < 3.15. May have something to do with LINKER_LANGUAGE=C setting for sixtrack_cuda_device and sixtrack_cuda_host which always seemed a bit fishy to me.

aoeftiger commented 4 years ago

:+1: :smile:

martinschwinzerl commented 4 years ago

Fixed by #132 , commit 1ce557c71d4d80058b84e1e63aa3212454b0e181

martinschwinzerl commented 3 years ago

Closing due to merge of PR #132 into the main branch, please re-open if the problem persists