[Git][ghc/ghc][wip/davide/hadrian-aclocal_path] Hadrian: Autoreconf builder on windows converts env variable ACLOCAL_PATH to unix paths
David Eichmann pushed to branch wip/davide/hadrian-aclocal_path at Glasgow Haskell Compiler / GHC Commits: 2b6f845a by David Eichmann at 2026-05-27T18:09:03+01:00 Hadrian: Autoreconf builder on windows converts env variable ACLOCAL_PATH to unix paths This is needed to fix hadrian bindist builds on windows in the mysy2 clang64 environment - - - - - 3 changed files: - boot - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Utilities.hs Changes: ===================================== boot ===================================== @@ -54,7 +54,9 @@ def autoreconf(): if os.name == 'nt': # Get the normalized ACLOCAL_PATH for Windows # This is necessary since on Windows this will be a Windows - # path, which autoreconf doesn't know doesn't know how to handle. + # path, which autoreconf doesn't know how to handle. + # + # This logic is duplicated in Hadrian. Specifically in hadrian/src/Rules/BinaryDist.hs ac_local = os.getenv('ACLOCAL_PATH', '') ac_local_arg = re.sub(r';', r':', ac_local) ac_local_arg = re.sub(r'\\', r'/', ac_local_arg) ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -331,7 +331,22 @@ bindistRules = do ghcRoot <- topDirectory copyFile (ghcRoot -/- "aclocal.m4") (ghcRoot -/- "distrib" -/- "aclocal.m4") copyDirectory (ghcRoot -/- "m4") (ghcRoot -/- "distrib") - buildWithCmdOptions [] $ + + -- Get the normalized ACLOCAL_PATH for Windows + -- This is necessary since on Windows this will be a Windows + -- path, which autoreconf doesn't know how to handle. + -- + -- This logic is duplicated in the `boot` python script + win_host <- isWinHost + env <- if not win_host + then pure [] + else do + aclocalPathMay <- getEnv "ACLOCAL_PATH" + pure [ AddEnv "ACLOCAL_PATH" (msys2WindowsToUnixPath aclocalPath) + | Just aclocalPath <- [aclocalPathMay] + ] + + buildWithCmdOptions env $ target (vanillaContext Stage1 ghc) (Autoreconf $ ghcRoot -/- "distrib") [] [] -- We clean after ourselves, moving the configure script we generated in -- our bindist dir ===================================== hadrian/src/Utilities.hs ===================================== @@ -3,7 +3,8 @@ module Utilities ( askWithResources, runBuilder, runBuilderWith, contextDependencies, stage1Dependencies, - topsortPackages, cabalDependencies + topsortPackages, cabalDependencies, + msys2WindowsToUnixPath ) where import qualified Hadrian.Builder as H @@ -69,3 +70,17 @@ topsortPackages pkgs = do let annotated = map (annotateInDeg es) es inDegZero = map snd $ filter ((== 0). fst) annotated in inDegZero ++ topSort (es \\ inDegZero) + +-- | Converts a windows style path to a unix style path using msys2 conventions. +-- >>> msys2WindowsToUnixPath "C:\\foo\\bar;C:\\msys2\\bin" +-- "/C/foo/bar:/c/msys2/bin" +msys2WindowsToUnixPath :: String -> String +msys2WindowsToUnixPath = + replaceDrivePrefix + . replace "\\" "/" + . replace ";" ":" + where + replaceDrivePrefix p = case p of + drive : ':' : '/' : rest -> '/' : drive : '/' : replaceDrivePrefix rest + c : cs -> c : replaceDrivePrefix cs + [] -> [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b6f845ab0a42877a0c0e9a11f5ac56f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b6f845ab0a42877a0c0e9a11f5ac56f... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
David Eichmann (@DavidEichmann)