[Git][ghc/ghc][master] hadrian: Always canonicalize topDirectory
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Thu Jun 29 01:08:31 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00
hadrian: Always canonicalize topDirectory
Hadrian's `topDirectory` is intended to provide an absolute path to the
root of the GHC tree. However, if the tree is reached via a symlink this
One question here is whether the `canonicalizePath` call is expensive
enough to warrant caching. In a quick microbenchmark I observed that
`canonicalizePath "."` takes around 10us per call; this seems
sufficiently low not to worry.
Alternatively, another approach here would have been to rather move the
canonicalization into `m4/fp_find_root.m4`. This would have avoided
repeated canonicalization but sadly path canonicalization is a hard
problem in POSIX shell.
Addresses #22451.
- - - - -
1 changed file:
- hadrian/src/Oracles/Setting.hs
Changes:
=====================================
hadrian/src/Oracles/Setting.hs
=====================================
@@ -17,6 +17,8 @@ module Oracles.Setting (
ghcWithInterpreter
) where
+import System.Directory
+import System.Info.Extra
import Hadrian.Expression
import Hadrian.Oracles.TextFile
import Hadrian.Oracles.Path
@@ -327,9 +329,14 @@ ghcCanonVersion = do
let leadingZero = [ '0' | length ghcMinorVersion == 1 ]
return $ ghcMajorVersion ++ leadingZero ++ ghcMinorVersion
--- | Path to the GHC source tree.
+-- | Absolute path to the GHC source tree.
topDirectory :: Action FilePath
-topDirectory = fixAbsolutePathOnWindows =<< setting GhcSourcePath
+topDirectory = do
+ x <- fixAbsolutePathOnWindows =<< setting GhcSourcePath
+ canonicalize x
+ where
+ -- We must canonicalize as the source directory may be accessed via a symlink. See #22451.
+ canonicalize = if isWindows then return else liftIO . canonicalizePath
ghcVersionStage :: Stage -> Action String
ghcVersionStage (Stage0 {}) = setting GhcVersion
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5efa9ca545d8d33b9be4fc0ba91af1db38f19276
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5efa9ca545d8d33b9be4fc0ba91af1db38f19276
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230628/22e40f83/attachment-0001.html>
More information about the ghc-commits
mailing list