[SYCL] Linking in static library with SYCL code should not require -Wl,--whole-archive
- Dominant language
- LLVM
- Stars
- 1.5k
- Forks
- 854
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 137
Description
With 848eba77430cde1b0654b69b95a3701cecb7d9e0, Ubuntu 24.04, PVC. Consider the following trivial example:
* https://github.com/dvrogozh/cmake-with-sycl/tree/fsycl-link (mind fsycl-link branch)
This project builds `main-static` application from `main.cpp` and `lib.cpp` in the following way:
1. `main.cpp` is regular C++ source and built with `g++`
2. `lib.cpp` is SYCL source and built with `dpclang++` into `liblib-static.a`
3. `main-static` application is linked by `g++`
Review `build-no-whole-archive.sh` and `build-whole-archive.sh` scripts for the details.
`main-static` built without `-Wl,--whole-archive` will fail with:
```
$ ./main-static
main-static: /home/dvrogozh/git/intel-llvm/sycl/source/detail/program_manager/program_manager.cpp:1620: sycl::_V1::detail::DeviceKernelInfo& sycl::_V1::detail::ProgramManager::getDeviceKernelInfo(const sycl::_V1::detail::compile_time_kernel_info_v1::CompileTimeKernelInfoTy&): Assertion `It != m_DeviceKernelInfoMap.end()' failed.
Aborted (core dumped)
```
Can compiler be changed to not require `-Wl,--whole-archive` in this case? Note that NVidia `nvcc` does not require that in a similar scenario.
CC: @tahonermann, @sarnex
Contributor guide
Assessment
This issue has not been assessed yet.