summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2013-03-13 21:29:27 +0000
committerIan Lynagh <ian@well-typed.com>2013-03-15 00:49:49 +0000
commitb7126674a5f4ead9c73a6a2cbe0fbc85f7d36c12 (patch)
tree767f78388d2e73d317a64d1c106402de6f9014ed
parent5319ea79fa1572b7d411548532031f9d19b928c6 (diff)
downloadhaskell-b7126674a5f4ead9c73a6a2cbe0fbc85f7d36c12.tar.gz
By default, use the dynamic way for programs in the GHC tree
In particular, this means that GHCi will use DLLs, rather than loading object files itself.
-rw-r--r--compiler/ghc.mk10
-rw-r--r--compiler/ghci/Linker.lhs28
-rw-r--r--compiler/main/DynFlags.hs2
-rw-r--r--compiler/utils/Util.lhs9
-rw-r--r--ghc.mk12
-rw-r--r--mk/build.mk.sample2
-rw-r--r--mk/config.mk.in9
-rw-r--r--mk/validate-settings.mk4
-rw-r--r--rts/Linker.c14
-rw-r--r--rts/ghc.mk4
-rw-r--r--rules/build-package-data.mk2
-rw-r--r--rules/build-package-way.mk2
-rw-r--r--rules/build-prog.mk4
-rw-r--r--rules/shell-wrapper.mk4
14 files changed, 56 insertions, 50 deletions
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 0c68d6d45e..54d828be1a 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -111,6 +111,12 @@ ifeq "$(UseLibFFIForAdjustors)" "YES"
else
@echo 'cLibFFI = False' >> $@
endif
+ @echo 'cDYNAMIC_GHC_PROGRAMS :: Bool' >> $@
+ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
+ @echo 'cDYNAMIC_GHC_PROGRAMS = True' >> $@
+else
+ @echo 'cDYNAMIC_GHC_PROGRAMS = False' >> $@
+endif
@echo done.
# -----------------------------------------------------------------------------
@@ -483,6 +489,10 @@ $(foreach way,$(compiler_stage3_WAYS),\
# switch off the recompilation checker for that module:
compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
+ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
+compiler/utils/Util_HC_OPTS += -DDYNAMIC_GHC_PROGRAMS
+endif
+
# LibFFI.hs #includes ffi.h
ifneq "$(UseSystemLibFFI)" "YES"
compiler/stage2/build/LibFFI.hs : $(libffi_HEADERS)
diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs
index 151c5cbcc3..3d568ead90 100644
--- a/compiler/ghci/Linker.lhs
+++ b/compiler/ghci/Linker.lhs
@@ -414,14 +414,14 @@ preloadLib dflags lib_paths framework_paths lib_spec
preload_static _paths name
= do b <- doesFileExist name
if not b then return False
- else do if dYNAMIC_BY_DEFAULT dflags
+ else do if cDYNAMIC_GHC_PROGRAMS
then dynLoadObjs dflags [name]
else loadObj name
return True
preload_static_archive _paths name
= do b <- doesFileExist name
if not b then return False
- else do if dYNAMIC_BY_DEFAULT dflags
+ else do if cDYNAMIC_GHC_PROGRAMS
then panic "Loading archives not supported"
else loadArchive name
return True
@@ -485,9 +485,8 @@ dieWith dflags span msg = throwGhcExceptionIO (ProgramError (showSDoc dflags (mk
checkNonStdWay :: DynFlags -> SrcSpan -> IO Bool
checkNonStdWay dflags srcspan = do
let tag = buildTag dflags
- dynamicByDefault = dYNAMIC_BY_DEFAULT dflags
- if (null tag && not dynamicByDefault) ||
- (tag == "dyn" && dynamicByDefault)
+ if (null tag && not cDYNAMIC_GHC_PROGRAMS) ||
+ (tag == "dyn" && cDYNAMIC_GHC_PROGRAMS)
then return False
-- see #3604: object files compiled for way "dyn" need to link to the
-- dynamic packages, so we can't load them into a statically-linked GHCi.
@@ -638,10 +637,9 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods
let file_base = reverse (drop (length osuf + 1) (reverse file))
dyn_file = file_base <.> "dyn_o"
new_file = file_base <.> normalObjectSuffix
- -- Note that even if dYNAMIC_BY_DEFAULT is on, we might
- -- still have dynamic object files called .o, so we need
- -- to try both filenames.
- use_dyn <- if dYNAMIC_BY_DEFAULT dflags
+ -- When looking for dynamic object files, we try both
+ -- .dyn_o and .o, with a preference for the former.
+ use_dyn <- if cDYNAMIC_GHC_PROGRAMS
then do doesFileExist dyn_file
else return False
if use_dyn
@@ -790,7 +788,7 @@ dynLinkObjs dflags pls objs = do
unlinkeds = concatMap linkableUnlinked new_objs
wanted_objs = map nameOfObject unlinkeds
- if dYNAMIC_BY_DEFAULT dflags
+ if cDYNAMIC_GHC_PROGRAMS
then do dynLoadObjs dflags wanted_objs
return (pls, Succeeded)
else do mapM_ loadObj wanted_objs
@@ -1185,7 +1183,7 @@ locateLib dflags is_hs dirs lib
--
= findDll `orElse` findArchive `orElse` tryGcc `orElse` assumeDll
- | not isDynamicGhcLib
+ | not cDYNAMIC_GHC_PROGRAMS
-- When the GHC package was not compiled as dynamic library
-- (=DYNAMIC not set), we search for .o libraries or, if they
-- don't exist, .a libraries.
@@ -1194,13 +1192,11 @@ locateLib dflags is_hs dirs lib
| otherwise
-- When the GHC package was compiled as dynamic library (=DYNAMIC set),
-- we search for .so libraries first.
- = findHSDll `orElse` findDynObject `orElse` findDynArchive `orElse`
- findObject `orElse` findArchive `orElse` assumeDll
+ = findHSDll `orElse` findDynObject `orElse` assumeDll
where
mk_obj_path dir = dir </> (lib <.> "o")
mk_dyn_obj_path dir = dir </> (lib <.> "dyn_o")
mk_arch_path dir = dir </> ("lib" ++ lib <.> "a")
- mk_dyn_arch_path dir = dir </> ("lib" ++ lib <.> "dyn_a")
hs_dyn_lib_name = lib ++ "-ghc" ++ cProjectVersion
mk_hs_dyn_lib_path dir = dir </> mkSOName platform hs_dyn_lib_name
@@ -1209,10 +1205,8 @@ locateLib dflags is_hs dirs lib
mk_dyn_lib_path dir = dir </> so_name
findObject = liftM (fmap Object) $ findFile mk_obj_path dirs
- findDynObject = do putStrLn "In findDynObject"
- liftM (fmap Object) $ findFile mk_dyn_obj_path dirs
+ findDynObject = liftM (fmap Object) $ findFile mk_dyn_obj_path dirs
findArchive = liftM (fmap Archive) $ findFile mk_arch_path dirs
- findDynArchive = liftM (fmap Archive) $ findFile mk_dyn_arch_path dirs
findHSDll = liftM (fmap DLLPath) $ findFile mk_hs_dyn_lib_path dirs
findDll = liftM (fmap DLLPath) $ findFile mk_dyn_lib_path dirs
tryGcc = liftM (fmap DLLPath) $ searchForLibUsingGcc dflags so_name dirs
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 162568ca4e..876d2ea759 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -3344,6 +3344,8 @@ compilerInfo dflags
("RTS ways", cGhcRTSWays),
("Dynamic by default", if dYNAMIC_BY_DEFAULT dflags
then "YES" else "NO"),
+ ("GHC Dynamic", if cDYNAMIC_GHC_PROGRAMS
+ then "YES" else "NO"),
("Leading underscore", cLeadingUnderscore),
("Debug on", show debugIsOn),
("LibDir", topDir dflags),
diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs
index f9927de2f0..90a2077c71 100644
--- a/compiler/utils/Util.lhs
+++ b/compiler/utils/Util.lhs
@@ -9,7 +9,7 @@
module Util (
-- * Flags dependent on the compiler build
ghciSupported, debugIsOn, ncgDebugIsOn,
- ghciTablesNextToCode, isDynamicGhcLib,
+ ghciTablesNextToCode,
isWindowsHost, isDarwinHost,
-- * General list processing
@@ -179,13 +179,6 @@ ghciTablesNextToCode = True
ghciTablesNextToCode = False
#endif
-isDynamicGhcLib :: Bool
-#ifdef DYNAMIC
-isDynamicGhcLib = True
-#else
-isDynamicGhcLib = False
-#endif
-
isWindowsHost :: Bool
#ifdef mingw32_HOST_OS
isWindowsHost = True
diff --git a/ghc.mk b/ghc.mk
index 6d0b379edf..5843d81802 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -128,13 +128,13 @@ include mk/ways.mk
include mk/custom-settings.mk
ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
-ifeq "$(DYNAMIC_BY_DEFAULT)" "YES"
+ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
ifeq "$(findstring dyn,$(GhcLibWays))" ""
-$(error dyn is not in $$(GhcLibWays), but $$(DYNAMIC_BY_DEFAULT) is YES)
+$(error dyn is not in $$(GhcLibWays), but $$(DYNAMIC_GHC_PROGRAMS) is YES)
endif
else
ifeq "$(findstring v,$(GhcLibWays))" ""
-$(error v is not in $$(GhcLibWays), and $$(DYNAMIC_BY_DEFAULT) is not YES)
+$(error v is not in $$(GhcLibWays), and $$(DYNAMIC_GHC_PROGRAMS) is not YES)
endif
endif
ifeq "$(GhcProfiled)" "YES"
@@ -196,7 +196,7 @@ include rules/way-prelims.mk
$(foreach way,$(ALL_WAYS),\
$(eval $(call way-prelims,$(way))))
-ifeq "$(DYNAMIC_BY_DEFAULT)" "YES"
+ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
GHCI_WAY = dyn
HADDOCK_WAY = dyn
else
@@ -438,7 +438,7 @@ SUPERSIZE_INSTALL_PACKAGES += $(addprefix libraries/,$(PACKAGES_STAGE2))
INSTALL_DYNLIBS :=
ifeq "$(InstallExtraPackages)" "NO"
INSTALL_PACKAGES := $(REGULAR_INSTALL_PACKAGES)
-ifeq "$(DYNAMIC_BY_DEFAULT)" "YES"
+ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
INSTALL_DYNLIBS := $(REGULAR_INSTALL_DYNLIBS)
endif
else
@@ -1260,7 +1260,7 @@ bootstrapping-files: $(libffi_HEADERS)
ifeq "$(HADDOCK_DOCS)" "YES"
BINDIST_HADDOCK_FLAG = --with-haddock="$(BINDIST_PREFIX)/bin/haddock"
endif
-ifeq "$(DYNAMIC_BY_DEFAULT)" "YES"
+ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
BINDIST_LIBRARY_FLAGS = --enable-shared --disable-library-vanilla
else
BINDIST_LIBRARY_FLAGS = --enable-library-vanilla --disable-shared
diff --git a/mk/build.mk.sample b/mk/build.mk.sample
index e055b49301..338eefb573 100644
--- a/mk/build.mk.sample
+++ b/mk/build.mk.sample
@@ -33,7 +33,7 @@
# A development build, working on the stage 2 compiler:
#BuildFlavour = devel2
-GhcLibWays = $(if $(filter $(DYNAMIC_BY_DEFAULT),YES),dyn,v)
+GhcLibWays = $(if $(filter $(DYNAMIC_GHC_PROGRAMS),YES),dyn,v)
# Uncomment this to get prettier build output.
# Please use V = 1 when reporting GHC bugs.
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 7409e40fe8..a69541a6e5 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -124,8 +124,15 @@ endif
# 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
+# Use the dynamic way when building programs in the GHC tree. In
+# particular, this means that GHCi will use DLLs rather than loading
+# object files directly.
+DYNAMIC_GHC_PROGRAMS = YES
+
# Build a compiler that will build *unregisterised* libraries and
# binaries by default. Unregisterised code is supposed to compile and
# run without any support for architecture-specific assembly mangling,
@@ -168,7 +175,7 @@ ArchSupportsGHCi=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(Targe
ifeq "$(OsSupportsGHCi)$(ArchSupportsGHCi)" "YESYES"
GhcWithInterpreter=YES
else
-GhcWithInterpreter=$(if $(findstring YES,$(DYNAMIC_BY_DEFAULT)),YES,NO)
+GhcWithInterpreter=$(if $(findstring YES,$(DYNAMIC_GHC_PROGRAMS)),YES,NO)
endif
# GhcEnableTablesNextToCode tells us whether the target architecture
diff --git a/mk/validate-settings.mk b/mk/validate-settings.mk
index e2f66f2b68..f6370e9e4c 100644
--- a/mk/validate-settings.mk
+++ b/mk/validate-settings.mk
@@ -37,8 +37,8 @@ GhcStage2HcOpts += -O -dcore-lint
GhcLibHcOpts += -O -dcore-lint
# We define DefaultFastGhcLibWays in this style so that the value is
-# correct even if the user alters DYNAMIC_BY_DEFAULT
-DefaultFastGhcLibWays = $(if $(filter $(DYNAMIC_BY_DEFAULT),YES),dyn,v)
+# correct even if the user alters DYNAMIC_GHC_PROGRAMS
+DefaultFastGhcLibWays = $(if $(filter $(DYNAMIC_GHC_PROGRAMS),YES),dyn,v)
DefaultProfGhcLibWays = $(if $(filter $(GhcProfiled),YES),p,)
ifeq "$(ValidateSpeed)" "FAST"
diff --git a/rts/Linker.c b/rts/Linker.c
index cf4f350af1..db27c3f300 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -141,10 +141,10 @@
// warnings like
// error: function might be possible candidate for attribute ‘noreturn’
// from gcc:
-#ifdef DYNAMIC_BY_DEFAULT
-int dynamicByDefault = 1;
+#ifdef DYNAMIC_GHC_PROGRAMS
+int dynamicGhcPrograms = 1;
#else
-int dynamicByDefault = 0;
+int dynamicGhcPrograms = 0;
#endif
/* Hash table mapping symbol names to Symbol */
@@ -2116,8 +2116,8 @@ loadArchive( pathchar *path )
IF_DEBUG(linker, debugBelch("loadArchive: start\n"));
IF_DEBUG(linker, debugBelch("loadArchive: Loading archive `%" PATH_FMT" '\n", path));
- if (dynamicByDefault) {
- barf("loadArchive called, but using dynlibs by default (%s)", path);
+ if (dynamicGhcPrograms) {
+ barf("loadArchive called, but using dynamic GHC (%s)", path);
}
gnuFileIndex = NULL;
@@ -2511,8 +2511,8 @@ loadObj( pathchar *path )
#endif
IF_DEBUG(linker, debugBelch("loadObj %" PATH_FMT "\n", path));
- if (dynamicByDefault) {
- barf("loadObj called, but using dynlibs by default (%s)", path);
+ if (dynamicGhcPrograms) {
+ barf("loadObj called, but using dynamic GHC (%s)", path);
}
initLinker();
diff --git a/rts/ghc.mk b/rts/ghc.mk
index 3dc3990dcc..09c2874209 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -329,8 +329,8 @@ rts/RtsUtils_CC_OPTS += -DTargetVendor=\"$(TargetVendor_CPP)\"
rts/RtsUtils_CC_OPTS += -DGhcUnregisterised=\"$(GhcUnregisterised)\"
rts/RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=\"$(GhcEnableTablesNextToCode)\"
-ifeq "$(DYNAMIC_BY_DEFAULT)" "YES"
-rts/Linker_CC_OPTS += -DDYNAMIC_BY_DEFAULT
+ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
+rts/Linker_CC_OPTS += -DDYNAMIC_GHC_PROGRAMS
endif
# Compile various performance-critical pieces *without* -fPIC -dynamic
diff --git a/rules/build-package-data.mk b/rules/build-package-data.mk
index bcd863fe62..cf67baf33c 100644
--- a/rules/build-package-data.mk
+++ b/rules/build-package-data.mk
@@ -22,7 +22,7 @@ $1_$2_CONFIGURE_OPTS += --disable-library-for-ghci
ifeq "$$(filter v,$$($1_$2_WAYS))" "v"
$1_$2_CONFIGURE_OPTS += --enable-library-vanilla
ifeq "$$(GhcWithInterpreter)" "YES"
-ifneq "$$(DYNAMIC_BY_DEFAULT)" "YES"
+ifneq "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
$1_$2_CONFIGURE_OPTS += --enable-library-for-ghci
endif
endif
diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk
index 8a0dc6409e..bae73e32d9 100644
--- a/rules/build-package-way.mk
+++ b/rules/build-package-way.mk
@@ -119,7 +119,7 @@ BINDIST_LIBS += $$($1_$2_$3_LIB0)
endif
# Build the GHCi library
-ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
+ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
$1_$2_GHCI_LIB = $$($1_$2_dyn_LIB)
else
ifeq "$3" "v"
diff --git a/rules/build-prog.mk b/rules/build-prog.mk
index 597315983d..81f2ef2ad9 100644
--- a/rules/build-prog.mk
+++ b/rules/build-prog.mk
@@ -64,7 +64,7 @@ else ifneq "$$($1_$2_INSTALL_INPLACE)" "YES"
$1_$2_WANT_INPLACE_WRAPPER = NO
else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
$1_$2_WANT_INPLACE_WRAPPER = YES
-else ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
+else ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
$1_$2_WANT_INPLACE_WRAPPER = YES
else
$1_$2_WANT_INPLACE_WRAPPER = NO
@@ -136,7 +136,7 @@ $(call shell-wrapper,$1,$2)
ifeq "$$($1_$2_PROGRAM_WAY)" ""
ifeq "$3" "0"
$1_$2_PROGRAM_WAY = v
-else ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
+else ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
$1_$2_PROGRAM_WAY = dyn
else
$1_$2_PROGRAM_WAY = v
diff --git a/rules/shell-wrapper.mk b/rules/shell-wrapper.mk
index 687c408348..4f6795d159 100644
--- a/rules/shell-wrapper.mk
+++ b/rules/shell-wrapper.mk
@@ -44,7 +44,7 @@ $$(INPLACE_WRAPPER): $$($1_$2_INPLACE)
echo 'pgmgcc="$$(WhatGccIsCalled)"' >> $$@
$$($1_$2_SHELL_WRAPPER_EXTRA)
$$($1_$2_INPLACE_SHELL_WRAPPER_EXTRA)
-ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
+ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
echo '$$(call prependLibraryPath,$$($1_$2_DEP_LIB_DIRS_SEARCHPATH))' >> $$@
endif
ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
@@ -99,7 +99,7 @@ BINDIST_EXTRAS += $$($1_$2_BINDIST_WRAPPER)
$$($1_$2_BINDIST_WRAPPER): $1/$2/build/tmp/$$($1_$2_PROG)
$$(call removeFiles, $$@)
echo '#!$$(SHELL)' >> $$@
-ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
+ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
echo '$$(call prependLibraryPath,$$($1_$2_DEP_LIB_REL_DIRS_SEARCHPATH))' >> $$@
endif
echo 'exec "$$<" $$$${1+"$$$$@"}' >> $$@