Commit 3fc453af authored by ian@well-typed.com's avatar ian@well-typed.com
Browse files

Don't define DYNAMIC when compiling the dyn way

We want to compile the sources only once, and to produce both vanilla
and dyn object files. This means that the sources can't differ for the
two ways.

This needed a bit of a kludge to get keepCAFsForGHCi included only in
the dynamic library.
parent 95d8658a
......@@ -20,11 +20,6 @@ Category: Development
Build-Type: Simple
Cabal-Version: >= 1.2.3
Flag dynlibs
Description: Dynamic library support
Default: False
Manual: True
Flag ghci
Description: Build GHCi support.
Default: False
......@@ -101,9 +96,8 @@ Library
c-sources:
parser/cutils.c
if flag(dynlibs)
c-sources:
ghci/keepCAFsForGHCi.c
c-sources:
ghci/keepCAFsForGHCi.c
hs-source-dirs:
basicTypes
......
......@@ -314,12 +314,6 @@ ifeq "$(BuildSharedLibs)" "YES"
# so we don't build it the dyn way; see trac #5987
ifneq "$(TargetOS_CPP)" "mingw32"
compiler_stage2_CONFIGURE_OPTS += --enable-shared
# If we are going to use dynamic libraries instead of .o files for ghci,
# we will need to always retain CAFs in the compiler.
# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
# function which sets the keepCAFs flag for the RTS before any Haskell
# code is run.
compiler_stage2_CONFIGURE_OPTS += --flags=dynlibs
endif
endif
......@@ -451,6 +445,20 @@ $(eval $(call build-package,compiler,stage1,0))
$(eval $(call build-package,compiler,stage2,1))
$(eval $(call build-package,compiler,stage3,2))
# We only want to turn keepCAFs on if we will be loading dynamic
# Haskell libraries with GHCi. We therefore filter the object file
# out for non-dynamic ways.
define keepCAFsForGHCiDynOnly
# $1 = stage
# $2 = way
ifeq "$$(findstring dyn, $1)" ""
compiler_stage$1_$2_C_OBJS := $$(filter-out %/keepCAFsForGHCi.o,$$(compiler_stage$1_$2_C_OBJS))
endif
endef
$(foreach w,$(compiler_stage1_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,1,$w)))
$(foreach w,$(compiler_stage2_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,2,$w)))
$(foreach w,$(compiler_stage3_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,3,$w)))
# after build-package, because that adds --enable-library-for-ghci
# to compiler_stage*_CONFIGURE_OPTS:
# We don't build the GHCi library for the ghc package. We can load it
......
#include "Rts.h"
// This file is only included when GhcBuildDylibs is set in mk/build.mk.
// This file is only included in the dynamic library.
// It contains an __attribute__((constructor)) function (run prior to main())
// which sets the keepCAFs flag in the RTS, before any Haskell code is run.
// This is required so that GHCi can use dynamic libraries instead of HSxyz.o
// files.
#ifdef DYNAMIC
static void keepCAFsForGHCi(void) __attribute__((constructor));
static void keepCAFsForGHCi(void)
{
keepCAFs = 1;
}
#endif
......@@ -1056,7 +1056,7 @@ wayOptc platform WayThreaded = case platformOS platform of
OSNetBSD -> ["-pthread"]
_ -> []
wayOptc _ WayDebug = ["-O0", "-g"]
wayOptc _ WayDyn = ["-DDYNAMIC"]
wayOptc _ WayDyn = []
wayOptc _ WayProf = ["-DPROFILING"]
wayOptc _ WayEventLog = ["-DTRACING"]
wayOptc _ WayPar = ["-DPAR", "-w"]
......@@ -1096,7 +1096,7 @@ wayOptl _ WayNDP = []
wayOptP :: Platform -> Way -> [String]
wayOptP _ WayThreaded = []
wayOptP _ WayDebug = []
wayOptP _ WayDyn = ["-DDYNAMIC"]
wayOptP _ WayDyn = []
wayOptP _ WayProf = ["-DPROFILING"]
wayOptP _ WayEventLog = ["-DTRACING"]
wayOptP _ WayPar = ["-D__PARALLEL_HASKELL__"]
......
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