Peter Trommler pushed to branch wip/T26521 at Glasgow Haskell Compiler / GHC Commits: cf9d958f by Peter Trommler at 2025-10-26T10:41:44+01:00 ghc-toolchain: refactor, move lastLine to Utils - - - - - 3 changed files: - utils/ghc-toolchain/src/GHC/Toolchain/CheckArm.hs - utils/ghc-toolchain/src/GHC/Toolchain/CheckPower.hs - utils/ghc-toolchain/src/GHC/Toolchain/Utils.hs Changes: ===================================== utils/ghc-toolchain/src/GHC/Toolchain/CheckArm.hs ===================================== @@ -8,6 +8,7 @@ import System.Process import GHC.Platform.ArchOS import GHC.Toolchain.Prelude +import GHC.Toolchain.Utils (lastLine) import GHC.Toolchain.Tools.Cc -- | Awkwardly, ARM triples sometimes contain insufficient information about @@ -75,10 +76,6 @@ findArmIsa cc = do "False" -> return False _ -> throwE $ "unexpected output from test program: " ++ out -lastLine :: String -> String -lastLine "" = "" -lastLine s = last $ lines s - -- | Raspbian unfortunately makes some extremely questionable packaging -- decisions, configuring gcc to compile for ARMv6 despite the fact that the -- Raspberry Pi 4 is ARMv8. As ARMv8 doesn't support all instructions supported ===================================== utils/ghc-toolchain/src/GHC/Toolchain/CheckPower.hs ===================================== @@ -3,6 +3,7 @@ module GHC.Toolchain.CheckPower ( checkPowerAbi ) where import GHC.Platform.ArchOS import GHC.Toolchain.Prelude +import GHC.Toolchain.Utils (lastLine) import GHC.Toolchain.Tools.Cc checkPowerAbi :: Cc -> M Arch @@ -19,8 +20,3 @@ checkPowerAbi cc = do "ELFv1" -> pure $ ArchPPC_64 ELF_V1 "ELFv2" -> pure $ ArchPPC_64 ELF_V2 _ -> throwE $ "unexpected output from test program: " ++ out - --- TODO: move lastLine to a common location -lastLine :: String -> String -lastLine "" = "" -lastLine s = last $ lines s ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Utils.hs ===================================== @@ -8,6 +8,7 @@ module GHC.Toolchain.Utils , oneOf , oneOf' , isSuccess + , lastLine ) where import Control.Exception @@ -65,3 +66,6 @@ isSuccess = \case ExitSuccess -> True ExitFailure _ -> False +lastLine :: String -> String +lastLine "" = "" +lastLine s = last $ lines s View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf9d958f5ed1bebd6f5ff757a6078c92... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf9d958f5ed1bebd6f5ff757a6078c92... You're receiving this email because of your account on gitlab.haskell.org.