[Git][ghc/ghc][wip/toolchain-selection] fixup! Windows builtin toolchain

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Tue Jul 11 15:24:19 UTC 2023



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


Commits:
961b4526 by Rodrigo Mesquita at 2023-07-11T16:24:11+01:00
fixup! Windows builtin toolchain

- - - - -


7 changed files:

- m4/fp_settings.m4
- m4/fp_setup_windows_toolchain.m4
- m4/ghc_toolchain.m4
- m4/prep_target_file.m4
- utils/ghc-toolchain/ghc-toolchain.cabal
- utils/ghc-toolchain/src/GHC/Toolchain/Monad.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs


Changes:

=====================================
m4/fp_settings.m4
=====================================
@@ -6,7 +6,7 @@
 AC_DEFUN([SUBST_TOOLDIR],
 [
     dnl See Note [tooldir: How GHC finds mingw on Windows]
-    $1=`echo $1 | sed 's%'"$mingwpath"'%$$tooldir/mingw%'`
+    $1=`echo $$1 | sed 's%'"$mingwpath"'%$$tooldir/mingw%'`
 ])
 
 # FP_SETTINGS


=====================================
m4/fp_setup_windows_toolchain.m4
=====================================
@@ -120,6 +120,8 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
     RANLIB="${mingwbin}llvm-ranlib.exe"
     OBJDUMP="${mingwbin}llvm-objdump.exe"
     DLLTOOL="${mingwbin}llvm-dlltool.exe"
+    DllWrap="${mingwbin}llvm-dllwrap.exe"
+    Windres="${mingwbin}llvm-windres.exe"
 
     # N.B. LLD does not support -r
     MergeObjsCmd=""


=====================================
m4/ghc_toolchain.m4
=====================================
@@ -94,7 +94,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
     echo "--ar=$AR" >> acargs
     echo "--ranlib=$RANLIB" >> acargs
     echo "--nm=$NM" >> acargs
-    echo "--merge-objs=$SettingsMergeObjectsCommand" >> acargs
+    echo "--merge-objs=$MergeObjsCmd" >> acargs
     echo "--readelf=$READELF" >> acargs
     echo "--windres=$WindresCmd" >> acargs
     echo "--dllwrap=$DllWrapCmd" >> acargs


=====================================
m4/prep_target_file.m4
=====================================
@@ -2,7 +2,7 @@
 # =========================
 #
 # Issue a substitution of [$1MaybeProg] with
-# * Nothing, if $1 is /bin/false (this is unfortunately hardcoded since SettingsDllWrapCommand and SettingsWindresCommand get set to this on windows).
+# * Nothing, if $1 is empty
 # * Just (Program {prgPath = "$$1", prgFlags = []}), otherwise
 #
 # $1 = optional value


=====================================
utils/ghc-toolchain/ghc-toolchain.cabal
=====================================
@@ -36,6 +36,7 @@ library
                       filepath,
                       process,
                       transformers,
+                      text,
                       ghc-platform
     hs-source-dirs:   src
     default-language: Haskell2010


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Monad.hs
=====================================
@@ -34,6 +34,8 @@ import qualified Control.Monad.Trans.Reader as Reader
 import qualified Control.Monad.Trans.Except as Except
 import System.IO hiding (readFile, writeFile, appendFile)
 -- import qualified System.Directory
+import qualified Data.Text    as T
+import qualified Data.Text.IO as T
 
 
 data Env = Env { verbosity    :: Int
@@ -100,7 +102,9 @@ logMsg v msg = do
     when (verbosity e >= v) (liftIO $ hPutStrLn stderr $ indent ++ msg)
 
 readFile :: FilePath -> M String
-readFile path = liftIO $ Prelude.readFile path
+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)!
 
 writeFile :: FilePath -> String -> M ()
 writeFile path s = liftIO $ Prelude.writeFile path s


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs
=====================================
@@ -51,7 +51,7 @@ findCc llvmTarget progOpt = checking "for C compiler" $ do
 
     cc' <- ignoreUnusedArgs $ Cc {ccProgram}
     cc  <- ccSupportsTarget llvmTarget cc'
-    checkCcWorks cc
+    checking "whether Cc works" $ checkCcWorks cc
     checkC99Support cc
     checkCcSupportsExtraViaCFlags cc
     return cc



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/961b4526e7f17ccb2bfe0c87bc6b822d3ff74fe9

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/961b4526e7f17ccb2bfe0c87bc6b822d3ff74fe9
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/20230711/9307c794/attachment-0001.html>


More information about the ghc-commits mailing list