Hi!
I tried to build a binary with static linking of some CUDA libraries (like these: NVRTC (Runtime Compilation) :: CUDA Toolkit Documentation), using clang-16 and LLD as a linker. And it just didn’t work and sometimes crashed.
After some research (lld silently creates an non-working executable if both .ctors and .init_array exist · Issue #68071 · llvm/llvm-project · GitHub), I discovered that replacing the .ctors
section of some static libraries (libnvrtc_static.a, libnvptxcompiler_static.a) with .init_arrays
solved the issue. Something like that was mentioned in the next issue: lld produces broken executable with CUDA · Issue #30572 · llvm/llvm-project · GitHub.
As I understood correctly, the .ctors
is an old behavior of GCC (<4.7.0). So, will you be building future versions of the CUDA package with only .init_arrays
? Or why not?
I reproduced that issue in version: 12.1.0, 11.8.0.
My env: clang-16, Ubuntu 22.04, CUDA 12.1.0.