Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

5 changed files:

Changes:

  • utils/ghc-toolchain/ghc-toolchain.cabal
    ... ... @@ -21,6 +21,7 @@ library
    21 21
                           GHC.Toolchain.NormaliseTriple,
    
    22 22
                           GHC.Toolchain.CheckArm,
    
    23 23
                           GHC.Toolchain.Target,
    
    24
    +                      GHC.Toolchain.CheckPower
    
    24 25
                           GHC.Toolchain.Tools.Ar,
    
    25 26
                           GHC.Toolchain.Tools.Cc,
    
    26 27
                           GHC.Toolchain.Tools.Cxx,
    

  • utils/ghc-toolchain/src/GHC/Toolchain/CheckArm.hs
    ... ... @@ -8,6 +8,7 @@ import System.Process
    8 8
     import GHC.Platform.ArchOS
    
    9 9
     
    
    10 10
     import GHC.Toolchain.Prelude
    
    11
    +import GHC.Toolchain.Utils (lastLine)
    
    11 12
     import GHC.Toolchain.Tools.Cc
    
    12 13
     
    
    13 14
     -- | Awkwardly, ARM triples sometimes contain insufficient information about
    
    ... ... @@ -75,10 +76,6 @@ findArmIsa cc = do
    75 76
               "False" -> return False
    
    76 77
               _ -> throwE $ "unexpected output from test program: " ++ out
    
    77 78
     
    
    78
    -lastLine :: String -> String
    
    79
    -lastLine "" = ""
    
    80
    -lastLine s  = last $ lines s
    
    81
    -
    
    82 79
     -- | Raspbian unfortunately makes some extremely questionable packaging
    
    83 80
     -- decisions, configuring gcc to compile for ARMv6 despite the fact that the
    
    84 81
     -- Raspberry Pi 4 is ARMv8. As ARMv8 doesn't support all instructions supported
    

  • utils/ghc-toolchain/src/GHC/Toolchain/CheckPower.hs
    1
    +module GHC.Toolchain.CheckPower ( checkPowerAbi ) where
    
    2
    +
    
    3
    +import GHC.Platform.ArchOS
    
    4
    +
    
    5
    +import GHC.Toolchain.Prelude
    
    6
    +import GHC.Toolchain.Utils (lastLine)
    
    7
    +import GHC.Toolchain.Tools.Cc
    
    8
    +
    
    9
    +-- 64-Bit ELF V2 ABI Specification, Power Architecture, Revision 1.5 says:
    
    10
    +-- A C preprocessor that conforms to this ABI shall predefine the macro
    
    11
    +-- _CALL_ELF to have a value of 2 (Section 5.1.4 Predifined Macros).
    
    12
    +-- The 64-bit PowerPC ELF Application Binary Interface Supplement 1.9
    
    13
    +-- does not define any macro to identify the ABI.
    
    14
    +-- So we check for ABI version 2 and default to ABI version 1.
    
    15
    +
    
    16
    +checkPowerAbi :: Cc -> M Arch
    
    17
    +checkPowerAbi cc = do
    
    18
    +  checking "POWER ELF ABI" $ do
    
    19
    +    out <- fmap lastLine $ preprocess cc $ unlines
    
    20
    +        [ "#if defined(_CALL_ELF) && _CALL_ELF == 2"
    
    21
    +        , "ELFv2"
    
    22
    +        , "#else"
    
    23
    +        , "ELFv1"
    
    24
    +        , "#endif"
    
    25
    +        ]
    
    26
    +    case out of
    
    27
    +      "ELFv1" -> pure $ ArchPPC_64 ELF_V1
    
    28
    +      "ELFv2" -> pure $ ArchPPC_64 ELF_V2
    
    29
    +      _       -> throwE $ "unexpected output from test program: " ++ out

  • utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
    ... ... @@ -6,6 +6,7 @@ import GHC.Platform.ArchOS
    6 6
     
    
    7 7
     import GHC.Toolchain.Prelude
    
    8 8
     import GHC.Toolchain.CheckArm
    
    9
    +import GHC.Toolchain.CheckPower
    
    9 10
     import GHC.Toolchain.Tools.Cc
    
    10 11
     
    
    11 12
     -- | Parse a triple `arch-vendor-os` into an 'ArchOS' and a vendor name 'String'
    
    ... ... @@ -40,7 +41,7 @@ parseArch cc arch =
    40 41
           "x86_64" -> pure ArchX86_64
    
    41 42
           "amd64" -> pure ArchX86_64
    
    42 43
           "powerpc" -> pure ArchPPC
    
    43
    -      "powerpc64" -> pure (ArchPPC_64 ELF_V1)
    
    44
    +      "powerpc64" -> checkPowerAbi cc
    
    44 45
           "powerpc64le" -> pure (ArchPPC_64 ELF_V2)
    
    45 46
           "s390x" -> pure ArchS390X
    
    46 47
           "arm" -> findArmIsa cc
    

  • utils/ghc-toolchain/src/GHC/Toolchain/Utils.hs
    ... ... @@ -8,6 +8,7 @@ module GHC.Toolchain.Utils
    8 8
         , oneOf
    
    9 9
         , oneOf'
    
    10 10
         , isSuccess
    
    11
    +    , lastLine
    
    11 12
         ) where
    
    12 13
     
    
    13 14
     import Control.Exception
    
    ... ... @@ -65,3 +66,6 @@ isSuccess = \case
    65 66
       ExitSuccess -> True
    
    66 67
       ExitFailure _ -> False
    
    67 68
     
    
    69
    +lastLine :: String -> String
    
    70
    +lastLine "" = ""
    
    71
    +lastLine s  = last $ lines s