diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2023-12-20 10:48:03 -0800 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2023-12-20 10:48:03 -0800 |
commit | 5b6846850813bee24f0fb13f340c05ebe9498ff6 (patch) | |
tree | ecba803f167cf211313700bcd5807d8e9e0f64f7 | |
parent | 816998ea1e6b6546bc24d912478708219494962c (diff) | |
download | volk-5b6846850813bee24f0fb13f340c05ebe9498ff6.tar.gz |
Fall back to /usr/local/lib/libvulkan.dylib on macOS
dlopen on macOS is supposed to automatically search /usr/local/lib per dlopen man page.
This behavior is customizable via DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH, but
even if neither is explicitly set /usr/local/lib should be a search path. Unfortunately,
this does not happen anymore on modern macOS systems, and this is precisely where
Vulkan SDK installs dylib by default.
This used to "work" in CMake builds that accidentally linked in libvulkan.dylib statically,
because the library was already loaded into the process, but fixing that exposed this issue.
For now we need to manually fallback to /usr/local/lib path.
-rw-r--r-- | volk.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -68,6 +68,10 @@ VkResult volkInitialize(void) module = dlopen("libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL); if (!module) module = dlopen("libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL); + // modern versions of macOS don't search /usr/local/lib automatically contrary to what man dlopen says + // Vulkan SDK uses this as the system-wide installation location, so we're going to fallback to this if all else fails + if (!module) + module = dlopen("/usr/local/lib/libvulkan.dylib", RTLD_NOW | RTLD_LOCAL); if (!module) return VK_ERROR_INITIALIZATION_FAILED; |