@@ -187,13 +187,15 @@ build_setupHooks
187187 -- dumped.
188188 dumpBuildInfo verbosity distPref (configDumpBuildInfo (configFlags lbi)) pkg_descr lbi flags
189189
190+ curDir <- absoluteWorkingDirLBI lbi
191+
190192 -- Now do the actual building
191193 (\ f -> foldM_ f (installedPkgs lbi) componentsToBuild) $ \ index target -> do
192194 let comp = targetComponent target
193195 clbi = targetCLBI target
194196 bi = componentBuildInfo comp
195197 -- 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)
197199 lbi' =
198200 lbi
199201 { withPrograms = progs'
@@ -375,17 +377,20 @@ repl_setupHooks
375377
376378 internalPackageDB <- createInternalPackageDB verbosity lbi distPref
377379
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+ }
389394 runPreBuildHooks :: LocalBuildInfo -> TargetInfo -> IO ()
390395 runPreBuildHooks lbi2 tgt =
391396 let inputs =
@@ -403,7 +408,7 @@ repl_setupHooks
403408 [ do
404409 let clbi = targetCLBI subtarget
405410 comp = targetComponent subtarget
406- lbi' = lbiForComponent comp lbi
411+ lbi' <- lbiForComponent comp lbi
407412 preBuildComponent runPreBuildHooks verbosity lbi' subtarget
408413 buildComponent
409414 (mempty {buildCommonFlags = mempty {setupVerbosity = toFlag verbosity}})
@@ -420,7 +425,7 @@ repl_setupHooks
420425 -- REPL for target components
421426 let clbi = targetCLBI target
422427 comp = targetComponent target
423- lbi' = lbiForComponent comp lbi
428+ lbi' <- lbiForComponent comp lbi
424429 preBuildComponent runPreBuildHooks verbosity lbi' target
425430 replComponent flags verbosity pkg_descr lbi' suffixHandlers comp clbi distPref
426431
@@ -925,12 +930,13 @@ createInternalPackageDB verbosity lbi distPref = do
925930-- 'progOverrideEnv', so that any programs configured from now on will be
926931-- able to invoke these build tools.
927932addInternalBuildTools
928- :: PackageDescription
933+ :: AbsolutePath (Dir Pkg )
934+ -> PackageDescription
929935 -> LocalBuildInfo
930936 -> BuildInfo
931937 -> ProgramDb
932938 -> ProgramDb
933- addInternalBuildTools pkg lbi bi progs =
939+ addInternalBuildTools pwd pkg lbi bi progs =
934940 prependProgramSearchPathNoLogging
935941 internalToolPaths
936942 [pkgDataDirVar]
@@ -949,13 +955,11 @@ addInternalBuildTools pkg lbi bi progs =
949955 buildDir lbi
950956 </> makeRelativePathEx (toolName' </> toolName' <.> exeExtension (hostPlatform lbi))
951957 ]
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)
959963
960964-- TODO: build separate libs in separate dirs so that we can build
961965-- multiple libs, e.g. for 'LibTest' library-style test suites
0 commit comments