Commit 81860281 authored by Joachim Breitner's avatar Joachim Breitner Committed by Marge Bot

Consolidate `TablesNextToCode` and `GhcUnreigsterised` in configure (#15548)

`TablesNextToCode` is now a substituted by configure, where it has the
correct defaults and error handling. Nowhere else needs to duplicate
that, though we may want the compiler to to guard against bogus settings
files.

I renamed it from `GhcEnableTablesNextToCode` to `TablesNextToCode` to:

 - Help me guard against any unfixed usages

 - Remove any lingering connotation that this flag needs to be combined
   with `GhcUnreigsterised`.

Original reviewers:

Original subscribers: TerrorJack, rwbarton, carter

Original Differential Revision: https://phabricator.haskell.org/D5082
parent 83ca42de
Pipeline #9347 passed with stages
in 362 minutes and 55 seconds
......@@ -256,7 +256,7 @@ endif
ifeq "$(GhcWithInterpreter)" "YES"
compiler_stage2_CONFIGURE_OPTS += --flags=ghci
ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
ifeq "$(TablesNextToCode)" "YES"
# Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
# or not?
# XXX This should logically be a CPP option, but there doesn't seem to
......
......@@ -59,7 +59,6 @@ module DynFlags (
fFlags, fLangFlags, xFlags,
wWarningFlags,
dynFlagDependencies,
tablesNextToCode,
makeDynFlagsConsistent,
shouldUseColor,
shouldUseHexWordLiterals,
......@@ -159,6 +158,7 @@ module DynFlags (
opt_L, opt_P, opt_F, opt_c, opt_cxx, opt_a, opt_l, opt_i,
opt_P_signature,
opt_windres, opt_lo, opt_lc, opt_lcc,
tablesNextToCode,
-- ** Manipulating DynFlags
addPluginModuleName,
......@@ -1493,6 +1493,9 @@ opt_lc dflags= toolSettings_opt_lc $ toolSettings dflags
opt_i :: DynFlags -> [String]
opt_i dflags= toolSettings_opt_i $ toolSettings dflags
tablesNextToCode :: DynFlags -> Bool
tablesNextToCode = platformMisc_tablesNextToCode . platformMisc
-- | The directory for this version of ghc in the user's app directory
-- (typically something like @~/.ghc/x86_64-linux-7.6.3@)
--
......@@ -1664,15 +1667,6 @@ defaultObjectTarget dflags = defaultHscTarget
(targetPlatform dflags)
(platformMisc dflags)
-- Determines whether we will be compiling
-- info tables that reside just before the entry code, or with an
-- indirection to the entry code. See TABLES_NEXT_TO_CODE in
-- includes/rts/storage/InfoTables.h.
tablesNextToCode :: DynFlags -> Bool
tablesNextToCode dflags =
not (platformUnregisterised $ targetPlatform dflags) &&
platformMisc_tablesNextToCode (platformMisc dflags)
data DynLibLoader
= Deployable
| SystemDependent
......
......@@ -271,6 +271,55 @@ AC_ARG_ENABLE(unregisterised,
)
AC_SUBST(Unregisterised)
dnl ** Do a build with tables next to code?
dnl
dnl Whether the target architecture supports placing info tables
dnl directly before the entry code (see TABLES_NEXT_TO_CODE in the RTS).
dnl Whether we actually compile for TABLES_NEXT_TO_CODE depends on
dnl whether we're building unregisterised code or not, which may be
dnl decided by options to the compiler later.
dnl
dnl See https://gitlab.haskell.org/ghc/ghc/wikis/commentary/rts/storage/heap-objects#tables_next_to_code
dnl --------------------------------------------------------------
case "$Unregisterised" in
NO)
case "$TargetArch" in
ia64|powerpc64|powerpc64le)
TablesNextToCodeDefault=NO
;;
*)
TablesNextToCodeDefault=YES
;;
esac
;;
YES)
TablesNextToCodeDefault=NO
;;
esac
AC_ARG_ENABLE(tables-next-to-code,
[AC_HELP_STRING([--enable-tables-next-to-code],
[Build an tables-next-to-code compiler (enabled by default on platforms without registerised support) [default="$TablesNextToCodeDefault"]])],
[ if test x"$enableval" = x"yes"; then
TablesNextToCode=YES
else
TablesNextToCode=NO
fi
],
[TablesNextToCode="$TablesNextToCodeDefault"]
)
fail() {
echo >&2
echo "$1" >&2
exit 1
}
if test "$TablesNextToCodeDefault" = "NO" && test "$TablesNextToCode" = "YES"; then
fail "Error: tables next to code was requested but is not supported"
fi
AC_SUBST(TablesNextToCode)
dnl ** Does target have runtime linker support?
dnl --------------------------------------------------------------
case "$target" in
......@@ -286,12 +335,6 @@ AC_SUBST(HaskellHaveRTSLinker)
# Requires FPTOOLS_SET_PLATFORM_VARS to be run first.
FP_FIND_ROOT
fail() {
echo >&2
echo "$1" >&2
exit 1
}
if test "$HostOS" = "mingw32"
then
......@@ -1335,6 +1378,7 @@ echo "\
which is version : $GccVersion
Building a cross compiler : $CrossCompiling
Unregisterised : $Unregisterised
TablesNextToCode : $TablesNextToCode
hs-cpp : $HaskellCPPCmd
hs-cpp-flags : $HaskellCPPArgs
ar : $ArCmd
......
......@@ -43,6 +43,7 @@ hs-cpp-args = @HaskellCPPArgs@
solaris-broken-shld = @SOLARIS_BROKEN_SHLD@
ghc-unregisterised = @Unregisterised@
tables-next-to-code = @TablesNextToCode@
ghc-source-path = @hardtop@
leading-underscore = @LeadingUnderscore@
......
......@@ -13,6 +13,7 @@ data Flag = ArSupportsAtFile
| CrossCompiling
| GccIsClang
| GhcUnregisterised
| TablesNextToCode
| GmpInTree
| GmpFrameworkPref
| LeadingUnderscore
......@@ -30,6 +31,7 @@ flag f = do
CrossCompiling -> "cross-compiling"
GccIsClang -> "gcc-is-clang"
GhcUnregisterised -> "ghc-unregisterised"
TablesNextToCode -> "tables-next-to-code"
GmpInTree -> "intree-gmp"
GmpFrameworkPref -> "gmp-framework-preferred"
LeadingUnderscore -> "leading-underscore"
......
module Oracles.Setting (
configFile, Setting (..), SettingList (..), setting, settingList, getSetting,
getSettingList, anyTargetPlatform, anyTargetOs, anyTargetArch, anyHostOs,
ghcWithInterpreter, ghcEnableTablesNextToCode, useLibFFIForAdjustors,
ghcWithInterpreter, useLibFFIForAdjustors,
ghcCanonVersion, cmdLineLengthLimit, hostSupportsRPaths, topDirectory,
libsuf, ghcVersionStage, SettingsFileSetting (..), settingsFileSetting
) where
......@@ -225,11 +225,6 @@ ghcWithInterpreter = do
, "sparc64", "arm" ]
return $ goodOs && goodArch
-- | Check whether the target architecture supports placing info tables next to
-- code. See: https://gitlab.haskell.org/ghc/ghc/wikis/commentary/rts/storage/heap-objects#tables_next_to_code.
ghcEnableTablesNextToCode :: Action Bool
ghcEnableTablesNextToCode = notM $ anyTargetArch ["ia64", "powerpc64", "powerpc64le"]
-- | Check to use @libffi@ for adjustors.
useLibFFIForAdjustors :: Action Bool
useLibFFIForAdjustors = notM $ anyTargetArch ["i386", "x86_64"]
......
......@@ -313,7 +313,7 @@ generateSettings = do
, ("Use native code generator", expr $ yesNo <$> ghcWithNativeCodeGen)
, ("Support SMP", expr $ yesNo <$> ghcWithSMP)
, ("RTS ways", unwords . map show <$> getRtsWays)
, ("Tables next to code", expr $ yesNo <$> ghcEnableTablesNextToCode)
, ("Tables next to code", expr $ yesNo <$> flag TablesNextToCode)
, ("Leading underscore", expr $ yesNo <$> flag LeadingUnderscore)
, ("Use LibFFI", expr $ yesNo <$> useLibFFIForAdjustors)
, ("Use Threads", yesNo . any (wayUnit Threaded) <$> getRtsWays)
......@@ -373,7 +373,7 @@ generateGhcAutoconfH :: Expr String
generateGhcAutoconfH = do
trackGenerateHs
configHContents <- expr $ map undefinePackage <$> readFileLines configH
tablesNextToCode <- expr ghcEnableTablesNextToCode
tablesNextToCode <- getFlag TablesNextToCode
ghcUnreg <- getFlag GhcUnregisterised
ccLlvmBackend <- getSetting CcLlvmBackend
ccClangBackend <- getSetting CcClangBackend
......
......@@ -67,7 +67,7 @@ packageArgs = do
, (any (wayUnit Threaded) rtsWays) ?
notStage0 ? arg "--ghc-option=-optc-DTHREADED_RTS"
, ghcWithInterpreter ?
ghcEnableTablesNextToCode ?
flag TablesNextToCode ?
notM (flag GhcUnregisterised) ?
notStage0 ? arg "--ghc-option=-DGHCI_TABLES_NEXT_TO_CODE"
, ghcWithInterpreter ?
......@@ -196,7 +196,7 @@ rtsPackageArgs = package rts ? do
targetOs <- getSetting TargetOs
targetVendor <- getSetting TargetVendor
ghcUnreg <- expr $ yesNo <$> flag GhcUnregisterised
ghcEnableTNC <- expr $ yesNo <$> ghcEnableTablesNextToCode
ghcEnableTNC <- expr $ yesNo <$> flag TablesNextToCode
rtsWays <- getRtsWays
way <- getWay
path <- getBuildPath
......@@ -249,7 +249,8 @@ rtsPackageArgs = package rts ? do
, "-DTargetOS=" ++ show targetOs
, "-DTargetVendor=" ++ show targetVendor
, "-DGhcUnregisterised=" ++ show ghcUnreg
, "-DGhcEnableTablesNextToCode=" ++ show ghcEnableTNC ]
, "-DTablesNextToCode=" ++ show ghcEnableTNC
]
-- We're after pur performance here. So make sure fast math and
-- vectorization is enabled.
......
......@@ -102,7 +102,7 @@ $(includes_H_CONFIG) : mk/config.h mk/config.mk includes/ghc.mk | $$(dir $$@)/.
#
# Tack on some extra config information from the build system
#
ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
ifeq "$(TablesNextToCode)" "YES"
@echo >> $@
@echo "#define TABLES_NEXT_TO_CODE 1" >> $@
endif
......@@ -211,7 +211,7 @@ $(includes_SETTINGS) : includes/Makefile | $$(dir $$@)/.
@echo ',("Use native code generator", "$(GhcWithNativeCodeGen)")' >> $@
@echo ',("Support SMP", "$(GhcWithSMP)")' >> $@
@echo ',("RTS ways", "$(GhcRTSWays)")' >> $@
@echo ',("Tables next to code", "$(GhcEnableTablesNextToCode)")' >> $@
@echo ',("Tables next to code", "$(TablesNextToCode)")' >> $@
@echo ',("Leading underscore", "$(LeadingUnderscore)")' >> $@
@echo ',("Use LibFFI", "$(UseLibFFIForAdjustors)")' >> $@
# Note that GhcThreaded just reflects the Makefile variable setting. In
......
......@@ -269,6 +269,9 @@ data PlatformMisc = PlatformMisc
, platformMisc_ghcWithNativeCodeGen :: Bool
, platformMisc_ghcWithSMP :: Bool
, platformMisc_ghcRTSWays :: String
-- | Determines whether we will be compiling info tables that reside just
-- before the entry code, or with an indirection to the entry code. See
-- TABLES_NEXT_TO_CODE in includes/rts/storage/InfoTables.h.
, platformMisc_tablesNextToCode :: Bool
, platformMisc_leadingUnderscore :: Bool
, platformMisc_libFFI :: Bool
......
......@@ -211,17 +211,6 @@ else
GhcWithInterpreter=$(if $(findstring YES,$(DYNAMIC_GHC_PROGRAMS)),YES,NO)
endif
# GhcEnableTablesNextToCode tells us whether the target architecture
# supports placing info tables directly before the entry code
# (see TABLES_NEXT_TO_CODE in the RTS). Whether we actually compile for
# TABLES_NEXT_TO_CODE depends on whether we're building unregisterised
# code or not, which may be decided by options to the compiler later.
ifneq "$(findstring $(TargetArch_CPP)X, ia64X powerpc64X powerpc64leX)" ""
GhcEnableTablesNextToCode=NO
else
GhcEnableTablesNextToCode=YES
endif
# Whether to use libffi for adjustors (foreign import "wrapper") or
# not. If we have built-in support (rts/Adjustor.c) then we use that,
# otherwise we fall back on libffi, which is slightly slower.
......@@ -505,6 +494,7 @@ HaskellHaveIdentDirective = @HaskellHaveIdentDirective@
HaskellHaveSubsectionsViaSymbols = @HaskellHaveSubsectionsViaSymbols@
HaskellHaveRTSLinker = @HaskellHaveRTSLinker@
Unregisterised = @Unregisterised@
TablesNextToCode = @TablesNextToCode@
SettingsCCompilerCommand = @SettingsCCompilerCommand@
SettingsHaskellCPPCommand = @SettingsHaskellCPPCommand@
......
......@@ -304,8 +304,13 @@ void printRtsInfo(const RtsConfig rts_config) {
mkRtsInfoPair("Target OS", TargetOS);
mkRtsInfoPair("Target vendor", TargetVendor);
mkRtsInfoPair("Word size", TOSTRING(WORD_SIZE_IN_BITS));
// TODO(@Ericson2314) This is a joint property of the RTS and generated
// code. The compiler will soon be multi-target so it doesn't make sense to
// say the target is <ABI adj>, unless we are talking about the host
// platform of the compiler / ABI used by a compiler plugin. This is *not*
// that, so I think a rename is in order to avoid confusion.
mkRtsInfoPair("Compiler unregisterised", GhcUnregisterised);
mkRtsInfoPair("Tables next to code", GhcEnableTablesNextToCode);
mkRtsInfoPair("Tables next to code", TablesNextToCode);
mkRtsInfoPair("Flag -with-rtsopts", /* See #15261 */
rts_config.rts_opts != NULL ? rts_config.rts_opts : "");
printf(" ]\n");
......
......@@ -418,7 +418,7 @@ rts/RtsUtils_CC_OPTS += -DTargetOS=\"$(TargetOS_CPP)\"
rts/RtsUtils_CC_OPTS += -DTargetVendor=\"$(TargetVendor_CPP)\"
#
rts/RtsUtils_CC_OPTS += -DGhcUnregisterised=\"$(GhcUnregisterised)\"
rts/RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=\"$(GhcEnableTablesNextToCode)\"
rts/RtsUtils_CC_OPTS += -DTablesNextToCode=\"$(TablesNextToCode)\"
#
rts/xxhash_CC_OPTS += -O3 -ffast-math -ftree-vectorize
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment