@@ -187,13 +187,15 @@ build_setupHooks
187
187
-- dumped.
188
188
dumpBuildInfo verbosity distPref (configDumpBuildInfo (configFlags lbi)) pkg_descr lbi flags
189
189
190
+ curDir <- absoluteWorkingDirLBI lbi
191
+
190
192
-- Now do the actual building
191
193
(\ f -> foldM_ f (installedPkgs lbi) componentsToBuild) $ \ index target -> do
192
194
let comp = targetComponent target
193
195
clbi = targetCLBI target
194
196
bi = componentBuildInfo comp
195
197
-- Include any build-tool-depends on build tools internal to the current package.
196
- progs' = addInternalBuildTools pkg_descr lbi bi (withPrograms lbi)
198
+ progs' = addInternalBuildTools curDir pkg_descr lbi bi (withPrograms lbi)
197
199
lbi' =
198
200
lbi
199
201
{ withPrograms = progs'
@@ -375,17 +377,20 @@ repl_setupHooks
375
377
376
378
internalPackageDB <- createInternalPackageDB verbosity lbi distPref
377
379
378
- let lbiForComponent comp lbi' =
379
- lbi'
380
- { withPackageDB = withPackageDB lbi ++ [internalPackageDB]
381
- , withPrograms =
382
- -- Include any build-tool-depends on build tools internal to the current package.
383
- addInternalBuildTools
384
- pkg_descr
385
- lbi'
386
- (componentBuildInfo comp)
387
- (withPrograms lbi')
388
- }
380
+ let lbiForComponent comp lbi' = do
381
+ curDir <- absoluteWorkingDirLBI lbi'
382
+ return $
383
+ lbi'
384
+ { withPackageDB = withPackageDB lbi' ++ [internalPackageDB]
385
+ , withPrograms =
386
+ -- Include any build-tool-depends on build tools internal to the current package.
387
+ addInternalBuildTools
388
+ curDir
389
+ pkg_descr
390
+ lbi'
391
+ (componentBuildInfo comp)
392
+ (withPrograms lbi')
393
+ }
389
394
runPreBuildHooks :: LocalBuildInfo -> TargetInfo -> IO ()
390
395
runPreBuildHooks lbi2 tgt =
391
396
let inputs =
@@ -403,7 +408,7 @@ repl_setupHooks
403
408
[ do
404
409
let clbi = targetCLBI subtarget
405
410
comp = targetComponent subtarget
406
- lbi' = lbiForComponent comp lbi
411
+ lbi' <- lbiForComponent comp lbi
407
412
preBuildComponent runPreBuildHooks verbosity lbi' subtarget
408
413
buildComponent
409
414
(mempty {buildCommonFlags = mempty {setupVerbosity = toFlag verbosity}})
@@ -420,7 +425,7 @@ repl_setupHooks
420
425
-- REPL for target components
421
426
let clbi = targetCLBI target
422
427
comp = targetComponent target
423
- lbi' = lbiForComponent comp lbi
428
+ lbi' <- lbiForComponent comp lbi
424
429
preBuildComponent runPreBuildHooks verbosity lbi' target
425
430
replComponent flags verbosity pkg_descr lbi' suffixHandlers comp clbi distPref
426
431
@@ -925,12 +930,13 @@ createInternalPackageDB verbosity lbi distPref = do
925
930
-- 'progOverrideEnv', so that any programs configured from now on will be
926
931
-- able to invoke these build tools.
927
932
addInternalBuildTools
928
- :: PackageDescription
933
+ :: AbsolutePath (Dir Pkg )
934
+ -> PackageDescription
929
935
-> LocalBuildInfo
930
936
-> BuildInfo
931
937
-> ProgramDb
932
938
-> ProgramDb
933
- addInternalBuildTools pkg lbi bi progs =
939
+ addInternalBuildTools pwd pkg lbi bi progs =
934
940
prependProgramSearchPathNoLogging
935
941
internalToolPaths
936
942
[pkgDataDirVar]
@@ -949,13 +955,11 @@ addInternalBuildTools pkg lbi bi progs =
949
955
buildDir lbi
950
956
</> makeRelativePathEx (toolName' </> toolName' <.> exeExtension (hostPlatform lbi))
951
957
]
952
- mbWorkDir = mbWorkDirLBI lbi
953
- rawDataDir = dataDir pkg
954
- dataDirPath
955
- | null $ getSymbolicPath rawDataDir =
956
- interpretSymbolicPath mbWorkDir sameDirectory
957
- | otherwise =
958
- interpretSymbolicPath mbWorkDir rawDataDir
958
+
959
+ -- This is an absolute path, so if a process changes directory, it can still
960
+ -- find the datadir (#10717)
961
+ dataDirPath :: FilePath
962
+ dataDirPath = interpretSymbolicPathAbsolute pwd (dataDir pkg)
959
963
960
964
-- TODO: build separate libs in separate dirs so that we can build
961
965
-- multiple libs, e.g. for 'LibTest' library-style test suites
0 commit comments