Fix lack of pthread linking in ubuntu 20.04 #1431
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ubuntu 20.04 saw a regression that caused the pthread library to no longer be a part of libvulkan.so's linked libraries. This didn't cause the loader to fail to load, rather any library that used pthread functions without linking to pthreads themselves would fail to run, for example the Vulkan-ValidationLayers (VVL). While it is currently unclear why VVL were trying to link to these symbols, this would make loading validation layers impossible.
The issue turns out to be this line of CMake
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
. Specifically, that line of code appearing beforefind_package(Threads REQUIRED)
causes CMake to 'find' CMAKE_HAVE_LIBC_PTHREAD successfully, whereas previously it would fail. Since this variable indicates that linking to libc is enough to get threading capabilities, CMake no longer links to pthread.This commit is an effort to prevent breaking ABI due to changing the link library list in Ubuntu 20.04. It should be noted that in Ubuntu 23.10, the location of
find_package(Threads)
has no bearing on the value of CMAKE_HAVE_LIBC_PTHREAD.