[Git][ghc/ghc][wip/toolchain-selection] Add flag to enable/disable ghc-toolchain based configurations

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Tue Jul 11 17:32:17 UTC 2023



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


Commits:
48f6dd22 by Rodrigo Mesquita at 2023-07-11T18:31:31+01:00
Add flag to enable/disable ghc-toolchain based configurations

This flag is disabled by default, and we'll use the
configure-generated-toolchains by default until we remove the toolchain
configuration logic from configure.

- - - - -


6 changed files:

- configure.ac
- distrib/configure.ac.in
- hadrian/cfg/system.config.in
- hadrian/src/Hadrian/Oracles/TextFile.hs
- hadrian/src/Oracles/Flag.hs
- m4/ghc_toolchain.m4


Changes:

=====================================
configure.ac
=====================================
@@ -163,6 +163,13 @@ if test "$EnableNativeIOManager" = "YES"; then
   AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.])
 fi
 
+AC_ARG_ENABLE(ghc-toolchain,
+[AS_HELP_STRING([--enable-ghc-toolchain],
+                [Whether to use the newer ghc-toolchain tool to configure ghc targets])],
+  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableGhcToolchain])],
+  [EnableGhcToolchain=NO]
+)
+AC_SUBST([EnableGhcToolchain])
 
 dnl CC_STAGE0, LD_STAGE0, AR_STAGE0 are like the "previous" variable
 dnl CC, LD, AR (inherited by CC_STAGE[123], etc.)
@@ -1304,7 +1311,7 @@ For more information on how to configure your GHC build, see
 # have a correct complete /host/ toolchain rather than an incomplete one, which
 # might further unlock things like canadian cross-compilation
 #
-# VALIDATE_GHC_TOOLCHAIN([default.host.target],[default.ghc-toolchain.host.target])
+# VALIDATE_GHC_TOOLCHAIN([default.host.target],[default.host.target.ghc-toolchain])
 
-VALIDATE_GHC_TOOLCHAIN([default.target],[default.ghc-toolchain.target])
+VALIDATE_GHC_TOOLCHAIN([default.target],[default.target.ghc-toolchain])
 


=====================================
distrib/configure.ac.in
=====================================
@@ -314,7 +314,7 @@ checkMake380 gmake
 PREP_TARGET_FILE
 FIND_GHC_TOOLCHAIN
 
-VALIDATE_GHC_TOOLCHAIN([default.target],[default.ghc-toolchain.target])
+VALIDATE_GHC_TOOLCHAIN([default.target],[default.target.ghc-toolchain])
 
 echo "****************************************************"
 echo "Configuration done, ready to 'make install'"


=====================================
hadrian/cfg/system.config.in
=====================================
@@ -38,6 +38,7 @@ cc-llvm-backend           = @CcLlvmBackend@
 #===============
 
 ghc-source-path      = @hardtop@
+use-ghc-toolchain    = @EnableGhcToolchain@
 
 # Information about build, host and target systems:
 #==================================================


=====================================
hadrian/src/Hadrian/Oracles/TextFile.hs
=====================================
@@ -89,7 +89,10 @@ lookupDependencies depFile file = do
 -- | Parse a target from a text file, tracking the result. The file is expected
 -- to contain a parseable Toolchain.Target value generated by ghc-toolchain.
 getTargetConfig :: FilePath -> Action Toolchain.Target
-getTargetConfig file = askOracle $ TargetFile file
+getTargetConfig file0 = do
+  useGhcToolchain <- lookupSystemConfig "use-ghc-toolchain"
+  let file1 = if useGhcToolchain == "YES" then file0 <.> "ghc-toolchain" else file0
+  askOracle $ TargetFile file1
 
 -- | Get the build target configuration through 'getTargetConfig'
 getBuildTarget :: Action Toolchain.Target


=====================================
hadrian/src/Oracles/Flag.hs
=====================================
@@ -38,6 +38,7 @@ data Flag = CrossCompiling
           | UseLibbfd
           | UseLibpthread
           | NeedLibatomic
+          | UseGhcToolchain
 
 -- Note, if a flag is set to empty string we treat it as set to NO. This seems
 -- fragile, but some flags do behave like this.
@@ -61,6 +62,7 @@ flag f = do
             UseLibbfd            -> "use-lib-bfd"
             UseLibpthread        -> "use-lib-pthread"
             NeedLibatomic        -> "need-libatomic"
+            UseGhcToolchain      -> "use-ghc-toolchain"
     value <- lookupSystemConfig key
     when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag "
         ++ quote (key ++ " = " ++ value) ++ " cannot be parsed."


=====================================
m4/ghc_toolchain.m4
=====================================
@@ -51,7 +51,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
     # (1) Configure a toolchain for the build and host platform (we require that BUILD=HOST, so one toolchain suffices)
     rm -f acargs
     echo "--triple=$HostPlatform" >> acargs
-    echo "--output=default.ghc-toolchain.host.target" >> acargs
+    echo "--output=default.host.target.ghc-toolchain" >> acargs
     dnl echo "--llvm-triple=$LlvmTarget" >> acargs
     echo "--cc=$CC_STAGE0" >> acargs
     dnl echo "--readelf=$READELF" >> acargs
@@ -84,7 +84,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
     # calling it through configure.
     rm -f acargs
     echo "--triple=$target" >> acargs
-    echo "--output=default.ghc-toolchain.target" >> acargs
+    echo "--output=default.target.ghc-toolchain" >> acargs
     echo "--llvm-triple=$LlvmTarget" >> acargs
     echo "--cc=$CC" >> acargs
     echo "--cxx=$CXX" >> acargs
@@ -124,7 +124,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
 
 
 dnl $1 like "default.target"
-dnl $2 like "default.ghc-toolchain.target"
+dnl $2 like "default.target.ghc-toolchain"
 AC_DEFUN([VALIDATE_GHC_TOOLCHAIN],[
     diff_output=`diff "$1" "$2" 2>&1`
     if test -z "$diff_output"; then



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/48f6dd226dab48e282c96bb896a3d1f72c9a6cad

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/48f6dd226dab48e282c96bb896a3d1f72c9a6cad
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/1fc905cf/attachment-0001.html>


More information about the ghc-commits mailing list