Skip to content

Commit

Permalink
Move fix from #502 to package.yaml (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpwiz authored Jun 28, 2024
1 parent 2e38033 commit 79bea09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
7 changes: 7 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ library:
extra-libraries: vulkan-1
- condition: os(darwin)
extra-libraries: vulkan
- condition: os(darwin) && flag(darwin-lib-dirs)
extra-lib-dirs: /usr/local/lib
- condition: '!os(windows) && !os(darwin)'
pkg-config-dependencies: vulkan
- condition: flag(safe-foreign-calls)
Expand Down Expand Up @@ -64,6 +66,11 @@ flags:
default: no
manual: yes

darwin-lib-dirs:
description: Add default LunarG MoltenVK SDK paths to extra-lib-dirs when building on MacOS. Requires Cabal >=3.10.3.
default: yes
manual: yes

tests:
test:
main: Driver.hs
Expand Down
30 changes: 9 additions & 21 deletions vulkan.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2

-- This file has been generated from package.yaml by hpack version 0.35.2.
-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

Expand All @@ -24,6 +24,11 @@ source-repository head
type: git
location: https://github.com/expipiplus1/vulkan

flag darwin-lib-dirs
description: Add default LunarG MoltenVK SDK paths to extra-lib-dirs when building on MacOS. Requires Cabal >=3.10.3.
manual: True
default: True

flag generic-instances
description: Derive Generic instances for all structs. Disabled by default because of code size and compile time impact.
manual: True
Expand Down Expand Up @@ -673,26 +678,6 @@ library
UndecidableInstances
ViewPatterns
ghc-options: -Wall -Wno-unticked-promoted-constructors -Wno-missing-pattern-synonym-signatures -Wno-unused-imports -Wno-missing-signatures -Wno-partial-type-signatures

-- The LunarG installation script (macOS) copies the vulkan dylibs to /usr/local/lib.
--
-- By adding this directory to the RPATH entries of the vulkan dylib
-- built from this component, we can save a lot of headaches (ie loader
-- errors) for macOS users for whom that path is not part of the default
-- RPATH entries. This is justified by this being the default installation
-- path of the vulkan SDK on macOS.
--
-- More specifically, vulkan-utils uses template haskell which forces the
-- vulkan library to be loaded at compile time, resulting in an especially
-- hard to diagnose loader error that is harder to fix than correcting the
-- rpath of an executable (#501). This fixes that error for LunarG vulkan
-- installations.
--
-- The caveat is that this fix is predicated on a Cabal bug being fixed: This
-- will only work from Cabal 3.10.3+ (after cabal#9554 lands).
if os(darwin)
extra-lib-dirs: /usr/local/lib

build-depends:
base <5
, bytestring
Expand All @@ -705,6 +690,9 @@ library
if os(darwin)
extra-libraries:
vulkan
if os(darwin) && flag(darwin-lib-dirs)
extra-lib-dirs:
/usr/local/lib
if !os(windows) && !os(darwin)
pkgconfig-depends:
vulkan
Expand Down

0 comments on commit 79bea09

Please sign in to comment.