[Git][ghc/ghc][wip/toolchain-selection] Apply 10 suggestion(s) to 4 file(s)

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Mon Jul 17 17:13:02 UTC 2023



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


Commits:
9896d0a0 by Ben Gamari at 2023-07-17T17:12:59+00:00
Apply 10 suggestion(s) to 4 file(s)
- - - - -


4 changed files:

- utils/ghc-toolchain/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Monad.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Program.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Target.hs


Changes:

=====================================
utils/ghc-toolchain/Main.hs
=====================================
@@ -180,7 +180,7 @@ options =
         ]
 
     tripleOpt = Option ['t'] ["triple"] (ReqArg (set _optTriple) "TRIPLE") "Target triple"
-    llvmTripleOpt = Option [] ["llvm-triple"] (ReqArg (set _optLlvmTriple . Just) "LLVMTRIPLE") "LLVM Target triple"
+    llvmTripleOpt = Option [] ["llvm-triple"] (ReqArg (set _optLlvmTriple . Just) "LLVM-TRIPLE") "LLVM Target triple"
 
     targetPrefixOpt = Option ['T'] ["target-prefix"] (ReqArg (set _optTargetPrefix . Just) "PREFIX")
         "A target prefix which will be added to all tool names when searching for toolchain components"
@@ -299,8 +299,9 @@ determineUseLibFFIForAdjustors archOs mb = checking "whether to use libffi for a
       pure True
     _    ->
       -- If don't have a native adjustor implementation we use libffi
-      pure (not . archHasNativeAdjustors $ archOS_arch archOs) -- If we
+      pure (not . archHasNativeAdjustors $ archOS_arch archOs)
 
+-- | Do we implement a native adjustor implementation (i.e. found in @rts/adjustors@) for this 'Arch'?
 archHasNativeAdjustors :: Arch -> Bool
 archHasNativeAdjustors = \case
   ArchX86    -> True
@@ -333,7 +334,7 @@ mkTarget opts = do
     mergeObjs <- optional $ findMergeObjs (optMergeObjs opts) cc ccLink nm
 
     when (isNothing mergeObjs && not (arSupportsDashL ar)) $
-      throwE "Neither a merge object tool nor an ar that supports -L is available"
+      throwE "Neither a object-merging tool (e.g. ld -r) nor an ar that supports -L is available"
 
     -- Windows-specific utilities
     windres <-


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Monad.hs
=====================================
@@ -104,7 +104,7 @@ logMsg v msg = do
 readFile :: FilePath -> M String
 readFile path = liftIO $ T.unpack <$> T.readFile path
               -- Use T.readfile to read the file strictly, or otherwise run
-              -- into bugs (in practice on windows)!
+              -- into file locking bugs on Windows
 
 writeFile :: FilePath -> String -> M ()
 writeFile path s = liftIO $ Prelude.writeFile path s
@@ -121,8 +121,7 @@ appendFile path s = liftIO $ Prelude.appendFile path s
 createFile :: FilePath -> M ()
 createFile path = writeFile path ""
 
--- | Branch on whether we're cross-compiling, that is, if the Target we're
--- producing differs from the platform we're producing it on.
+-- | Branch on whether we can execute target code locally.
 ifCrossCompiling
     :: M a  -- ^ what to do when cross-compiling
     -> M a  -- ^ what to do otherwise


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Program.hs
=====================================
@@ -140,7 +140,7 @@ findProgram description userSpec candidates
 --
 -- The compiler must
 -- * Take the program path as a positional argument
--- * Accept -o to specify output path
+-- * Accept @-o@ to specify output path
 compile
     :: FilePath  -- ^ input extension
     -> [String]  -- ^ extra flags
@@ -155,14 +155,14 @@ compile ext extraFlags lens c outPath program = do
     callProgram (view lens c) $ extraFlags ++ ["-o", outPath, srcPath]
     expectFileExists outPath "compiler produced no output"
 
--- Does compiler program support the --target=<triple> option? If so, we should
+-- | Does compiler program support the @--target=<triple>@ option? If so, we should
 -- pass it whenever possible to avoid ambiguity and potential compile-time
 -- errors (e.g. see #20162).
 supportsTarget :: Lens compiler Program
-               -> (compiler -> M ()) -- ^ Action to check if compiler with --target flag works
-               -> String             -- ^ The llvm target to use if Cc supports --target
-               -> compiler           -- ^ The compiler to check --target support for
-               -> M compiler         -- ^ Return compiler with --target flag if supported
+               -> (compiler -> M ()) -- ^ Action to check if compiler with @--target@ flag works
+               -> String             -- ^ The LLVM target to use if @cc@ supports @--target@
+               -> compiler           -- ^ The compiler to check @--target@ support for
+               -> M compiler         -- ^ Return compiler with @--target@ flag if supported
 supportsTarget lens checkWorks llvmTarget c
 -- TODO: #23603
   | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) = return c


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
=====================================
@@ -64,7 +64,7 @@ data Target = Target
     , tgtHsCPreprocessor :: HsCpp
     , tgtCCompilerLink :: CcLink
     , tgtAr :: Ar
-    , tgtRanlib :: Maybe Ranlib -- Most ar implementations do good things by default without ranlib so don't need it
+    , tgtRanlib :: Maybe Ranlib -- ^ N.B. Most @ar@ implementations will add an index by default without @ranlib@ so this is often optional
     , tgtNm :: Nm
     , tgtMergeObjs :: Maybe MergeObjs -- We don't need a merge objects tool if we @Ar@ supports @-L@
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9896d0a081dc6b2e953765834233d645c885cad6

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9896d0a081dc6b2e953765834233d645c885cad6
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/20230717/98c7c39b/attachment-0001.html>


More information about the ghc-commits mailing list