[Git][ghc/ghc][wip/toolchain-selection] 3 commits: configure: Create and validate toolchain target file

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Tue Jun 27 18:13:09 UTC 2023



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


Commits:
e28c75cf by Rodrigo Mesquita at 2023-06-27T19:12:48+01:00
configure: Create and validate toolchain target file

Interpolate LeadingUnderscore in distrib/configure.ac.in

- - - - -
8b8d1341 by Rodrigo Mesquita at 2023-06-27T19:12:51+01:00
Split GHC.Platform.ArchOS from ghc-boot into ghc-platform

- - - - -
60765db6 by Rodrigo Mesquita at 2023-06-27T19:12:51+01:00
Use ghc-platform instead of ghc-boot

- - - - -


26 changed files:

- configure.ac
- + default.target.in
- distrib/configure.ac.in
- hadrian/bindist/Makefile
- hadrian/bindist/config.mk.in
- hadrian/cabal.project
- hadrian/hadrian.cabal
- hadrian/src/Packages.hs
- hadrian/src/Rules/BinaryDist.hs
- hadrian/src/Rules/ToolArgs.hs
- hadrian/src/Settings/Default.hs
- hadrian/stack.yaml
- libraries/ghc-boot/ghc-boot.cabal.in
- + libraries/ghc-platform/CHANGELOG.md
- + libraries/ghc-platform/LICENSE
- + libraries/ghc-platform/ghc-platform.cabal
- libraries/ghc-boot/GHC/Platform/ArchOS.hs → libraries/ghc-platform/src/GHC/Platform/ArchOS.hs
- m4/fp_prog_ar_needs_ranlib.m4
- m4/ghc_toolchain.m4
- + m4/prep_target_file.m4
- mk/project.mk.in
- utils/ghc-toolchain/Main.hs
- utils/ghc-toolchain/ghc-toolchain.cabal
- utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Ar.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs


Changes:

=====================================
configure.ac
=====================================
@@ -644,7 +644,6 @@ dnl CONF_CC_OPTS_STAGE[012] accordingly.
 FP_CC_SUPPORTS_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_CXX_OPTS_STAGE0], [CONF_GCC_LINKER_OPTS_STAGE0])
 FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_CXX_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1])
 FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_CXX_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2])
-FIND_GHC_TOOLCHAIN
 
 dnl Pass -Qunused-arguments or otherwise GHC will have very noisy invocations of Clang
 dnl TODO: Do we need -Qunused-arguments in CXX and GCC linker too?
@@ -1177,6 +1176,10 @@ checkMake380() {
 checkMake380 make
 checkMake380 gmake
 
+# Toolchain target files
+PREP_TARGET_FILE
+FIND_GHC_TOOLCHAIN
+
 AC_CONFIG_FILES(
 [ mk/project.mk
   hadrian/cfg/system.config
@@ -1185,6 +1188,7 @@ AC_CONFIG_FILES(
   hadrian/ghci-stack
   docs/users_guide/ghc_config.py
   distrib/configure.ac
+  default.target
 ])
 
 dnl Create the VERSION file, satisfying #22322.
@@ -1285,3 +1289,6 @@ mk/build.mk.sample to mk/build.mk, and edit the settings in there.
 For more information on how to configure your GHC build, see
    https://gitlab.haskell.org/ghc/ghc/wikis/building
 "]
+
+VALIDATE_GHC_TOOLCHAIN
+


=====================================
default.target.in
=====================================
@@ -0,0 +1,39 @@
+Target
+{ tgtArchOs = ArchOS {archOS_arch = @HaskellHostArch@, archOS_OS = @HaskellHostOs@}
+, tgtVendor = "@HostVendor_CPP@"
+, tgtSupportsGnuNonexecStack = @TargetHasGnuNonexecStackBool@
+, tgtSupportsSubsectionsViaSymbols = @TargetHasSubsectionsViaSymbolsBool@
+, tgtSupportsIdentDirective = @TargetHasIdentDirectiveBool@
+, tgtWordSize = WS at TargetWordSize@
+, tgtEndianness = @TargetEndianness@
+, tgtSymbolsHaveLeadingUnderscore = @LeadingUnderscoreBool@
+, tgtLlvmTarget = "@LlvmTarget@"
+, tgtUnregisterised = @UnregisterisedBool@
+, tgtTablesNextToCode = @TablesNextToCodeBool@
+, tgtUseLibffiForAdjustors = @UseLibffiForAdjustorsBool@
+, tgtCCompiler = Cc {ccProgram = Program {prgPath = "@SettingsCCompilerCommand@", prgFlags = @SettingsCCompilerFlagsList@}}
+, tgtCxxCompiler = Cxx {cxxProgram = Program {prgPath = "@SettingsCxxCompilerCommand@", prgFlags = @SettingsCxxCompilerFlagsList@}}
+, tgtCPreprocessor = Cpp {cppProgram = Program {prgPath = "@CPPCmd@", prgFlags = @CONF_CPP_OPTS_STAGE1List@}}
+, tgtHsCPreprocessor = HsCpp {hsCppProgram = Program {prgPath = "@HaskellCPPCmd@", prgFlags = @HaskellCPPArgsList@}}
+, tgtCCompilerLink = CcLink
+{ ccLinkProgram = Program {prgPath = "@SettingsCCompilerCommand@", prgFlags = @SettingsCCompilerLinkFlagsList@}
+, ccLinkSupportsNoPie = @SettingsCCompilerSupportsNoPieBool@
+, ccLinkSupportsCompactUnwind = @LdHasNoCompactUnwindBool@
+, ccLinkSupportsFilelist = @LdHasFilelistBool@
+, ccLinkIsGnu = @LdIsGNULdBool@
+}
+
+, tgtAr = Ar
+{ arMkArchive = Program {prgPath = "@AR@", prgFlags = @ArArgsList@}
+, arIsGnu = @ArIsGNUArBool@
+, arSupportsAtFile = @ArSupportsAtFileBool@
+, arSupportsDashL = @ArSupportsDashLBool@
+, arNeedsRanlib = @ArNeedsRanLibBool@
+}
+
+, tgtRanlib = Just (Ranlib {ranlibProgram = Program {prgPath = "@REAL_RANLIB_CMD@", prgFlags = []}})
+, tgtNm = Nm {nmProgram = Program {prgPath = "@NmCmd@", prgFlags = []}}
+, tgtMergeObjs = Just (MergeObjs {mergeObjsProgram = Program {prgPath = "@SettingsMergeObjectsCommand@", prgFlags = @SettingsMergeObjectsFlagsList@}, mergeObjsSupportsResponseFiles = @MergeObjsSupportsResponseFilesBool@})
+, tgtDllwrap = @DllWrapCmdMaybeProg@
+, tgtWindres = @WindresCmdMaybeProg@
+}


=====================================
distrib/configure.ac.in
=====================================
@@ -57,10 +57,12 @@ if test "$target" != "$host" ; then
                           #   configure: error: cannot run C compiled programs.
                           #   If you meant to cross compile, use `--host'.
 fi
+LeadingUnderscore="@LeadingUnderscore@"
 CrossCompilePrefix="@CrossCompilePrefix@"
 TargetPlatformFull="${target}"
 TablesNextToCode="@TablesNextToCode@"
 
+AC_SUBST(LeadingUnderscore)
 AC_SUBST(CrossCompiling)
 AC_SUBST(CrossCompilePrefix)
 AC_SUBST(TargetPlatformFull)
@@ -286,6 +288,7 @@ AC_SUBST(UseLibdw)
 FP_SETTINGS
 
 AC_CONFIG_FILES([config.mk])
+AC_CONFIG_FILES([default.target])
 AC_OUTPUT
 
 # We get caught by
@@ -307,6 +310,11 @@ checkMake380() {
 checkMake380 make
 checkMake380 gmake
 
+# Toolchain target files
+PREP_TARGET_FILE
+FIND_GHC_TOOLCHAIN
+VALIDATE_GHC_TOOLCHAIN
+
 echo "****************************************************"
 echo "Configuration done, ready to 'make install'"
 echo "(see README and INSTALL files for more info.)"


=====================================
hadrian/bindist/Makefile
=====================================
@@ -1,7 +1,10 @@
 MAKEFLAGS += --no-builtin-rules
 .SUFFIXES:
 
+# Configuration from the source distribution's configure script.
 include ./mk/project.mk
+
+# Configuration from the binary distribution's configure script.
 include ./config.mk
 
 .PHONY: default


=====================================
hadrian/bindist/config.mk.in
=====================================
@@ -254,6 +254,8 @@ TargetHasIdentDirective = @TargetHasIdentDirective@
 TargetHasSubsectionsViaSymbols = @TargetHasSubsectionsViaSymbols@
 TargetHasLibm = @TargetHasLibm@
 TablesNextToCode = @TablesNextToCode@
+LeadingUnderscore = @LeadingUnderscore@
+LlvmTarget = @LlvmTarget@
 
 SettingsCCompilerCommand = @SettingsCCompilerCommand@
 SettingsCxxCompilerCommand = @SettingsCxxCompilerCommand@


=====================================
hadrian/cabal.project
=====================================
@@ -1,5 +1,6 @@
 packages: ./
           ../utils/ghc-toolchain/
+          ../libraries/ghc-platform/
 
 -- This essentially freezes the build plan for hadrian
 index-state: 2023-03-30T10:00:00Z


=====================================
hadrian/hadrian.cabal
=====================================
@@ -166,8 +166,8 @@ executable hadrian
                        , text                 >= 1.2     && < 3
                        , cryptohash-sha256    >= 0.11    && < 0.12
                        , base16-bytestring    >= 0.1.1 && < 1.1.0.0
+                       , ghc-platform
                        , ghc-toolchain
-                       , ghc-boot
     ghc-options:       -Wall
                        -Wincomplete-record-updates
                        -Wredundant-constraints


=====================================
hadrian/src/Packages.hs
=====================================
@@ -4,7 +4,7 @@ module Packages (
     array, base, binary, bytestring, cabal, cabalSyntax, checkPpr,
     checkExact, countDeps,
     compareSizes, compiler, containers, deepseq, deriveConstants, directory,
-    exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh,
+    exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcPlatform,
     ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline,
     hsc2hs, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy,
     libffi, mtl, parsec, pretty, primitive, process, remoteIserv, rts,
@@ -36,7 +36,7 @@ ghcPackages :: [Package]
 ghcPackages =
     [ array, base, binary, bytestring, cabalSyntax, cabal, checkPpr, checkExact, countDeps
     , compareSizes, compiler, containers, deepseq, deriveConstants, directory
-    , exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh
+    , exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcPlatform
     , ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs
     , hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, libffi, mtl
     , parsec, pretty, process, rts, runGhc, stm, semaphoreCompat, templateHaskell
@@ -52,7 +52,7 @@ isGhcPackage = (`elem` ghcPackages)
 -- | Package definitions, see 'Package'.
 array, base, binary, bytestring, cabalSyntax, cabal, checkPpr, checkExact, countDeps,
   compareSizes, compiler, containers, deepseq, deriveConstants, directory,
-  exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh,
+  exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcPlatform,
   ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs,
   hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy, remoteIserv, libffi, mtl,
   parsec, pretty, primitive, process, rts, runGhc, semaphoreCompat, stm, templateHaskell,
@@ -83,6 +83,7 @@ ghc                 = prg  "ghc-bin"         `setPath` "ghc"
 ghcBignum           = lib  "ghc-bignum"
 ghcBoot             = lib  "ghc-boot"
 ghcBootTh           = lib  "ghc-boot-th"
+ghcPlatform         = lib  "ghc-platform"
 ghcCompact          = lib  "ghc-compact"
 ghcConfig           = prg  "ghc-config"      `setPath` "testsuite/ghc-config"
 ghcHeap             = lib  "ghc-heap"


=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -258,6 +258,7 @@ bindistRules = do
           need $ map (bindistFilesDir -/-)
                     (["configure", "Makefile"] ++ bindistInstallFiles)
           copyFile ("hadrian" -/- "bindist" -/- "config.mk.in") (bindistFilesDir -/- "config.mk.in")
+          copyFile ("default.target.in") (bindistFilesDir -/- "default.target.in")
           forM_ bin_targets $ \(pkg, _) -> do
             needed_wrappers <- pkgToWrappers pkg
             forM_ needed_wrappers $ \wrapper_name -> do


=====================================
hadrian/src/Rules/ToolArgs.hs
=====================================
@@ -158,6 +158,7 @@ toolTargets = [ binary
               -- , runGhc  -- # depends on ghc library
               , ghcBoot
               , ghcBootTh
+              , ghcPlatform
               , ghcHeap
               , ghci
               , ghcPkg  -- # executable


=====================================
hadrian/src/Settings/Default.hs
=====================================
@@ -85,6 +85,7 @@ stage0Packages = do
              , runGhc
              , ghcBoot
              , ghcBootTh
+             , ghcPlatform
              , ghcHeap
              , ghci
              , ghcPkg


=====================================
hadrian/stack.yaml
=====================================
@@ -3,6 +3,7 @@ resolver: lts-19.8
 packages:
 - '.'
 - '../utils/ghc-toolchain'
+- '../libraries/ghc-platform'
 
 nix:
    enable: false


=====================================
libraries/ghc-boot/ghc-boot.cabal.in
=====================================
@@ -51,7 +51,6 @@ Library
             GHC.Serialized
             GHC.ForeignSrcLang
             GHC.HandleEncoding
-            GHC.Platform.ArchOS
             GHC.Platform.Host
             GHC.Settings.Utils
             GHC.UniqueSubdir
@@ -65,6 +64,10 @@ Library
             , GHC.ForeignSrcLang.Type
             , GHC.Lexeme
 
+    -- reexport platform modules from ghc-platform
+    reexported-modules:
+              GHC.Platform.ArchOS
+
     -- but done by Hadrian
     autogen-modules:
             GHC.Version
@@ -77,6 +80,7 @@ Library
                    directory  >= 1.2 && < 1.4,
                    filepath   >= 1.3 && < 1.5,
                    deepseq    >= 1.4 && < 1.5,
+                   ghc-platform >= 0.1,
                    ghc-boot-th == @ProjectVersionMunged@
     if !os(windows)
         build-depends:


=====================================
libraries/ghc-platform/CHANGELOG.md
=====================================
@@ -0,0 +1,8 @@
+# Revision history for ghc-platform
+
+## 0.1.0.0 -- 2023-06-20
+
+* First version. Split off the `GHC.Platform.ArchOS` module from the
+    non-reinstallable `ghc-boot` package into this reinstallable standalone
+    package which abides by the PVP, in part motivated by the ongoing work on
+    `ghc-toolchain` towards runtime retargetability.


=====================================
libraries/ghc-platform/LICENSE
=====================================
@@ -0,0 +1,30 @@
+Copyright (c) 2023, Rodrigo Mesquita
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * Neither the name of Rodrigo Mesquita nor the names of other
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


=====================================
libraries/ghc-platform/ghc-platform.cabal
=====================================
@@ -0,0 +1,20 @@
+cabal-version:      3.0
+name:               ghc-platform
+version:            0.1.0.0
+synopsis:           Platform information used by GHC and friends
+license:            BSD-3-Clause
+license-file:       LICENSE
+author:             Rodrigo Mesquita
+maintainer:         ghc-devs at haskell.org
+build-type:         Simple
+extra-doc-files:    CHANGELOG.md
+
+common warnings
+    ghc-options: -Wall
+
+library
+    import:           warnings
+    exposed-modules:  GHC.Platform.ArchOS
+    build-depends:    base >=4.15.0.0
+    hs-source-dirs:   src
+    default-language: Haskell2010


=====================================
libraries/ghc-boot/GHC/Platform/ArchOS.hs → libraries/ghc-platform/src/GHC/Platform/ArchOS.hs
=====================================


=====================================
m4/fp_prog_ar_needs_ranlib.m4
=====================================
@@ -46,4 +46,5 @@ AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],[
     fi
     AC_SUBST([REAL_RANLIB_CMD])
     AC_SUBST([RANLIB_CMD])
+    AC_SUBST([ArNeedsRanLib],[`echo $fp_cv_prog_ar_needs_ranlib | tr 'a-z' 'A-Z'`])
 ])# FP_PROG_AR_NEEDS_RANLIB


=====================================
m4/ghc_toolchain.m4
=====================================
@@ -22,7 +22,7 @@ AC_DEFUN([ENABLE_GHC_TOOLCHAIN_ARG],
 AC_DEFUN([FIND_GHC_TOOLCHAIN],
 [
     "$GHC" -v0 \
-        -ilibraries/ghc-boot -iutils/ghc-toolchain/src \
+        -ilibraries/ghc-platform/src -iutils/ghc-toolchain/src \
         -XNoImplicitPrelude \
         -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \
         utils/ghc-toolchain/Main.hs -o acghc-toolchain
@@ -67,8 +67,19 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
     ) <acargs || exit 1
 
     cat acargs
-    cat default.target
+    cat default.ghc-toolchain.target
 
     #rm -Rf acargs acghc-toolchain actmp-ghc-toolchain
 ])
 
+
+AC_DEFUN([VALIDATE_GHC_TOOLCHAIN],[
+    A="default.target"
+    B="default.ghc-toolchain.target"
+    diff_output=`diff "$A" "$B" 2>&1`
+    if test -z "$diff_output"; then
+      true
+    else
+      AC_MSG_WARN([Differences found between $A and $B: $diff_output])
+    fi
+])


=====================================
m4/prep_target_file.m4
=====================================
@@ -0,0 +1,114 @@
+# PREP_MAYBE_SIMPLE_PROGRAM
+# =========================
+#
+# Issue a substitution of [$1MaybeProg] with
+# * Nothing, if $1 is empty
+# * Just (Program {prgPath = "$$1", prgFlags = []}), otherwise
+#
+# $1 = optional value
+AC_DEFUN([PREP_MAYBE_SIMPLE_PROGRAM],[
+    if test -z "[$]$1"; then
+      $1MaybeProg='Nothing'
+    else
+      $1MaybeProg='Just (Program {prgPath = "$$1", prgFlags = @<:@@:>@})'
+    fi
+    AC_SUBST([$1MaybeProg])
+])
+
+# PREP_BOOLEAN
+# ============
+#
+# Issue a substitution with True/False of [$1Bool] when $1 has YES/NO value
+# $1 = boolean variable to substitute
+AC_DEFUN([PREP_BOOLEAN],[
+    case "$$1" in
+        YES)
+          $1Bool=True
+          ;;
+        NO)
+          $1Bool=False
+          ;;
+        *)
+          AC_MSG_ERROR([Expecting YES/NO but got $$1 in $1])
+          ;;
+    esac
+    AC_SUBST([$1Bool])
+])
+
+# PREP_LIST
+# ============
+#
+# Issue a substitution with ["list","of","args"] of [$1List] when $1 is a
+# space-separated list of args
+# i.e.
+# "arg1 arg2 arg3"
+# ==>
+# ["arg1","arg2","arg3"]
+#
+# $1 = list variable to substitute
+dnl In autoconf, '@<:@' stands for '[', and '@:>@' for ']'.
+AC_DEFUN([PREP_LIST],[
+    # shell array
+    set -- $$1
+    $1List="@<:@"
+    if test "[$]#" -eq 0; then
+        # no arguments
+        true
+    else
+        $1List="${$1List}\"[$]1\""
+        shift # drop first elem
+        for arg in "[$]@"
+        do
+            $1List="${$1List},\"$arg\""
+        done
+    fi
+    $1List="${$1List}@:>@"
+
+    AC_SUBST([$1List])
+])
+
+# Eventually: PREP_BUILD_TARGET_FILE, PREP_HOST_TARGET_FILE, PREP_TARGET_TARGET_FILE
+# Prepares required substitutions to generate the target file
+AC_DEFUN([PREP_TARGET_FILE],[
+    PREP_BOOLEAN([MergeObjsSupportsResponseFiles])
+    PREP_BOOLEAN([TargetHasGnuNonexecStack])
+    PREP_BOOLEAN([LeadingUnderscore])
+    PREP_BOOLEAN([ArSupportsAtFile])
+    PREP_BOOLEAN([ArSupportsDashL])
+    PREP_BOOLEAN([TargetHasIdentDirective])
+    PREP_BOOLEAN([SettingsCCompilerSupportsNoPie])
+    PREP_BOOLEAN([LdHasFilelist])
+    PREP_BOOLEAN([LdIsGNULd])
+    PREP_BOOLEAN([LdHasNoCompactUnwind])
+    PREP_BOOLEAN([TargetHasSubsectionsViaSymbols])
+    PREP_BOOLEAN([Unregisterised])
+    PREP_BOOLEAN([TablesNextToCode])
+    PREP_BOOLEAN([UseLibffiForAdjustors])
+    PREP_BOOLEAN([ArIsGNUAr])
+    PREP_BOOLEAN([ArNeedsRanLib])
+    PREP_LIST([SettingsMergeObjectsFlags])
+    PREP_LIST([ArArgs])
+    PREP_LIST([SettingsCCompilerLinkFlags])
+    PREP_LIST([HaskellCPPArgs])
+    PREP_LIST([CONF_CPP_OPTS_STAGE1])
+    PREP_LIST([SettingsCxxCompilerFlags])
+    PREP_LIST([SettingsCCompilerFlags])
+    PREP_MAYBE_SIMPLE_PROGRAM([DllWrapCmd])
+    PREP_MAYBE_SIMPLE_PROGRAM([WindresCmd])
+
+    dnl PREP_ENDIANNESS
+    case "$TargetWordBigEndian" in
+        YES)
+            TargetEndianness=BigEndian
+            ;;
+        NO)
+            TargetEndianness=LittleEndian
+            ;;
+        *)
+            AC_MSG_ERROR([Expecting YES/NO but got $TargetWordBigEndian in TargetWordBigEndian])
+            ;;
+    esac
+    AC_SUBST([TargetEndianness])
+])
+
+AC_DEFUN()


=====================================
mk/project.mk.in
=====================================
@@ -123,11 +123,6 @@ BuildVendor_CPP         = @BuildVendor_CPP@
 #
 ################################################################################
 
-# Leading underscores on symbol names in object files
-# Valid options: YES/NO
-#
-LeadingUnderscore=@LeadingUnderscore@
-
 # Pin a suffix on executables? If so, what (Windows only).
 exeext0=@exeext_host@
 exeext1=@exeext_target@


=====================================
utils/ghc-toolchain/Main.hs
=====================================
@@ -225,7 +225,8 @@ run :: Opts -> M ()
 run opts = do
     tgt <- mkTarget opts
     logDebug $ "Final Target: " ++ show tgt
-    writeFile "default.target" (show tgt)
+    let file = "default.ghc-toolchain.target"
+    writeFile file (show tgt)
 
 optional :: M a -> M (Maybe a)
 optional k = fmap Just k <|> pure Nothing


=====================================
utils/ghc-toolchain/ghc-toolchain.cabal
=====================================
@@ -36,8 +36,7 @@ library
                       filepath,
                       process,
                       transformers,
-                      async,
-                      ghc-boot
+                      ghc-platform
     hs-source-dirs:   src
     default-language: Haskell2010
 
@@ -50,6 +49,6 @@ executable ghc-toolchain
                       filepath,
                       process,
                       transformers,
-                      ghc-boot,
+                      ghc-platform,
                       ghc-toolchain
     default-language: Haskell2010


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Target.hs
=====================================
@@ -1,3 +1,4 @@
+{-# LANGUAGE RecordWildCards #-}
 module GHC.Toolchain.Target where
 
 import GHC.Platform.ArchOS
@@ -60,7 +61,36 @@ data Target = Target
     , tgtDllwrap :: Maybe Program
     , tgtWindres :: Maybe Program
     }
-    deriving (Show, Read, Eq, Ord)
+    deriving (Read, Eq, Ord)
+
+instance Show Target where
+  show Target{..} = unlines
+    [ "Target"
+    , "{ tgtArchOs = " ++ show tgtArchOs
+    , ", tgtVendor = " ++ show tgtVendor
+    , ", tgtSupportsGnuNonexecStack = " ++ show tgtSupportsGnuNonexecStack
+    , ", tgtSupportsSubsectionsViaSymbols = " ++ show tgtSupportsSubsectionsViaSymbols
+    , ", tgtSupportsIdentDirective = " ++ show tgtSupportsIdentDirective
+    , ", tgtWordSize = " ++ show tgtWordSize
+    , ", tgtEndianness = " ++ show tgtEndianness
+    , ", tgtSymbolsHaveLeadingUnderscore = " ++ show tgtSymbolsHaveLeadingUnderscore
+    , ", tgtLlvmTarget = " ++ show tgtLlvmTarget
+    , ", tgtUnregisterised = " ++ show tgtUnregisterised
+    , ", tgtTablesNextToCode = " ++ show tgtTablesNextToCode
+    , ", tgtUseLibffiForAdjustors = " ++ show tgtUseLibffiForAdjustors
+    , ", tgtCCompiler = " ++ show tgtCCompiler
+    , ", tgtCxxCompiler = " ++ show tgtCxxCompiler
+    , ", tgtCPreprocessor = " ++ show tgtCPreprocessor
+    , ", tgtHsCPreprocessor = " ++ show tgtHsCPreprocessor
+    , ", tgtCCompilerLink = " ++ show tgtCCompilerLink
+    , ", tgtAr = " ++ show tgtAr
+    , ", tgtRanlib = " ++ show tgtRanlib
+    , ", tgtNm = " ++ show tgtNm
+    , ", tgtMergeObjs = " ++ show tgtMergeObjs
+    , ", tgtDllwrap = " ++ show tgtDllwrap
+    , ", tgtWindres = " ++ show tgtDllwrap
+    , "}"
+    ]
 
 -- | The word size as an integer representing the number of bytes
 wordSize2Bytes :: WordSize -> Int


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Ar.hs
=====================================
@@ -17,7 +17,19 @@ data Ar = Ar { arMkArchive :: Program
              , arSupportsDashL :: Bool
              , arNeedsRanlib :: Bool
              }
-    deriving (Show, Read, Eq, Ord)
+    deriving (Read, Eq, Ord)
+
+-- These instances are more suitable for diffing
+instance Show Ar where
+  show Ar{..} = unlines
+    [ "Ar"
+    , "{ arMkArchive = " ++ show arMkArchive
+    , ", arIsGnu = " ++ show arIsGnu
+    , ", arSupportsAtFile = " ++ show arSupportsAtFile
+    , ", arSupportsDashL = " ++ show arSupportsDashL
+    , ", arNeedsRanlib = " ++ show arNeedsRanlib
+    , "}"
+    ]
 
 findAr :: Maybe String -- ^ Vendor name from the target triple, if specified
        -> ProgOpt -> M Ar


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
=====================================
@@ -1,5 +1,6 @@
 {-# OPTIONS_GHC -Wno-name-shadowing #-}
 {-# LANGUAGE NamedFieldPuns #-}
+{-# LANGUAGE RecordWildCards #-}
 {-# LANGUAGE CPP #-}
 
 module GHC.Toolchain.Tools.Link ( CcLink(..), findCcLink ) where
@@ -23,7 +24,19 @@ data CcLink = CcLink { ccLinkProgram :: Program
                      , ccLinkSupportsFilelist :: Bool      -- This too
                      , ccLinkIsGnu :: Bool -- We once thought this could instead be LdSupportsGcSections, but then realized it couldn't IIRC
                      }
-    deriving (Show, Read, Eq, Ord)
+    deriving (Read, Eq, Ord)
+
+-- These instances are more suitable for diffing
+instance Show CcLink where
+  show CcLink{..} = unlines
+    [ "CcLink"
+    , "{ ccLinkProgram = " ++ show ccLinkProgram
+    , ", ccLinkSupportsNoPie = " ++ show ccLinkSupportsNoPie
+    , ", ccLinkSupportsCompactUnwind = " ++ show ccLinkSupportsCompactUnwind
+    , ", ccLinkSupportsFilelist = " ++ show ccLinkSupportsFilelist
+    , ", ccLinkIsGnu = " ++ show ccLinkIsGnu
+    , "}"
+    ]
 
 _ccLinkProgram :: Lens CcLink Program
 _ccLinkProgram = Lens ccLinkProgram (\x o -> o{ccLinkProgram=x})



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/537b9c4d285cfdcfe7c9ec5e525edbf744426ddb...60765db6db883b658feb087ddddcb796882d1323

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/537b9c4d285cfdcfe7c9ec5e525edbf744426ddb...60765db6db883b658feb087ddddcb796882d1323
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/20230627/f818fe79/attachment-0001.html>


More information about the ghc-commits mailing list