···
1
+
This patch is based on https://github.com/sternenseemann/cabal/compare/Cabal-v3.12.0.0..e836ef53c1f80bf99a70f9c4ee5976e9f3830215
2
+
and has been postprocessed with `filterdiff --strip=1 --addoldprefix=a/libraries/Cabal/ --addnewprefix=b/libraries/Cabal/`.
4
+
Reasoning and explanation of the patch can be found in the comment in the diff for PathsModule.hs below.
6
+
diffCabal/src/Distribution/Simple/Build/PathsModule.hs b/Cabal/src/Distribution/Simple/Build/PathsModule.hs
7
+
index 892e5bd38..391f5b130 100644
8
+
--- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs
9
+
+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs
10
+
@@ -51,6 +51,7 @@ generatePathsModule pkg_descr lbi clbi =
11
+
, Z.zIsWindows = isWindows
12
+
, Z.zIsI386 = buildArch == I386
13
+
, Z.zIsX8664 = buildArch == X86_64
16
+
, Z.zManglePkgName = showPkgName
17
+
, Z.zPrefix = show flat_prefix
18
+
@@ -60,8 +61,110 @@ generatePathsModule pkg_descr lbi clbi =
19
+
, Z.zDatadir = zDatadir
20
+
, Z.zLibexecdir = zLibexecdir
21
+
, Z.zSysconfdir = zSysconfdir
22
+
+ , -- Sadly we can't be cleverer about this – we can't have literals in the template
23
+
+ Z.zShouldEmitDataDir = shouldEmit "DataDir"
24
+
+ , Z.zShouldEmitLibDir = shouldEmit "LibDir"
25
+
+ , Z.zShouldEmitDynLibDir = shouldEmit "DynLibDir"
26
+
+ , Z.zShouldEmitLibexecDir = shouldEmit "LibexecDir"
27
+
+ , Z.zShouldEmitSysconfDir = shouldEmit "SysconfDir"
28
+
+ , Z.zWarning = zWarning
29
+
+ , Z.zShouldEmitWarning = zShouldEmitWarning
32
+
+ -- GHC's NCG backend for aarch64-darwin does not support link-time dead code
33
+
+ -- elimination to the extent that NCG does for other targets. Consequently,
34
+
+ -- we struggle with unnecessarily retained store path references due to the
35
+
+ -- use of `Paths_*` modules – even if `getLibDir` is not used, it'll end up
36
+
+ -- in the final library or executables we build.
38
+
+ -- When using a different output for the executables and library, this
39
+
+ -- becomes more sinister: The library will contain a reference to the bin
40
+
+ -- output and itself due to `getLibDir` and `getBinDir`, but the executables
41
+
+ -- will do so, too. Either due to linking dynamically or because the library
42
+
+ -- is linked statically into the executable and retains those references.
43
+
+ -- Since Nix disallows cyclical references between two outputs, it becomes
44
+
+ -- impossible to use the `Paths_*` module and a separate `bin` output for
45
+
+ -- aarch64-darwin.
47
+
+ -- The solution we have resorted to for now, is to trim the `Paths_*` module
48
+
+ -- dynamically depending on what references *could* be used without causing
49
+
+ -- a cyclical reference. That has the effect that any code that would not
50
+
+ -- cause a cyclical reference with dead code elimination will compile and
51
+
+ -- work for aarch64-darwin. If the code would use a `get*Dir` function that
52
+
+ -- has been omitted, this would indicate that the code would have caused a
53
+
+ -- cyclical reference anyways.
55
+
+ -- The logic for this makes some pretty big assumptions about installation
56
+
+ -- prefixes that probably only hold fully in nixpkgs with
57
+
+ -- `haskellPackages.mkDerivation`. Simple uses outside nixpkgs that have
58
+
+ -- everything below the same prefix should continue to work as expected,
61
+
+ -- We assume the following:
63
+
+ -- - flat_prefix is `$out`.
64
+
+ -- - flat_libdir etc. are always below `$out`.
66
+
+ -- Since in the normal case due to static linking `$bin` and `$out` will
67
+
+ -- have the same references in libraries/executables, we need to either
68
+
+ -- prevent usage of `getBinDir` or `getLibDir` to break the cycle in case
69
+
+ -- `flat_bindir` is not below `$out`. We have decided to always allow usage
70
+
+ -- of `getBinDir`, so `getLibDir` gets dropped if a separate `bin` output is
71
+
+ -- used. This has the simple reason that `$out` which contains `flat_libdir`
72
+
+ -- tends to be quite big – we would like to have a `bin` output that doesn't
73
+
+ -- require keeping that around.
74
+
+ pathEmittable :: FilePath -> Bool
76
+
+ -- If the executable installation target is below `$out` the reference
77
+
+ -- cycle is within a single output (since libs are installed to `$out`)
78
+
+ -- and thus unproblematic. We can use any and all `get*Dir` functions.
79
+
+ | flat_prefix `isPrefixOf` flat_bindir = True
80
+
+ -- Otherwise, we need to disallow all `get*Dir` functions that would cause
81
+
+ -- a reference to `$out` which contains the libraries that would in turn
82
+
+ -- reference `$bin`. This always include `flat_libdir` and friends, but
83
+
+ -- can also include `flat_datadir` if no separate output for data files is
85
+
+ | otherwise = not (flat_prefix `isPrefixOf` p)
87
+
+ -- This list maps the "name" of the directory to whether we want to include
88
+
+ -- it in the `Paths_*` module or not. `shouldEmit` performs a lookup in this.
89
+
+ dirs :: [(String, Bool)]
92
+
+ (\(name, path) -> (name, pathEmittable path))
93
+
+ [ ("LibDir", flat_libdir)
94
+
+ , ("DynLibDir", flat_dynlibdir)
95
+
+ , ("DataDir", flat_datadir)
96
+
+ , ("LibexecDir", flat_libexecdir)
97
+
+ , ("SysconfDir", flat_sysconfdir)
100
+
+ shouldEmit :: String -> Bool
101
+
+ shouldEmit name =
102
+
+ case lookup name dirs of
104
+
+ Nothing -> error "panic! BUG in Cabal Paths_ patch for aarch64-darwin, report this at https://github.com/nixos/nixpkgs/issues"
106
+
+ -- This is a comma separated list of all functions that have been emitted.
107
+
+ -- This is included in a GHC warning which will be attached to the `Paths_*`
108
+
+ -- module in case we are dropping any `get*Dir` functions that would
109
+
+ -- normally exist.
111
+
+ -- TODO: getDataFileName is not accounted for at the moment.
112
+
+ omittedFunctions :: String
113
+
+ omittedFunctions =
114
+
+ intercalate ", " $
115
+
+ map (("get" ++) . fst) $
116
+
+ filter (not . snd) dirs
118
+
+ zWarning :: String
121
+
+ "The following functions have been omitted by a nixpkgs-specific patch to Cabal: "
122
+
+ ++ omittedFunctions
123
+
+ zShouldEmitWarning :: Bool
124
+
+ zShouldEmitWarning = any (not . snd) dirs
126
+
supports_cpp = supports_language_pragma
127
+
supports_rebindable_syntax = ghc_newer_than (mkVersion [7, 0, 1])
128
+
supports_language_pragma = ghc_newer_than (mkVersion [6, 6, 1])
129
+
diffCabal/src/Distribution/Simple/Build/PathsModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
130
+
index 25c924720..a8278675e 100644
131
+
--- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
132
+
+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
133
+
@@ -19,6 +19,14 @@ data Z
134
+
zDatadir :: FilePath,
135
+
zLibexecdir :: FilePath,
136
+
zSysconfdir :: FilePath,
137
+
+ zShouldEmitLibDir :: Bool,
138
+
+ zShouldEmitDynLibDir :: Bool,
139
+
+ zShouldEmitLibexecDir :: Bool,
140
+
+ zShouldEmitDataDir :: Bool,
141
+
+ zShouldEmitSysconfDir :: Bool,
142
+
+ zShouldEmitWarning :: Bool,
143
+
+ zWarning :: String,
144
+
+ zOr :: (Bool -> Bool -> Bool),
145
+
zNot :: (Bool -> Bool),
146
+
zManglePkgName :: (PackageName -> String)}
148
+
@@ -54,10 +62,51 @@ render z_root = execWriter $ do
149
+
tell "{-# OPTIONS_GHC -w #-}\n"
150
+
tell "module Paths_"
151
+
tell (zManglePkgName z_root (zPackageName z_root))
155
+
+ if (zShouldEmitWarning z_root)
157
+
+ tell "{-# WARNING "
158
+
+ tell (zWarning z_root)
166
+
- tell " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n"
167
+
- tell " getDataFileName, getSysconfDir\n"
168
+
+ tell " getBinDir,\n"
169
+
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitLibDir z_root))
171
+
+ tell " getLibDir,\n"
175
+
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDynLibDir z_root))
177
+
+ tell " getDynLibDir,\n"
181
+
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitLibexecDir z_root))
183
+
+ tell " getLibexecDir,\n"
187
+
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDataDir z_root))
189
+
+ tell " getDataFileName,\n"
190
+
+ tell " getDataDir,\n"
194
+
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitSysconfDir z_root))
196
+
+ tell " getSysconfDir\n"
202
+
if (zNot z_root (zAbsolute z_root))
203
+
@@ -106,12 +155,15 @@ render z_root = execWriter $ do
204
+
tell (zVersionDigits z_root)
207
+
- tell "getDataFileName :: FilePath -> IO FilePath\n"
208
+
- tell "getDataFileName name = do\n"
209
+
- tell " dir <- getDataDir\n"
210
+
- tell " return (dir `joinFileName` name)\n"
212
+
- tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"
213
+
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDataDir z_root))
215
+
+ tell "getDataFileName :: FilePath -> IO FilePath\n"
216
+
+ tell "getDataFileName name = do\n"
217
+
+ tell " dir <- getDataDir\n"
218
+
+ tell " return (dir `joinFileName` name)\n"
224
+
z_var0_function_defs = do
225
+
@@ -139,6 +191,7 @@ render z_root = execWriter $ do
227
+
if (zRelocatable z_root)
231
+
tell "getPrefixDirReloc :: FilePath -> IO FilePath\n"
232
+
tell "getPrefixDirReloc dirRel = do\n"
233
+
@@ -148,31 +201,37 @@ render z_root = execWriter $ do
234
+
tell (zBindir z_root)
235
+
tell ") `joinFileName` dirRel)\n"
237
+
+ tell "getBinDir :: IO FilePath\n"
238
+
tell "getBinDir = catchIO (getEnv \""
239
+
tell (zManglePkgName z_root (zPackageName z_root))
240
+
tell "_bindir\") (\\_ -> getPrefixDirReloc $ "
241
+
tell (zBindir z_root)
243
+
+ tell "getLibDir :: IO FilePath\n"
244
+
tell "getLibDir = catchIO (getEnv \""
245
+
tell (zManglePkgName z_root (zPackageName z_root))
246
+
tell "_libdir\") (\\_ -> getPrefixDirReloc $ "
247
+
tell (zLibdir z_root)
249
+
+ tell "getDynLibDir :: IO FilePath\n"
250
+
tell "getDynLibDir = catchIO (getEnv \""
251
+
tell (zManglePkgName z_root (zPackageName z_root))
252
+
tell "_dynlibdir\") (\\_ -> getPrefixDirReloc $ "
253
+
tell (zDynlibdir z_root)
255
+
+ tell "getDataDir :: IO FilePath\n"
256
+
tell "getDataDir = catchIO (getEnv \""
257
+
tell (zManglePkgName z_root (zPackageName z_root))
258
+
tell "_datadir\") (\\_ -> getPrefixDirReloc $ "
259
+
tell (zDatadir z_root)
261
+
+ tell "getLibexecDir :: IO FilePath\n"
262
+
tell "getLibexecDir = catchIO (getEnv \""
263
+
tell (zManglePkgName z_root (zPackageName z_root))
264
+
tell "_libexecdir\") (\\_ -> getPrefixDirReloc $ "
265
+
tell (zLibexecdir z_root)
267
+
+ tell "getSysconfDir :: IO FilePath\n"
268
+
tell "getSysconfDir = catchIO (getEnv \""
269
+
tell (zManglePkgName z_root (zPackageName z_root))
270
+
tell "_sysconfdir\") (\\_ -> getPrefixDirReloc $ "
271
+
@@ -186,72 +245,119 @@ render z_root = execWriter $ do
272
+
if (zAbsolute z_root)
275
+
- tell "bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n"
276
+
+ tell "bindir :: FilePath\n"
278
+
tell (zBindir z_root)
281
+
- tell (zLibdir z_root)
283
+
- tell "dynlibdir = "
284
+
- tell (zDynlibdir z_root)
285
+
+ tell "getBinDir :: IO FilePath\n"
286
+
+ tell "getBinDir = catchIO (getEnv \""
287
+
+ tell (zManglePkgName z_root (zPackageName z_root))
288
+
+ tell "_bindir\") (\\_ -> return bindir)\n"
290
+
- tell "datadir = "
291
+
- tell (zDatadir z_root)
292
+
+ if (zShouldEmitLibDir z_root)
294
+
+ tell "libdir :: FilePath\n"
296
+
+ tell (zLibdir z_root)
298
+
+ tell "getLibDir :: IO FilePath\n"
299
+
+ tell "getLibDir = catchIO (getEnv \""
300
+
+ tell (zManglePkgName z_root (zPackageName z_root))
301
+
+ tell "_libdir\") (\\_ -> return libdir)\n"
306
+
- tell "libexecdir = "
307
+
- tell (zLibexecdir z_root)
308
+
+ if (zShouldEmitDynLibDir z_root)
310
+
+ tell "dynlibdir :: FilePath\n"
311
+
+ tell "dynlibdir = "
312
+
+ tell (zDynlibdir z_root)
314
+
+ tell "getDynLibDir :: IO FilePath\n"
315
+
+ tell "getDynLibDir = catchIO (getEnv \""
316
+
+ tell (zManglePkgName z_root (zPackageName z_root))
317
+
+ tell "_dynlibdir\") (\\_ -> return dynlibdir)\n"
322
+
- tell "sysconfdir = "
323
+
- tell (zSysconfdir z_root)
324
+
+ if (zShouldEmitDataDir z_root)
326
+
+ tell "datadir :: FilePath\n"
327
+
+ tell "datadir = "
328
+
+ tell (zDatadir z_root)
330
+
+ tell "getDataDir :: IO FilePath\n"
331
+
+ tell "getDataDir = catchIO (getEnv \""
332
+
+ tell (zManglePkgName z_root (zPackageName z_root))
333
+
+ tell "_datadir\") (\\_ -> return datadir)\n"
338
+
+ if (zShouldEmitLibexecDir z_root)
340
+
+ tell "libexecdir :: FilePath\n"
341
+
+ tell "libexecdir = "
342
+
+ tell (zLibexecdir z_root)
344
+
+ tell "getLibexecDir :: IO FilePath\n"
345
+
+ tell "getLibexecDir = catchIO (getEnv \""
346
+
+ tell (zManglePkgName z_root (zPackageName z_root))
347
+
+ tell "_libexecdir\") (\\_ -> return libexecdir)\n"
352
+
- tell "getBinDir = catchIO (getEnv \""
353
+
- tell (zManglePkgName z_root (zPackageName z_root))
354
+
- tell "_bindir\") (\\_ -> return bindir)\n"
355
+
- tell "getLibDir = catchIO (getEnv \""
356
+
- tell (zManglePkgName z_root (zPackageName z_root))
357
+
- tell "_libdir\") (\\_ -> return libdir)\n"
358
+
- tell "getDynLibDir = catchIO (getEnv \""
359
+
- tell (zManglePkgName z_root (zPackageName z_root))
360
+
- tell "_dynlibdir\") (\\_ -> return dynlibdir)\n"
361
+
- tell "getDataDir = catchIO (getEnv \""
362
+
- tell (zManglePkgName z_root (zPackageName z_root))
363
+
- tell "_datadir\") (\\_ -> return datadir)\n"
364
+
- tell "getLibexecDir = catchIO (getEnv \""
365
+
- tell (zManglePkgName z_root (zPackageName z_root))
366
+
- tell "_libexecdir\") (\\_ -> return libexecdir)\n"
367
+
- tell "getSysconfDir = catchIO (getEnv \""
368
+
- tell (zManglePkgName z_root (zPackageName z_root))
369
+
- tell "_sysconfdir\") (\\_ -> return sysconfdir)\n"
370
+
+ if (zShouldEmitSysconfDir z_root)
372
+
+ tell "sysconfdir :: FilePath\n"
373
+
+ tell "sysconfdir = "
374
+
+ tell (zSysconfdir z_root)
376
+
+ tell "getSysconfDir :: IO FilePath\n"
377
+
+ tell "getSysconfDir = catchIO (getEnv \""
378
+
+ tell (zManglePkgName z_root (zPackageName z_root))
379
+
+ tell "_sysconfdir\") (\\_ -> return sysconfdir)\n"
386
+
if (zIsWindows z_root)
390
+
tell "prefix :: FilePath\n"
392
+
tell (zPrefix z_root)
395
+
+ tell "getBinDir :: IO FilePath\n"
396
+
tell "getBinDir = getPrefixDirRel $ "
397
+
tell (zBindir z_root)
399
+
+ tell "getLibDir :: IO FilePath\n"
400
+
tell "getLibDir = "
401
+
tell (zLibdir z_root)
403
+
+ tell "getDynLibDir :: IO FilePath\n"
404
+
tell "getDynLibDir = "
405
+
tell (zDynlibdir z_root)
407
+
+ tell "getDataDir :: IO FilePath\n"
408
+
tell "getDataDir = catchIO (getEnv \""
409
+
tell (zManglePkgName z_root (zPackageName z_root))
410
+
tell "_datadir\") (\\_ -> "
411
+
tell (zDatadir z_root)
413
+
+ tell "getLibexecDir :: IO FilePath\n"
414
+
tell "getLibexecDir = "
415
+
tell (zLibexecdir z_root)
417
+
+ tell "getSysconfDir :: IO FilePath\n"
418
+
tell "getSysconfDir = "
419
+
tell (zSysconfdir z_root)
421
+
diffcabal-dev-scripts/src/GenPathsModule.hs b/cabal-dev-scripts/src/GenPathsModule.hs
422
+
index 46ef779e2..e9f5e099f 100644
423
+
--- a/libraries/Cabal/cabal-dev-scripts/src/GenPathsModule.hs
424
+
+++ b/libraries/Cabal/cabal-dev-scripts/src/GenPathsModule.hs
425
+
@@ -41,6 +41,16 @@ $(capture "decls" [d|
426
+
, zLibexecdir :: FilePath
427
+
, zSysconfdir :: FilePath
429
+
+ , zShouldEmitLibDir :: Bool
430
+
+ , zShouldEmitDynLibDir :: Bool
431
+
+ , zShouldEmitLibexecDir :: Bool
432
+
+ , zShouldEmitDataDir :: Bool
433
+
+ , zShouldEmitSysconfDir :: Bool
435
+
+ , zShouldEmitWarning :: Bool
436
+
+ , zWarning :: String
438
+
+ , zOr :: Bool -> Bool -> Bool
439
+
, zNot :: Bool -> Bool
440
+
, zManglePkgName :: PackageName -> String
442
+
difftemplates/Paths_pkg.template.hs b/templates/Paths_pkg.template.hs
443
+
index 8e1e03d27..cc5c86701 100644
444
+
--- a/libraries/Cabal/templates/Paths_pkg.template.hs
445
+
+++ b/libraries/Cabal/templates/Paths_pkg.template.hs
446
+
@@ -14,10 +14,31 @@
448
+
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
449
+
{-# OPTIONS_GHC -w #-}
450
+
-module Paths_{{ manglePkgName packageName }} (
451
+
+module Paths_{{ manglePkgName packageName }}
452
+
+ {% if shouldEmitWarning %}{-# WARNING {{ warning }} #-}{% endif %}
455
+
- getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,
456
+
- getDataFileName, getSysconfDir
458
+
+{# We only care about the absolute case for our emit logic, since only in this
459
+
+ case references are incurred. We are not going to hit isWindows and relocatable
460
+
+ has no absolute references to begin with.
462
+
+{% if or (not absolute) shouldEmitLibDir %}
465
+
+{% if or (not absolute) shouldEmitDynLibDir %}
468
+
+{% if or (not absolute) shouldEmitLibexecDir %}
471
+
+{% if or (not absolute) shouldEmitDataDir %}
475
+
+{% if or (not absolute) shouldEmitSysconfDir %}
480
+
{% if not absolute %}
481
+
@@ -56,12 +77,12 @@ catchIO = Exception.catch
483
+
version = Version {{ versionDigits }} []
485
+
+{% if or (not absolute) shouldEmitDataDir %}
486
+
getDataFileName :: FilePath -> IO FilePath
487
+
getDataFileName name = do
489
+
return (dir `joinFileName` name)
491
+
-getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
494
+
{% defblock function_defs %}
495
+
minusFileName :: FilePath -> String -> FilePath
496
+
@@ -90,48 +111,93 @@ splitFileName p = (reverse (path2++drive), reverse fname)
498
+
{% if relocatable %}
500
+
+{# Relocatable can not incur any absolute references, so we can ignore it.
501
+
+ Additionally, --enable-relocatable is virtually useless in Nix builds
504
+
getPrefixDirReloc :: FilePath -> IO FilePath
505
+
getPrefixDirReloc dirRel = do
506
+
exePath <- getExecutablePath
507
+
let (dir,_) = splitFileName exePath
508
+
return ((dir `minusFileName` {{ bindir }}) `joinFileName` dirRel)
510
+
+getBinDir :: IO FilePath
511
+
getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> getPrefixDirReloc $ {{ bindir }})
512
+
+getLibDir :: IO FilePath
513
+
getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> getPrefixDirReloc $ {{ libdir }})
514
+
+getDynLibDir :: IO FilePath
515
+
getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> getPrefixDirReloc $ {{ dynlibdir }})
516
+
+getDataDir :: IO FilePath
517
+
getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> getPrefixDirReloc $ {{ datadir }})
518
+
+getLibexecDir :: IO FilePath
519
+
getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> getPrefixDirReloc $ {{ libexecdir }})
520
+
+getSysconfDir :: IO FilePath
521
+
getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> getPrefixDirReloc $ {{ sysconfdir }})
523
+
{% useblock function_defs %}
525
+
{% elif absolute %}
527
+
-bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
528
+
+bindir :: FilePath
529
+
bindir = {{ bindir }}
530
+
-libdir = {{ libdir }}
531
+
-dynlibdir = {{ dynlibdir }}
532
+
-datadir = {{ datadir }}
533
+
-libexecdir = {{ libexecdir }}
534
+
-sysconfdir = {{ sysconfdir }}
536
+
+getBinDir :: IO FilePath
537
+
getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> return bindir)
539
+
+{% if shouldEmitLibDir %}
540
+
+libdir :: FilePath
541
+
+libdir = {{ libdir }}
542
+
+getLibDir :: IO FilePath
543
+
getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> return libdir)
546
+
+{% if shouldEmitDynLibDir %}
547
+
+dynlibdir :: FilePath
548
+
+dynlibdir = {{ dynlibdir }}
549
+
+getDynLibDir :: IO FilePath
550
+
getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> return dynlibdir)
553
+
+{% if shouldEmitDataDir %}
554
+
+datadir :: FilePath
555
+
+datadir = {{ datadir }}
556
+
+getDataDir :: IO FilePath
557
+
getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> return datadir)
560
+
+{% if shouldEmitLibexecDir %}
561
+
+libexecdir :: FilePath
562
+
+libexecdir = {{ libexecdir }}
563
+
+getLibexecDir :: IO FilePath
564
+
getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> return libexecdir)
567
+
+{% if shouldEmitSysconfDir %}
568
+
+sysconfdir :: FilePath
569
+
+sysconfdir = {{ sysconfdir }}
570
+
+getSysconfDir :: IO FilePath
571
+
getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> return sysconfdir)
574
+
{% elif isWindows %}
576
+
+{# We are only trying to fix the problem for aarch64-darwin with this patch,
577
+
+ so let's ignore Windows which we can reach via pkgsCross, for example.
581
+
prefix = {{ prefix }}
583
+
+getBinDir :: IO FilePath
584
+
getBinDir = getPrefixDirRel $ {{ bindir }}
585
+
+getLibDir :: IO FilePath
586
+
getLibDir = {{ libdir }}
587
+
+getDynLibDir :: IO FilePath
588
+
getDynLibDir = {{ dynlibdir }}
589
+
+getDataDir :: IO FilePath
590
+
getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> {{ datadir }})
591
+
+getLibexecDir :: IO FilePath
592
+
getLibexecDir = {{ libexecdir }}
593
+
+getSysconfDir :: IO FilePath
594
+
getSysconfDir = {{ sysconfdir }}
596
+
getPrefixDirRel :: FilePath -> IO FilePath