Skip to content

Commit 79bea09

Browse files
authored
Move fix from #502 to package.yaml (#537)
1 parent 2e38033 commit 79bea09

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

package.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ library:
2727
extra-libraries: vulkan-1
2828
- condition: os(darwin)
2929
extra-libraries: vulkan
30+
- condition: os(darwin) && flag(darwin-lib-dirs)
31+
extra-lib-dirs: /usr/local/lib
3032
- condition: '!os(windows) && !os(darwin)'
3133
pkg-config-dependencies: vulkan
3234
- condition: flag(safe-foreign-calls)
@@ -64,6 +66,11 @@ flags:
6466
default: no
6567
manual: yes
6668

69+
darwin-lib-dirs:
70+
description: Add default LunarG MoltenVK SDK paths to extra-lib-dirs when building on MacOS. Requires Cabal >=3.10.3.
71+
default: yes
72+
manual: yes
73+
6774
tests:
6875
test:
6976
main: Driver.hs

vulkan.cabal

+9-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22

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

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

27+
flag darwin-lib-dirs
28+
description: Add default LunarG MoltenVK SDK paths to extra-lib-dirs when building on MacOS. Requires Cabal >=3.10.3.
29+
manual: True
30+
default: True
31+
2732
flag generic-instances
2833
description: Derive Generic instances for all structs. Disabled by default because of code size and compile time impact.
2934
manual: True
@@ -673,26 +678,6 @@ library
673678
UndecidableInstances
674679
ViewPatterns
675680
ghc-options: -Wall -Wno-unticked-promoted-constructors -Wno-missing-pattern-synonym-signatures -Wno-unused-imports -Wno-missing-signatures -Wno-partial-type-signatures
676-
677-
-- The LunarG installation script (macOS) copies the vulkan dylibs to /usr/local/lib.
678-
--
679-
-- By adding this directory to the RPATH entries of the vulkan dylib
680-
-- built from this component, we can save a lot of headaches (ie loader
681-
-- errors) for macOS users for whom that path is not part of the default
682-
-- RPATH entries. This is justified by this being the default installation
683-
-- path of the vulkan SDK on macOS.
684-
--
685-
-- More specifically, vulkan-utils uses template haskell which forces the
686-
-- vulkan library to be loaded at compile time, resulting in an especially
687-
-- hard to diagnose loader error that is harder to fix than correcting the
688-
-- rpath of an executable (#501). This fixes that error for LunarG vulkan
689-
-- installations.
690-
--
691-
-- The caveat is that this fix is predicated on a Cabal bug being fixed: This
692-
-- will only work from Cabal 3.10.3+ (after cabal#9554 lands).
693-
if os(darwin)
694-
extra-lib-dirs: /usr/local/lib
695-
696681
build-depends:
697682
base <5
698683
, bytestring
@@ -705,6 +690,9 @@ library
705690
if os(darwin)
706691
extra-libraries:
707692
vulkan
693+
if os(darwin) && flag(darwin-lib-dirs)
694+
extra-lib-dirs:
695+
/usr/local/lib
708696
if !os(windows) && !os(darwin)
709697
pkgconfig-depends:
710698
vulkan

0 commit comments

Comments
 (0)