at master 23 kB view raw
1This patch is based on https://github.com/sternenseemann/cabal/compare/Cabal-v3.12.0.0..e836ef53c1f80bf99a70f9c4ee5976e9f3830215 2and has been postprocessed with `filterdiff --strip=1 --addoldprefix=a/libraries/Cabal/ --addnewprefix=b/libraries/Cabal/`. 3 4Reasoning and explanation of the patch can be found in the comment in the diff for PathsModule.hs below. 5 6diffCabal/src/Distribution/Simple/Build/PathsModule.hs b/Cabal/src/Distribution/Simple/Build/PathsModule.hs 7index 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 14+ , Z.zOr = (||) 15 , Z.zNot = not 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 30 } 31 where 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. 37+ -- 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. 46+ -- 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. 54+ -- 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, 59+ -- though. 60+ -- 61+ -- We assume the following: 62+ -- 63+ -- - flat_prefix is `$out`. 64+ -- - flat_libdir etc. are always below `$out`. 65+ -- 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 75+ pathEmittable p 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 84+ -- used. 85+ | otherwise = not (flat_prefix `isPrefixOf` p) 86+ 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)] 90+ dirs = 91+ map 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) 98+ ] 99+ 100+ shouldEmit :: String -> Bool 101+ shouldEmit name = 102+ case lookup name dirs of 103+ Just b -> b 104+ Nothing -> error "panic! BUG in Cabal Paths_ patch for aarch64-darwin, report this at https://github.com/nixos/nixpkgs/issues" 105+ 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. 110+ -- 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 117+ 118+ zWarning :: String 119+ zWarning = 120+ show $ 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 125+ 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]) 129diffCabal/src/Distribution/Simple/Build/PathsModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs 130index 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)} 147 deriving Generic 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)) 152- tell " (\n" 153+ tell "\n" 154+ tell " " 155+ if (zShouldEmitWarning z_root) 156+ then do 157+ tell "{-# WARNING " 158+ tell (zWarning z_root) 159+ tell " #-}" 160+ return () 161+ else do 162+ return () 163+ tell "\n" 164+ tell " (\n" 165 tell " version,\n" 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)) 170+ then do 171+ tell " getLibDir,\n" 172+ return () 173+ else do 174+ return () 175+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDynLibDir z_root)) 176+ then do 177+ tell " getDynLibDir,\n" 178+ return () 179+ else do 180+ return () 181+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitLibexecDir z_root)) 182+ then do 183+ tell " getLibexecDir,\n" 184+ return () 185+ else do 186+ return () 187+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDataDir z_root)) 188+ then do 189+ tell " getDataFileName,\n" 190+ tell " getDataDir,\n" 191+ return () 192+ else do 193+ return () 194+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitSysconfDir z_root)) 195+ then do 196+ tell " getSysconfDir\n" 197+ return () 198+ else do 199+ return () 200 tell " ) where\n" 201 tell "\n" 202 if (zNot z_root (zAbsolute z_root)) 203@@ -106,12 +155,15 @@ render z_root = execWriter $ do 204 tell (zVersionDigits z_root) 205 tell " []\n" 206 tell "\n" 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" 211- tell "\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)) 214+ then do 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" 219+ return () 220+ else do 221+ return () 222 tell "\n" 223 let 224 z_var0_function_defs = do 225@@ -139,6 +191,7 @@ render z_root = execWriter $ do 226 tell "\n" 227 if (zRelocatable z_root) 228 then do 229+ tell "\n" 230 tell "\n" 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" 236 tell "\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) 242 tell ")\n" 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) 248 tell ")\n" 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) 254 tell ")\n" 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) 260 tell ")\n" 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) 266 tell ")\n" 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) 273 then do 274 tell "\n" 275- tell "bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n" 276+ tell "bindir :: FilePath\n" 277 tell "bindir = " 278 tell (zBindir z_root) 279 tell "\n" 280- tell "libdir = " 281- tell (zLibdir z_root) 282- tell "\n" 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" 289 tell "\n" 290- tell "datadir = " 291- tell (zDatadir z_root) 292+ if (zShouldEmitLibDir z_root) 293+ then do 294+ tell "libdir :: FilePath\n" 295+ tell "libdir = " 296+ tell (zLibdir z_root) 297+ tell "\n" 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" 302+ return () 303+ else do 304+ return () 305 tell "\n" 306- tell "libexecdir = " 307- tell (zLibexecdir z_root) 308+ if (zShouldEmitDynLibDir z_root) 309+ then do 310+ tell "dynlibdir :: FilePath\n" 311+ tell "dynlibdir = " 312+ tell (zDynlibdir z_root) 313+ tell "\n" 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" 318+ return () 319+ else do 320+ return () 321 tell "\n" 322- tell "sysconfdir = " 323- tell (zSysconfdir z_root) 324+ if (zShouldEmitDataDir z_root) 325+ then do 326+ tell "datadir :: FilePath\n" 327+ tell "datadir = " 328+ tell (zDatadir z_root) 329+ tell "\n" 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" 334+ return () 335+ else do 336+ return () 337 tell "\n" 338+ if (zShouldEmitLibexecDir z_root) 339+ then do 340+ tell "libexecdir :: FilePath\n" 341+ tell "libexecdir = " 342+ tell (zLibexecdir z_root) 343+ tell "\n" 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" 348+ return () 349+ else do 350+ return () 351 tell "\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) 371+ then do 372+ tell "sysconfdir :: FilePath\n" 373+ tell "sysconfdir = " 374+ tell (zSysconfdir z_root) 375+ tell "\n" 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" 380+ return () 381+ else do 382+ return () 383 tell "\n" 384 return () 385 else do 386 if (zIsWindows z_root) 387 then do 388+ tell "\n" 389 tell "\n" 390 tell "prefix :: FilePath\n" 391 tell "prefix = " 392 tell (zPrefix z_root) 393 tell "\n" 394 tell "\n" 395+ tell "getBinDir :: IO FilePath\n" 396 tell "getBinDir = getPrefixDirRel $ " 397 tell (zBindir z_root) 398 tell "\n" 399+ tell "getLibDir :: IO FilePath\n" 400 tell "getLibDir = " 401 tell (zLibdir z_root) 402 tell "\n" 403+ tell "getDynLibDir :: IO FilePath\n" 404 tell "getDynLibDir = " 405 tell (zDynlibdir z_root) 406 tell "\n" 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) 412 tell ")\n" 413+ tell "getLibexecDir :: IO FilePath\n" 414 tell "getLibexecDir = " 415 tell (zLibexecdir z_root) 416 tell "\n" 417+ tell "getSysconfDir :: IO FilePath\n" 418 tell "getSysconfDir = " 419 tell (zSysconfdir z_root) 420 tell "\n" 421diffcabal-dev-scripts/src/GenPathsModule.hs b/cabal-dev-scripts/src/GenPathsModule.hs 422index 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 428 429+ , zShouldEmitLibDir :: Bool 430+ , zShouldEmitDynLibDir :: Bool 431+ , zShouldEmitLibexecDir :: Bool 432+ , zShouldEmitDataDir :: Bool 433+ , zShouldEmitSysconfDir :: Bool 434+ 435+ , zShouldEmitWarning :: Bool 436+ , zWarning :: String 437+ 438+ , zOr :: Bool -> Bool -> Bool 439 , zNot :: Bool -> Bool 440 , zManglePkgName :: PackageName -> String 441 } 442difftemplates/Paths_pkg.template.hs b/templates/Paths_pkg.template.hs 443index 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 @@ 447 {% endif %} 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 %} 453+ ( 454 version, 455- getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, 456- getDataFileName, getSysconfDir 457+ getBinDir, 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. 461+#} 462+{% if or (not absolute) shouldEmitLibDir %} 463+ getLibDir, 464+{% endif %} 465+{% if or (not absolute) shouldEmitDynLibDir %} 466+ getDynLibDir, 467+{% endif %} 468+{% if or (not absolute) shouldEmitLibexecDir %} 469+ getLibexecDir, 470+{% endif %} 471+{% if or (not absolute) shouldEmitDataDir %} 472+ getDataFileName, 473+ getDataDir, 474+{% endif %} 475+{% if or (not absolute) shouldEmitSysconfDir %} 476+ getSysconfDir 477+{% endif %} 478 ) where 479 480 {% if not absolute %} 481@@ -56,12 +77,12 @@ catchIO = Exception.catch 482 version :: Version 483 version = Version {{ versionDigits }} [] 484 485+{% if or (not absolute) shouldEmitDataDir %} 486 getDataFileName :: FilePath -> IO FilePath 487 getDataFileName name = do 488 dir <- getDataDir 489 return (dir `joinFileName` name) 490- 491-getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath 492+{% endif %} 493 494 {% defblock function_defs %} 495 minusFileName :: FilePath -> String -> FilePath 496@@ -90,48 +111,93 @@ splitFileName p = (reverse (path2++drive), reverse fname) 497 498 {% if relocatable %} 499 500+{# Relocatable can not incur any absolute references, so we can ignore it. 501+ Additionally, --enable-relocatable is virtually useless in Nix builds 502+#} 503+ 504 getPrefixDirReloc :: FilePath -> IO FilePath 505 getPrefixDirReloc dirRel = do 506 exePath <- getExecutablePath 507 let (dir,_) = splitFileName exePath 508 return ((dir `minusFileName` {{ bindir }}) `joinFileName` dirRel) 509 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 }}) 522 523 {% useblock function_defs %} 524 525 {% elif absolute %} 526 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 }} 535- 536+getBinDir :: IO FilePath 537 getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> return bindir) 538+ 539+{% if shouldEmitLibDir %} 540+libdir :: FilePath 541+libdir = {{ libdir }} 542+getLibDir :: IO FilePath 543 getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> return libdir) 544+{% endif %} 545+ 546+{% if shouldEmitDynLibDir %} 547+dynlibdir :: FilePath 548+dynlibdir = {{ dynlibdir }} 549+getDynLibDir :: IO FilePath 550 getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> return dynlibdir) 551+{% endif %} 552+ 553+{% if shouldEmitDataDir %} 554+datadir :: FilePath 555+datadir = {{ datadir }} 556+getDataDir :: IO FilePath 557 getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> return datadir) 558+{% endif %} 559+ 560+{% if shouldEmitLibexecDir %} 561+libexecdir :: FilePath 562+libexecdir = {{ libexecdir }} 563+getLibexecDir :: IO FilePath 564 getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> return libexecdir) 565+{% endif %} 566+ 567+{% if shouldEmitSysconfDir %} 568+sysconfdir :: FilePath 569+sysconfdir = {{ sysconfdir }} 570+getSysconfDir :: IO FilePath 571 getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> return sysconfdir) 572+{% endif %} 573 574 {% elif isWindows %} 575 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. 578+#} 579+ 580 prefix :: FilePath 581 prefix = {{ prefix }} 582 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 }} 595 596 getPrefixDirRel :: FilePath -> IO FilePath