expipiplus1 / vulkan

Haskell bindings for Vulkan
https://hackage.haskell.org/package/vulkan
BSD 3-Clause "New" or "Revised" License
139 stars 31 forks source link

vulkan-utils fails to build with a dlopen() error #501

Closed ashkann closed 3 months ago

ashkann commented 6 months ago

Building vulkan-utils on macOS errors out:

stack build vulkan-utils --no-interleaved-output
vulkan-utils> configure
vulkan-utils> build

Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the error:

       [S-7011]
       While building package vulkan-utils-0.5.10.6 (scroll up to its section to see the error) using:
       /private/var/folders/78/tby_nyvs1kv4607wlnywyf840000gp/T/stack-c8a4545b4872cc6d/vulkan-utils-0.5.10.6/.stack-work/dist/aarch64-osx/Cabal-3.8.1.0/setup/setup --verbose=1 --builddir=.stack-work/dist/aarch64-osx/Cabal-3.8.1.0 build --ghc-options " -fdiagnostics-color=always"
       Process exited with code: ExitFailure 1 
       Logs have been written to: /Users/A.Nazary/Haskell/v2/.stack-work/logs/vulkan-utils-0.5.10.6.log

       [1 of 3] Compiling Main             ( /private/var/folders/78/tby_nyvs1kv4607wlnywyf840000gp/T/stack-c8a4545b4872cc6d/vulkan-utils-0.5.10.6/Setup.hs, /private/var/folders/78/tby_nyvs1kv4607wlnywyf840000gp/T/stack-c8a4545b4872cc6d/vulkan-utils-0.5.10.6/.stack-work/dist/aarch64-osx/Cabal-3.8.1.0/setup/Main.o )
       [2 of 3] Compiling StackSetupShim   ( /Users/A.Nazary/.stack/setup-exe-src/setup-shim-6HauvNHV.hs, /private/var/folders/78/tby_nyvs1kv4607wlnywyf840000gp/T/stack-c8a4545b4872cc6d/vulkan-utils-0.5.10.6/.stack-work/dist/aarch64-osx/Cabal-3.8.1.0/setup/StackSetupShim.o )
       [3 of 3] Linking /private/var/folders/78/tby_nyvs1kv4607wlnywyf840000gp/T/stack-c8a4545b4872cc6d/vulkan-utils-0.5.10.6/.stack-work/dist/aarch64-osx/Cabal-3.8.1.0/setup/setup
       ld: warning: ignoring duplicate libraries: '-lm'
       Configuring vulkan-utils-0.5.10.6...
       Preprocessing library for vulkan-utils-0.5.10.6..
       Building library for vulkan-utils-0.5.10.6..
       [ 1 of 22] Compiling Vulkan.Utils.CommandCheck
       [ 2 of 22] Compiling Vulkan.Utils.Debug
       [ 3 of 22] Compiling Vulkan.Utils.FromGL
       [ 4 of 22] Compiling Vulkan.Utils.Internal
       [ 5 of 22] Compiling Vulkan.Utils.Misc
       [ 6 of 22] Compiling Vulkan.Utils.QueueAssignment
       [ 7 of 22] Compiling Vulkan.Utils.Requirements

       <no location info>: error:
           dlopen(/Users/A.Nazary/.stack/snapshots/aarch64-osx/2b80aa937a3497f58e342a39714e87adc268c9cf7297103e6a58b4fabd128389/9.4.7/lib/aarch64-osx-ghc-9.4.7/libHSvulkan-3.26.1-J1pmiwZUOJtIsA0cywV4yY-ghc9.4.7.dylib, 0x0005): Library not loaded: @rpath/libvulkan.1.dylib
         Referenced from: <BA3628BB-56C5-3616-BF29-E7C1A0457CE3> /Users/A.Nazary/.stack/snapshots/aarch64-osx/2b80aa937a3497f58e342a39714e87adc268c9cf7297103e6a58b4fabd128389/9.4.7/lib/aarch64-osx-ghc-9.4.7/libHSvulkan-3.26.1-J1pmiwZUOJtIsA0cywV4yY-ghc9.4.7.dylib
         Reason: tried: '/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.stack/snapshots/aarch64-osx/f5d9ed27fcad263339fad1561f48140136a6d643844b991d0656e551065f4d9b/9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.stack/snapshots/aarch64-osx/f5d9ed27fcad263339fad1561f48140136a6d643844b991d0656e551065f4d9b/9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.stack/snapshots/aarch64-osx/f5d9ed27fcad263339fad1561f48140136a6d643844b991d0656e551065f4d9b/9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.stack/snapshots/aarch64-osx/f5d9ed27fcad263339fad1561f48140136a6d643844b991d0656e551065f4d9b/9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/bin/../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '$ORIGIN/../../../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file)
       [ 9 of 22] Compiling Vulkan.Utils.Requirements.TH

       <no location info>: error:
           dlopen(/Users/A.Nazary/.stack/snapshots/aarch64-osx/2b80aa937a3497f58e342a39714e87adc268c9cf7297103e6a58b4fabd128389/9.4.7/lib/aarch64-osx-ghc-9.4.7/libHSvulkan-3.26.1-J1pmiwZUOJtIsA0cywV4yY-ghc9.4.7.dylib, 0x0005): Library not loaded: @rpath/libvulkan.1.dylib
         Referenced from: <BA3628BB-56C5-3616-BF29-E7C1A0457CE3> /Users/A.Nazary/.stack/snapshots/aarch64-osx/2b80aa937a3497f58e342a39714e87adc268c9cf7297103e6a58b4fabd128389/9.4.7/lib/aarch64-osx-ghc-9.4.7/libHSvulkan-3.26.1-J1pmiwZUOJtIsA0cywV4yY-ghc9.4.7.dylib
         Reason: tried: '/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.stack/snapshots/aarch64-osx/f5d9ed27fcad263339fad1561f48140136a6d643844b991d0656e551065f4d9b/9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.stack/snapshots/aarch64-osx/f5d9ed27fcad263339fad1561f48140136a6d643844b991d0656e551065f4d9b/9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.stack/snapshots/aarch64-osx/f5d9ed27fcad263339fad1561f48140136a6d643844b991d0656e551065f4d9b/9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.stack/snapshots/aarch64-osx/f5d9ed27fcad263339fad1561f48140136a6d643844b991d0656e551065f4d9b/9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '/Users/A.Nazary/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/bin/../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file), '$ORIGIN/../../../lib/aarch64-osx-ghc-9.4.7/libvulkan.1.dylib' (no such file)
       [10 of 22] Compiling Vulkan.Utils.ShaderQQ.Backend.Glslang
       [11 of 22] Compiling Vulkan.Utils.ShaderQQ.Backend.Internal
       [12 of 22] Compiling Vulkan.Utils.ShaderQQ.Backend.Shaderc
       [13 of 22] Compiling Vulkan.Utils.ShaderQQ.Interpolate
       [14 of 22] Compiling Vulkan.Utils.ShaderQQ.HLSL
       [15 of 22] Compiling Vulkan.Utils.ShaderQQ.GLSL
       [16 of 22] Compiling Vulkan.Utils.ShaderQQ.ShaderType
       [17 of 22] Compiling Vulkan.Utils.ShaderQQ.Backend.Shaderc.Internal
       [18 of 22] Compiling Vulkan.Utils.ShaderQQ.HLSL.Shaderc
       [19 of 22] Compiling Vulkan.Utils.ShaderQQ.GLSL.Shaderc
       [20 of 22] Compiling Vulkan.Utils.ShaderQQ.Backend.Glslang.Internal
       [21 of 22] Compiling Vulkan.Utils.ShaderQQ.HLSL.Glslang
       [22 of 22] Compiling Vulkan.Utils.ShaderQQ.GLSL.Glslang

LunarG (Vulkan SDK on mac) installs the vulkan loader under /usr/local/lib which is not a default path and is not listed among the entries dlopen() looks into (you can see the list in the error message above). Symlinking to one the searched path fixed it:

ln -s /usr/local/lib/libvulkan.1.3.268.dylib /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libvulkan.1.dylib

(nothing special about this path, just looked the most generic to me).

Probably getting LunarG to install the shared libs into a standard path would have prevented the problem as well (haven't tried but same principle applies).

Also, depending only on vulkan (but not vulkan-utils) did successfully build but did not run. Adding the following line fixed that (it could run when re-built with the following option):

ghc-options:
- -optl-Wl,-rpath,/usr/local/lib