Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lack of pthread linking in ubuntu 20.04 #1431

Merged

Conversation

charles-lunarg
Copy link
Collaborator

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 before find_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.

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 *before* `find_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.
@ci-tester-lunarg
Copy link

CI Vulkan-Loader build queued with queue ID 116588.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build # 2451 running.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build # 2451 passed.

@charles-lunarg charles-lunarg merged commit 0b2b713 into KhronosGroup:main Jan 15, 2024
43 checks passed
@charles-lunarg charles-lunarg deleted the fix_ubuntu_20_pthread_issue branch January 15, 2024 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants