summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/ghc.mk2
-rw-r--r--compiler/main/DynFlags.hs14
-rw-r--r--configure.ac56
-rw-r--r--hadrian/cfg/system.config.in1
-rw-r--r--hadrian/src/Oracles/Flag.hs2
-rw-r--r--hadrian/src/Oracles/Setting.hs7
-rw-r--r--hadrian/src/Rules/Generate.hs4
-rw-r--r--hadrian/src/Settings/Packages.hs7
-rw-r--r--includes/ghc.mk4
-rw-r--r--libraries/ghc-boot/GHC/Platform.hs3
-rw-r--r--mk/config.mk.in12
-rw-r--r--rts/RtsUtils.c7
-rw-r--r--rts/ghc.mk2
13 files changed, 78 insertions, 43 deletions
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 629a1ed560..441b698972 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -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
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index ca53fda26d..fe7e3134ec 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -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
diff --git a/configure.ac b/configure.ac
index aa48872b4e..0524d140b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in
index 5bdb322551..2380baf9c0 100644
--- a/hadrian/cfg/system.config.in
+++ b/hadrian/cfg/system.config.in
@@ -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@
diff --git a/hadrian/src/Oracles/Flag.hs b/hadrian/src/Oracles/Flag.hs
index 4f5116bf41..075a1bfe23 100644
--- a/hadrian/src/Oracles/Flag.hs
+++ b/hadrian/src/Oracles/Flag.hs
@@ -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"
diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs
index 408f9e3422..51ccc729a3 100644
--- a/hadrian/src/Oracles/Setting.hs
+++ b/hadrian/src/Oracles/Setting.hs
@@ -1,7 +1,7 @@
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"]
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index 18e6f9271c..8ad8ead4c7 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -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
diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs
index ecffc58c9d..01c170b68e 100644
--- a/hadrian/src/Settings/Packages.hs
+++ b/hadrian/src/Settings/Packages.hs
@@ -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.
diff --git a/includes/ghc.mk b/includes/ghc.mk
index 7ad63ba8ef..ad51234143 100644
--- a/includes/ghc.mk
+++ b/includes/ghc.mk
@@ -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
diff --git a/libraries/ghc-boot/GHC/Platform.hs b/libraries/ghc-boot/GHC/Platform.hs
index ea1aa5e323..7eec31a9fe 100644
--- a/libraries/ghc-boot/GHC/Platform.hs
+++ b/libraries/ghc-boot/GHC/Platform.hs
@@ -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
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 10326d0c25..ca17e8689b 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -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@
diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c
index b099fa2dad..2a53d18572 100644
--- a/rts/RtsUtils.c
+++ b/rts/RtsUtils.c
@@ -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");
diff --git a/rts/ghc.mk b/rts/ghc.mk
index ae4dcd840c..d913a9c695 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -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