[Git][ghc/ghc][wip/romes/enable-ghc-toolchain] 3 commits: ghc-toolchain: Create CHANGELOG.md

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Mon Jul 24 10:50:42 UTC 2023



Rodrigo Mesquita pushed to branch wip/romes/enable-ghc-toolchain at Glasgow Haskell Compiler / GHC


Commits:
05c6593c by Rodrigo Mesquita at 2023-07-24T11:49:51+01:00
ghc-toolchain: Create CHANGELOG.md

- - - - -
4d41a8f5 by Rodrigo Mesquita at 2023-07-24T11:50:09+01:00
ghc-toolchain: Parse javascript as a valid architecture

- - - - -
72cbbaf8 by Rodrigo Mesquita at 2023-07-24T11:50:34+01:00
ghc-toolchain: Try the C compiler as a fallback C++ compiler

It's not uncommon for users to specify a particular C compiler but not the C++
compiler.

An example of this is `configure` invoking ghc-toolchain for the HOST
target configuration, but only configuring a CC_STAGE0, not a CXX_STAGE0

We instruct ghc-toolchain to be a bit cleverer here, by trying the C
compiler as a fallback C++ compiler if none is otherwise found. It might
be that the C compiler program is a collection of compilers that also
support C++, such as gcc or clang.

- - - - -


5 changed files:

- + utils/ghc-toolchain/CHANGELOG.md
- utils/ghc-toolchain/Main.hs
- utils/ghc-toolchain/ghc-toolchain.cabal
- utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs


Changes:

=====================================
utils/ghc-toolchain/CHANGELOG.md
=====================================
@@ -0,0 +1,7 @@
+# Revision history for ghc-toolchain
+
+## Unreleased
+
+* Try the C compiler as a fallback C++ compiler
+* Parse "javascript" as a valid architecture
+* First version. See Note [ghc-toolchain overview] in GHC.Toolchain for an overview


=====================================
utils/ghc-toolchain/Main.hs
=====================================
@@ -314,7 +314,7 @@ mkTarget opts = do
     -- Use Llvm target if specified, otherwise use triple as llvm target
     let tgtLlvmTarget = fromMaybe (optTriple opts) (optLlvmTriple opts)
     cc0 <- findCc tgtLlvmTarget (optCc opts)
-    cxx <- findCxx tgtLlvmTarget (optCxx opts)
+    cxx <- findCxx tgtLlvmTarget (optCxx opts) cc0
     cpp <- findCpp (optCpp opts) cc0
     hsCpp <- findHsCpp (optHsCpp opts) cc0
     (archOs, tgtVendor) <- parseTriple cc0 (optTriple opts)


=====================================
utils/ghc-toolchain/ghc-toolchain.cabal
=====================================
@@ -7,6 +7,7 @@ bug-reports:        https://gitlab.haskell.org/ghc/ghc/-/issues
 author:             Ben Gamari
 maintainer:         ben at well-typed.com
 copyright:          (c) The GHC Developers
+extra-source-files: CHANGELOG.md
 
 library
     exposed-modules:


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
=====================================
@@ -53,6 +53,7 @@ parseArch cc arch =
       "riscv64" -> pure ArchRISCV64
       "hppa" -> pure ArchUnknown
       "wasm32" -> pure ArchWasm32
+      "javascript" -> pure ArchJavaScript
       _ -> throwE $ "Unknown architecture " ++ arch
 
 parseOs :: String -> M OS


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs
=====================================
@@ -11,6 +11,7 @@ import System.FilePath
 import GHC.Toolchain.Prelude
 import GHC.Toolchain.Program
 import GHC.Toolchain.Utils
+import GHC.Toolchain.Tools.Cc
 
 newtype Cxx = Cxx { cxxProgram :: Program
                   }
@@ -20,10 +21,12 @@ _cxxProgram :: Lens Cxx Program
 _cxxProgram = Lens cxxProgram (\x o -> o{cxxProgram=x})
 
 findCxx :: String -- ^ The llvm target to use if Cc supports --target
-        -> ProgOpt -> M Cxx
-findCxx target progOpt = checking "for C++ compiler" $ do
+        -> ProgOpt -- ^ A user specified C++ compiler
+        -> Cc      -- ^ The C compiler, to try as a fallback C++ compiler if we can't find one.
+        -> M Cxx
+findCxx target progOpt cc = checking "for C++ compiler" $ do
     -- TODO: We use the search order in configure, but there could be a more optimal one
-    cxxProgram <- findProgram "C++ compiler" progOpt ["g++", "clang++", "c++"]
+    cxxProgram <- findProgram "C++ compiler" progOpt ["g++", "clang++", "c++"] <|> pure (ccProgram cc)
     cxx        <- cxxSupportsTarget target Cxx{cxxProgram}
     checkCxxWorks cxx
     return cxx



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/695a74abbb0a6e55c4c2b01e7effff7c0ba5a768...72cbbaf89612ac87157051ff0ad9975a8d0ec54b

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/695a74abbb0a6e55c4c2b01e7effff7c0ba5a768...72cbbaf89612ac87157051ff0ad9975a8d0ec54b
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/20230724/516efde0/attachment-0001.html>


More information about the ghc-commits mailing list