Commit d014ab0d authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

Remove dynamic-by-default (#16782)

Dynamic-by-default was a mechanism to automatically select the -dynamic
way for some targets.

It was implemented in a convoluted way: it was defined as a flavour
option, hence it couldn't be passed as a global settings (which are
produced by `configure` before considering flavours), so a build system
rule was used to pass -DDYNAMIC_BY_DEFAULT to the C compiler so that
deriveConstants could infer it.

* Make build system has it disabled for 8 years (951e28c0)
* It has never been implemented in Hadrian
* Last time someone tried to enable it 1 year ago it didn't work (!2436)
* Having this as a global constant impedes making GHC multi-target (see !5427)

This commit fully removes support for dynamic-by-default. If someone
wants to reimplement something like this, it would probably need to move
the logic in the compiler.

(Doing this would probably need some refactoring of the way the compiler
handles DynFlags: DynFlags are used to store and to pass enabled ways to
many parts of the compiler. It can be set by command-line flags, GHC
API, global settings. In multi-target GHC, we will use DynFlags to load
the target platform and its constants: but at this point with the
current DynFlags implementation we can't easily update the existing
DynFlags with target-specific options such as dynamic-by-default without
overriding ways previously set by the user.)
parent 546f8b14
Pipeline #34109 failed with stages
in 8 minutes and 2 seconds
......@@ -148,7 +148,6 @@ module GHC.Driver.Session (
-- ** Manipulating DynFlags
addPluginModuleName,
defaultDynFlags, -- Settings -> DynFlags
defaultWays,
initDynFlags, -- DynFlags -> IO DynFlags
defaultFatalMessager,
defaultFlushOut,
......@@ -1173,7 +1172,7 @@ defaultDynFlags mySettings llvmConfig =
ignorePackageFlags = [],
trustFlags = [],
packageEnv = Nothing,
targetWays_ = defaultWays mySettings,
targetWays_ = Set.empty,
splitInfo = Nothing,
ghcNameVersion = sGhcNameVersion mySettings,
......@@ -1255,12 +1254,6 @@ defaultDynFlags mySettings llvmConfig =
cfgWeights = defaultWeights
}
defaultWays :: Settings -> Ways
defaultWays settings = if pc_DYNAMIC_BY_DEFAULT (sPlatformConstants settings)
then Set.singleton WayDyn
else Set.empty
type FatalMessager = String -> IO ()
defaultFatalMessager :: FatalMessager
......@@ -3652,7 +3645,6 @@ defaultFlags settings
++ default_RPath platform
++ concatMap (wayGeneralFlags platform) (defaultWays settings)
++ validHoleFitDefaults
where platform = sTargetPlatform settings
......@@ -4677,8 +4669,6 @@ compilerInfo dflags
("Uses package keys", "YES"),
-- Whether or not we support the @-this-unit-id@ flag
("Uses unit IDs", "YES"),
-- Whether or not GHC compiles libraries as dynamic by default
("Dynamic by default", showBool $ pc_DYNAMIC_BY_DEFAULT constants),
-- Whether or not GHC was compiled using -dynamic
("GHC Dynamic", showBool hostIsDynamic),
-- Whether or not GHC was compiled using -prof
......@@ -4692,7 +4682,6 @@ compilerInfo dflags
showBool True = "YES"
showBool False = "NO"
platform = targetPlatform dflags
constants = platformConstants platform
isWindows = platformOS platform == OSMinGW32
expandDirectories :: FilePath -> Maybe FilePath -> String -> String
expandDirectories topd mtoold = expandToolDir mtoold . expandTopDir topd
......
......@@ -28,7 +28,6 @@ data TestSetting = TestHostOS
| TestGhcWithInterpreter
| TestGhcUnregisterised
| TestGhcWithSMP
| TestGhcDynamicByDefault
| TestGhcDynamic
| TestGhcProfiled
| TestAR
......@@ -57,7 +56,6 @@ testSetting key = do
TestGhcWithInterpreter -> "GhcWithInterpreter"
TestGhcUnregisterised -> "GhcUnregisterised"
TestGhcWithSMP -> "GhcWithSMP"
TestGhcDynamicByDefault -> "GhcDynamicByDefault"
TestGhcDynamic -> "GhcDynamic"
TestGhcProfiled -> "GhcProfiled"
TestAR -> "AR"
......
......@@ -11,7 +11,6 @@ deriveConstantsPairs =
, ("platformConstants", "--gen-haskell-value")
]
-- TODO: do we need to support `includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT`?
deriveConstantsBuilderArgs :: Args
deriveConstantsBuilderArgs = builder DeriveConstants ? do
cFlags <- includeCcArgs
......
......@@ -63,7 +63,6 @@ runTestBuilderArgs = builder RunTest ? do
let hasRtsWay w = elem w rtsWays
hasLibWay w = elem w libWays
hasDynamic <- getBooleanSetting TestGhcDynamic
hasDynamicByDefault <- getBooleanSetting TestGhcDynamicByDefault
withNativeCodeGen <- getBooleanSetting TestGhcWithNativeCodeGen
withInterpreter <- getBooleanSetting TestGhcWithInterpreter
unregisterised <- getBooleanSetting TestGhcUnregisterised
......@@ -127,7 +126,6 @@ runTestBuilderArgs = builder RunTest ? do
, arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck)
, arg "-e", arg $ asBool "ghc_with_smp=" withSMP
, arg "-e", arg $ "config.ghc_dynamic_by_default=" ++ show hasDynamicByDefault
, arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic
, arg "-e", arg $ "config.wordsize=" ++ show wordsize
......
......@@ -62,10 +62,6 @@ ifneq "$(GhcWithSMP)" "YES"
includes_CC_OPTS += -DNOSMP
endif
ifeq "$(DYNAMIC_BY_DEFAULT)" "YES"
includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT
endif
define includesHeaderVersion
# $1 = stage
$$(includes_$1_H_VERSION) : mk/project.mk | $$$$(dir $$$$@)/.
......
......@@ -124,26 +124,6 @@ endif
PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
$(NoSharedLibsPlatformList)),NO,YES)
# DYNAMIC_BY_DEFAULT says whether this compiler will default to
# building dynamic executables, i.e. -dynamic is on. We do this for
# most platforms because it lets us use the system dynamic linker
# instead of our own linker for GHCi.
#
# Currently this isn't possible on Windows, and we have not yet enabled
# it on i386 while we consider the performance implications.
#
ifeq "$(TargetOS_CPP)" "mingw32"
DYNAMIC_BY_DEFAULT = NO
else ifeq "$(TargetArch_CPP)" "i386"
DYNAMIC_BY_DEFAULT = NO
else
DYNAMIC_BY_DEFAULT = YES
endif
# For now, we unconditionally disable dynamic-by-default, as the
# cabal-install's that are in the wild don't handle it properly.
DYNAMIC_BY_DEFAULT = NO
# If building both v and dyn ways, then use -dynamic-too to build them.
# This makes the build faster.
DYNAMIC_TOO = YES
......
......@@ -12,5 +12,4 @@ WITH_TERMINFO = NO
BIGNUM_BACKEND = native
Stage1Only = YES
DYNAMIC_BY_DEFAULT = NO
DYNAMIC_GHC_PROGRAMS = NO
......@@ -12,5 +12,4 @@ WITH_TERMINFO = NO
BIGNUM_BACKEND = native
Stage1Only = YES
DYNAMIC_BY_DEFAULT = NO
DYNAMIC_GHC_PROGRAMS = NO
......@@ -11,5 +11,4 @@ WITH_TERMINFO = NO
BIGNUM_BACKEND = native
Stage1Only = YES
DYNAMIC_BY_DEFAULT = NO
DYNAMIC_GHC_PROGRAMS = NO
......@@ -11,5 +11,4 @@ WITH_TERMINFO = NO
BIGNUM_BACKEND = native
Stage1Only = YES
DYNAMIC_BY_DEFAULT = NO
DYNAMIC_GHC_PROGRAMS = NO
......@@ -12,5 +12,4 @@ WITH_TERMINFO = NO
BIGNUM_BACKEND = native
Stage1Only = YES
DYNAMIC_BY_DEFAULT = NO
DYNAMIC_GHC_PROGRAMS = NO
......@@ -12,5 +12,4 @@ WITH_TERMINFO = NO
BIGNUM_BACKEND = native
Stage1Only = YES
DYNAMIC_BY_DEFAULT = NO
DYNAMIC_GHC_PROGRAMS = NO
......@@ -55,11 +55,8 @@ if ghc_with_threaded_rts:
if ghc_with_dynamic_rts:
config.have_shared_libs = True
if config.ghc_dynamic_by_default and config.have_vanilla == 1:
config.run_ways.append('static')
else:
if ghc_with_dynamic_rts:
config.run_ways.append('dyn')
if ghc_with_dynamic_rts:
config.run_ways.append('dyn')
if (config.have_profiling and ghc_with_threaded_rts):
config.run_ways.append('profthreaded')
......
......@@ -24,7 +24,6 @@ main = do
getGhcFieldOrFail fields "GhcWithSMP" "Support SMP"
getGhcFieldOrFail fields "GhcRTSWays" "RTS ways"
getGhcFieldOrFail fields "GhcLeadingUnderscore" "Leading underscore"
getGhcFieldOrDefault fields "GhcDynamicByDefault" "Dynamic by default" "NO"
getGhcFieldOrDefault fields "GhcDynamic" "GHC Dynamic" "NO"
getGhcFieldOrDefault fields "GhcProfiled" "GHC Profiled" "NO"
getGhcFieldProgWithDefault fields "AR" "ar command" "ar"
......
......@@ -172,13 +172,7 @@ else
RUNTEST_OPTS += -e config.have_fast_bignum=True
endif
ifeq "$(GhcDynamicByDefault)" "YES"
RUNTEST_OPTS += -e config.ghc_dynamic_by_default=True
CABAL_MINIMAL_BUILD = --enable-shared --disable-library-vanilla
else
RUNTEST_OPTS += -e config.ghc_dynamic_by_default=False
CABAL_MINIMAL_BUILD = --enable-library-vanilla --disable-shared
endif
ifeq "$(GhcDynamic)" "YES"
RUNTEST_OPTS += -e config.ghc_dynamic=True
......
......@@ -18,17 +18,13 @@ include $(TOP)/mk/test.mk
LOCAL_PKGCONF=local.package.conf
LOCAL_GHC_PKG = '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF)
ifeq "$(GhcDynamicByDefault)" "YES"
RM_PROG006_EXTRA_FLAGS = -hisuf dyn_hi -osuf dyn_o
endif
rn.prog006:
rm -f A.hi A.o B/C.hi B/C.o Main.hi Main.o
rm -f A.dyn_hi A.dyn_o B/C.dyn_hi B/C.dyn_o Main.dyn_hi Main.dyn_o
rm -f pkg.conf
rm -f pwd pwd.exe pwd.exe.manifest pwd.hi pwd.o
'$(TEST_HC)' $(TEST_HC_OPTS) --make pwd -v0
'$(TEST_HC)' $(TEST_HC_OPTS) --make -this-unit-id test-1.0-XXX B.C -fforce-recomp -v0 $(RM_PROG006_EXTRA_FLAGS)
'$(TEST_HC)' $(TEST_HC_OPTS) --make -this-unit-id test-1.0-XXX B.C -fforce-recomp -v0
rm -f pkg.conf
echo "name: test" >>pkg.conf
echo "version: 1.0" >>pkg.conf
......
......@@ -8,11 +8,7 @@ cleanPackageDatabase.%:
HERE := $(abspath .)
$(eval $(call canonicalise,HERE))
ifeq "$(GhcDynamicByDefault)" "YES"
HI_SUF = dyn_hi
else
HI_SUF = hi
endif
mkPackageDatabase.%:
$(MAKE) -s --no-print-directory cleanPackageDatabase.$*
......
......@@ -159,8 +159,8 @@ constantWord w name expr = [(w, GetWord name (Fst (CExpr expr)))]
constantNatural :: Where -> Name -> String -> Wanteds
constantNatural w name expr = [(w, GetNatural name (Fst (CExpr expr)))]
constantBool :: Where -> Name -> String -> Wanteds
constantBool w name expr = [(w, GetBool name (Fst (CPPExpr expr)))]
-- constantBool :: Where -> Name -> String -> Wanteds
-- constantBool w name expr = [(w, GetBool name (Fst (CPPExpr expr)))]
fieldOffset :: Where -> String -> String -> Wanteds
fieldOffset w theType theField = fieldOffset_ w nameBase theType theField
......@@ -661,8 +661,6 @@ wanteds os = concat
-- Amount of pointer bits used for semi-tagging constructor closures
,constantWord Haskell "TAG_BITS" "TAG_BITS"
,constantBool Haskell "DYNAMIC_BY_DEFAULT" "defined(DYNAMIC_BY_DEFAULT)"
,constantWord Haskell "LDV_SHIFT" "LDV_SHIFT"
,constantNatural Haskell "ILDV_CREATE_MASK" "LDV_CREATE_MASK"
,constantNatural Haskell "ILDV_STATE_CREATE" "LDV_STATE_CREATE"
......
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