[Git][ghc/ghc][wip/hadrian-subst-bindist] Substitute bindist files with Hadrian
John Ericson (@Ericson2314)
gitlab at gitlab.haskell.org
Sat Feb 10 00:40:58 UTC 2024
John Ericson pushed to branch wip/hadrian-subst-bindist at Glasgow Haskell Compiler / GHC
Commits:
e65aaabf by John Ericson at 2024-02-09T19:39:42-05:00
Substitute bindist files with Hadrian
The `ghc-toolchain` overhaul will eventually replace all this stuff with
something much more cleaned up, but I think it is still worth making
this sort of cleanup in the meantime so other untanglings and dead code
cleaning can procede.
I was able to delete a fair amount of dead code doing this too.
Progress on #23966
- - - - -
8 changed files:
- configure.ac
- distrib/configure.ac.in
- hadrian/bindist/Makefile
- hadrian/bindist/config.mk.in
- hadrian/cfg/system.config.in
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Rules/Generate.hs
- mk/project.mk.in
Changes:
=====================================
configure.ac
=====================================
@@ -379,15 +379,7 @@ then
else
TargetPlatformFull="${target_alias}"
fi
-if test "$CrossCompiling" = "YES"
-then
- # Use value passed by user from --target=
- CrossCompilePrefix="${TargetPlatformFull}-"
-else
- CrossCompilePrefix=""
-fi
AC_SUBST(CrossCompiling)
-AC_SUBST(CrossCompilePrefix)
AC_SUBST(TargetPlatformFull)
dnl ** Which gcc to use?
@@ -619,9 +611,6 @@ FP_LD_NO_WARN_DUPLICATE_LIBRARIES([target], [CONF_GCC_LINKER_OPTS_STAGE2])
FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES
GHC_LLVM_TARGET_SET_VAR
-# we intend to pass trough --targets to llvm as is.
-LLVMTarget_CPP=` echo "$LlvmTarget"`
-AC_SUBST(LLVMTarget_CPP)
# The target is substituted into the distrib/configure.ac file
AC_SUBST(LlvmTarget)
@@ -951,12 +940,10 @@ PREP_TARGET_FILE
FIND_GHC_TOOLCHAIN([hadrian/cfg])
AC_CONFIG_FILES(
-[ mk/project.mk
- hadrian/cfg/system.config
+[ hadrian/cfg/system.config
hadrian/ghci-cabal
hadrian/ghci-multi-cabal
hadrian/ghci-stack
- distrib/configure.ac
hadrian/cfg/default.host.target
hadrian/cfg/default.target
])
=====================================
distrib/configure.ac.in
=====================================
@@ -23,19 +23,12 @@ bootstrap_llvm_target=@LlvmTarget@
TargetHasLibm=@TargetHasLibm@
AC_SUBST(TargetHasLibm)
-FFIIncludeDir=@FFIIncludeDir@
-FFILibDir=@FFILibDir@
-AC_SUBST(FFILibDir)
-AC_SUBST(FFIIncludeDir)
-
-LibdwIncludeDir=@LibdwIncludeDir@
-LibdwLibDir=@LibdwLibDir@
-AC_SUBST(LibdwLibDir)
-AC_SUBST(LibdwIncludeDir)
-
UseLibffiForAdjustors=@UseLibffiForAdjustors@
AC_SUBST(UseLibffiForAdjustors)
+GhcWithSMP=@GhcWithSMP@
+AC_SUBST(GhcWithSMP)
+
# We have to run these unconditionally as FPTOOLS_SET_PLATFORMS_VARS wants the
# values it computes.
AC_CANONICAL_BUILD
@@ -59,13 +52,11 @@ if test "$target" != "$host" ; then
fi
LeadingUnderscore="@LeadingUnderscore@"
CrossCompilePrefix="@CrossCompilePrefix@"
-TargetPlatformFull="${target}"
TablesNextToCode="@TablesNextToCode@"
AC_SUBST(LeadingUnderscore)
AC_SUBST(CrossCompiling)
AC_SUBST(CrossCompilePrefix)
-AC_SUBST(TargetPlatformFull)
AC_SUBST(TablesNextToCode)
Unregisterised="@Unregisterised@"
=====================================
hadrian/bindist/Makefile
=====================================
@@ -2,7 +2,7 @@ MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
# Configuration from the source distribution's configure script.
-include ./mk/project.mk
+include ./source.mk
# Configuration from the binary distribution's configure script.
include ./config.mk
=====================================
hadrian/bindist/config.mk.in
=====================================
@@ -134,20 +134,9 @@ CrossCompiling = @CrossCompiling@
CrossCompilePrefix = @CrossCompilePrefix@
GhcUnregisterised = @Unregisterised@
-# ArchSupportsSMP should be set iff there is support for that arch in
-# rts/include/stg/SMP.h
-ifeq "$(TargetArch_CPP)" "arm"
-# We don't support load/store barriers pre-ARMv7. See #10433.
-ArchSupportsSMP=$(if $(filter $(ARM_ISA),ARMv5 ARMv6),NO,YES)
-else ifeq "$(TargetArch_CPP)" "javascript"
-ArchSupportsSMP=NO
-else
-ArchSupportsSMP=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 sparc powerpc powerpc64 powerpc64le s390x aarch64 riscv64)))
-endif
-
# The THREADED_RTS requires `BaseReg` to be in a register and the
# `GhcUnregisterised` mode doesn't allow that.
-GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO))
+GhcWithSMP := @GhcWithSMP@
# Whether to include GHCi in the compiler. Depends on whether the RTS linker
# has support for this OS/ARCH combination.
=====================================
hadrian/cfg/system.config.in
=====================================
@@ -130,3 +130,5 @@ use-lib-dl = @UseLibdl@
use-lib-bfd = @UseLibbfd@
use-lib-pthread = @UseLibpthread@
need-libatomic = @NeedLibatomic@
+
+emsdk-version = @ConfiguredEmsdkVersion@
=====================================
hadrian/src/Oracles/Setting.hs
=====================================
@@ -72,6 +72,7 @@ data Setting = CursesIncludeDir
| SystemGhc
| TargetPlatformFull
| BourneShell
+ | EmsdkVersion
-- TODO compute solely in Hadrian, removing these variables' definitions
-- from aclocal.m4 whenever they can be calculated from other variables
@@ -129,6 +130,7 @@ setting key = lookupSystemConfig $ case key of
SystemGhc -> "system-ghc"
TargetPlatformFull -> "target-platform-full"
BourneShell -> "bourne-shell"
+ EmsdkVersion -> "emsdk-version"
-- | Look up the value of a 'SettingList' in @cfg/system.config@, tracking the
-- result.
=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -340,6 +340,55 @@ templateRules = do
[ interpolateVar "LlvmMinVersion" $ replaceEq '.' ',' <$> setting LlvmMinVersion
, interpolateVar "LlvmMaxVersion" $ replaceEq '.' ',' <$> setting LlvmMaxVersion
]
+ bindistRules
+
+bindistRules :: Rules ()
+bindistRules = do
+ templateRule "mk/project.mk" $ mconcat
+ [ interpolateSetting "ProjectName" ProjectName
+ , interpolateSetting "ProjectVersion" ProjectVersion
+ , interpolateSetting "ProjectVersionInt" ProjectVersionInt
+ , interpolateSetting "ProjectPatchLevel" ProjectPatchLevel
+ , interpolateSetting "ProjectPatchLevel1" ProjectPatchLevel1
+ , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2
+ , interpolateSetting "ProjectGitCommitId" ProjectGitCommitId
+
+ , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple
+ , interpolateVar "TargetPlatform_CPP" $ cppify <$> getTarget targetPlatformTriple
+ , interpolateVar "TargetArch_CPP" $ cppify <$> getTarget queryArch
+ , interpolateVar "TargetOS_CPP" $ cppify <$> getTarget queryOS
+ , interpolateVar "LLVMTarget_CPP" $ cppify <$> getTarget tgtLlvmTarget
+ ]
+ templateRule "distrib/configure.ac" $ mconcat
+ [ interpolateSetting "ConfiguredEmsdkVersion" EmsdkVersion
+ , interpolateVar "CrossCompilePrefix" $ do
+ crossCompiling <- interp $ getFlag CrossCompiling
+ tpf <- setting TargetPlatformFull
+ pure $ if crossCompiling then tpf <> "-" else ""
+ , interpolateVar "LeadingUnderscore" $ yesNo <$> getTarget tgtSymbolsHaveLeadingUnderscore
+ , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion
+ , interpolateSetting "LlvmMinVersion" LlvmMinVersion
+ , interpolateVar "LlvmTarget" $ getTarget tgtLlvmTarget
+ , interpolateSetting "ProjectVersion" ProjectVersion
+ , interpolateVar "SettingsUseDistroMINGW" $ settingsFileSetting ToolchainSetting_DistroMinGW
+ , interpolateVar "TablesNextToCode" $ yesNo <$> getTarget tgtTablesNextToCode
+ , interpolateVar "TargetHasLibm" $ lookupSystemConfig "target-has-libm"
+ , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple
+ , interpolateVar "TargetWordBigEndian" $ getTarget isBigEndian
+ , interpolateVar "TargetWordSize" $ getTarget wordSize
+ , interpolateVar "Unregisterised" $ yesNo <$> getTarget tgtUnregisterised
+ , interpolateVar "UseLibdw" $ fmap yesNo $ interp $ getFlag UseLibdw
+ , interpolateVar "UseLibffiForAdjustors" $ yesNo <$> getTarget tgtUseLibffiForAdjustors
+ , interpolateVar "GhcWithSMP" $ yesNo <$> targetSupportsSMP
+ ]
+ where
+ interp = interpretInContext (semiEmptyTarget Stage2)
+ getTarget = interp . queryTarget
+
+-- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that
+-- the resulting 'String' is a valid C preprocessor identifier.
+cppify :: String -> String
+cppify = replaceEq '-' '_' . replaceEq '.' '_'
-- Generators
@@ -446,10 +495,11 @@ generateSettings = do
arSupportsAtFile' = yesNo . arSupportsAtFile . tgtAr
arSupportsDashL' = yesNo . arSupportsDashL . tgtAr
ranlibPath = maybe "" (prgPath . ranlibProgram) . tgtRanlib
- isBigEndian = yesNo . (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness
- wordSize = show . wordSize2Bytes . tgtWordSize
mergeObjsSupportsResponseFiles' = maybe "NO" (yesNo . mergeObjsSupportsResponseFiles) . tgtMergeObjs
+isBigEndian, wordSize :: Toolchain.Target -> String
+isBigEndian = yesNo . (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness
+wordSize = show . wordSize2Bytes . tgtWordSize
-- | Generate @Config.hs@ files.
generateConfigHs :: Expr String
=====================================
mk/project.mk.in
=====================================
@@ -1,5 +1,5 @@
# WARNING: mk/project.mk is automatically generated from mk/project.mk.in by
-# ./configure. Make sure you are editing mk/project.mk.in, not mk/project.mk.
+# Hadrian. Make sure you are editing mk/project.mk.in, not mk/project.mk.
################################################################################
#
@@ -25,8 +25,7 @@
# random .o-file stuff might change even if the .hi syntax doesn't
ProjectName = @ProjectName@
-ProjectTags =
-ProjectVersion = @ProjectVersion@$(ProjectTags)
+ProjectVersion = @ProjectVersion@
ProjectVersionInt = @ProjectVersionInt@
ProjectPatchLevel = @ProjectPatchLevel@
ProjectPatchLevel1 = @ProjectPatchLevel1@
@@ -81,55 +80,19 @@ ProjectGitCommitId = @ProjectGitCommitId@
# You have to do a lot of work by hand to cross compile: see the
# section on "Porting GHC" in the Building Guide.
-HOSTPLATFORM = @HostPlatform@
TARGETPLATFORM = @TargetPlatform@
-BUILDPLATFORM = @BuildPlatform@
-
-HostPlatform_CPP = @HostPlatform_CPP@
-HostArch_CPP = @HostArch_CPP@
-HostOS_CPP = @HostOS_CPP@
-HostVendor_CPP = @HostVendor_CPP@
TargetPlatform_CPP = @TargetPlatform_CPP@
TargetArch_CPP = @TargetArch_CPP@
TargetOS_CPP = @TargetOS_CPP@
-TargetVendor_CPP = @TargetVendor_CPP@
LLVMTarget_CPP = @LLVMTarget_CPP@
-BuildPlatform_CPP = @BuildPlatform_CPP@
-BuildArch_CPP = @BuildArch_CPP@
-BuildOS_CPP = @BuildOS_CPP@
-BuildVendor_CPP = @BuildVendor_CPP@
-
- at HostPlatform_CPP@_HOST = 1
- at TargetPlatform_CPP@_TARGET = 1
- at BuildPlatform_CPP@_BUILD = 1
-
- at HostArch_CPP@_HOST_ARCH = 1
- at TargetArch_CPP@_TARGET_ARCH = 1
- at BuildArch_CPP@_BUILD_ARCH = 1
-
- at HostOS_CPP@_HOST_OS = 1
- at TargetOS_CPP@_TARGET_OS = 1
- at BuildOS_CPP@_BUILD_OS = 1
-
- at HostVendor_CPP@_HOST_VENDOR = 1
- at TargetVendor_CPP@_TARGET_VENDOR = 1
- at BuildVendor_CPP@_BUILD_VENDOR = 1
-
################################################################################
#
# Global configuration options
#
################################################################################
-# Pin a suffix on executables? If so, what (Windows only).
-exeext0=@exeext_host@
-exeext1=@exeext_target@
-exeext2=@exeext_target@
-exeext3=@exeext_target@
-soext=@soext_target@
-
# Windows_Host=YES if on a Windows platform
ifneq "$(findstring $(HostOS_CPP), mingw32)" ""
Windows_Host=YES
@@ -143,17 +106,3 @@ Darwin_Host=YES
else
Darwin_Host=NO
endif
-
-# Windows_Target=YES if we are targeting a Windows platform
-ifneq "$(findstring $(TargetOS_CPP), mingw32)" ""
-Windows_Target=YES
-else
-Windows_Target=NO
-endif
-
-# Is the stage0 compiler affected by Bug #9439?
-GHC_LLVM_AFFECTED_BY_9439 = @GHC_LLVM_AFFECTED_BY_9439@
-
-ifeq "$(TargetArch_CPP)" "arm"
-ARM_ISA=@ARM_ISA@
-endif
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e65aaabfe0e9f53c95ec4880fc81fedeb857ecf4
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e65aaabfe0e9f53c95ec4880fc81fedeb857ecf4
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/20240209/5933e679/attachment-0001.html>
More information about the ghc-commits
mailing list