[Git][ghc/ghc][wip/toolchain-selection] allow duplos in place of triples

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Tue Jun 20 18:24:23 UTC 2023



Rodrigo Mesquita pushed to branch wip/toolchain-selection at Glasgow Haskell Compiler / GHC


Commits:
750061ce by Rodrigo Mesquita at 2023-06-20T19:24:17+01:00
allow duplos in place of triples

- - - - -


2 changed files:

- utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Ar.hs


Changes:

=====================================
utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
=====================================
@@ -9,17 +9,21 @@ import GHC.Toolchain.CheckArm
 import GHC.Toolchain.Tools.Cc
 
 -- | Parse a triple `arch-vendor-os` into an 'ArchOS' and a vendor name 'String'
-parseTriple :: Cc -> String -> M (ArchOS, String)
+parseTriple :: Cc -> String -> M (ArchOS, Maybe String)
 parseTriple cc triple
+  | [archName, osName] <- parts
+  = do arch <- parseArch cc archName
+       os   <- parseOs osName
+       return (ArchOS arch os, Nothing)
   | [archName, vendorName, osName] <- parts
   = do arch <- parseArch cc archName
-       os <- parseOs vendorName osName
-       return $ (ArchOS arch os, vendorName)
+       os   <- parseOs osName
+       return (ArchOS arch os, Just vendorName)
 
   | [archName, vendorName, osName, _abi] <- parts
   = do arch <- parseArch cc archName
-       os <- parseOs vendorName osName
-       return $ (ArchOS arch os, vendorName)
+       os   <- parseOs osName
+       return (ArchOS arch os, Just vendorName)
 
   | otherwise
   = throwE $ "malformed triple " ++ triple
@@ -49,8 +53,8 @@ parseArch cc arch =
       "wasm32" -> pure ArchWasm32
       _ -> throwE $ "Unknown architecture " ++ arch
 
-parseOs :: String -> String -> M OS
-parseOs vendor os =
+parseOs :: String -> M OS
+parseOs os =
     case os of
       "linux" -> pure OSLinux
       "linux-android" -> pure OSLinux
@@ -70,7 +74,7 @@ parseOs vendor os =
       "aix" -> pure OSAIX
       "gnu" -> pure OSHurd
       "wasi" -> pure OSWasi
-      _ -> throwE $ "Unknown vendor/operating system " ++ vendor ++ "-" ++ os
+      _ -> throwE $ "Unknown operating system " ++ os
 
 splitOn :: Char -> String -> [String]
 splitOn sep = go


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Ar.hs
=====================================
@@ -31,7 +31,7 @@ instance Show Ar where
     , "}"
     ]
 
-findAr :: String -- ^ Vendor name from the target triple
+findAr :: Maybe String -- ^ Vendor name from the target triple, if specified
        -> ProgOpt -> M Ar
 findAr vendor progOpt = checking "for 'ar'" $ do
     bareAr <- findProgram "ar archiver" progOpt ["ar"]
@@ -48,7 +48,7 @@ findAr vendor progOpt = checking "for 'ar'" $ do
           -- TODO: It'd be better not to handle Apple specifically here?
           -- It's quite tedious to check for Apple's crazy timestamps in
           -- .a files, so we hardcode it.
-          | vendor == "apple" = True
+          | vendor == Just "apple" = True
           | mode:_ <- prgFlags mkArchive
           , 's' `elem` mode = False
           | otherwise = True



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/750061ce178ffa949f369c4f805c674b4c3a88b9

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/750061ce178ffa949f369c4f805c674b4c3a88b9
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/20230620/801a270f/attachment-0001.html>


More information about the ghc-commits mailing list