Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/3fc453af215a236ebf8d9ecfbf6574035e6316e2

>---------------------------------------------------------------

commit 3fc453af215a236ebf8d9ecfbf6574035e6316e2
Author: Ian Lynagh <i...@well-typed.com>
Date:   Wed Dec 5 16:29:07 2012 +0000

    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.

>---------------------------------------------------------------

 compiler/ghc.cabal.in           |   10 ++--------
 compiler/ghc.mk                 |   20 ++++++++++++++------
 compiler/ghci/keepCAFsForGHCi.c |    5 ++---
 compiler/main/DynFlags.hs       |    4 ++--
 4 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in
index a9dd62b..3e7cd42 100644
--- a/compiler/ghc.cabal.in
+++ b/compiler/ghc.cabal.in
@@ -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
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 0e53ca5..24c11b8 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -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
diff --git a/compiler/ghci/keepCAFsForGHCi.c b/compiler/ghci/keepCAFsForGHCi.c
index 805088e..2348233 100644
--- a/compiler/ghci/keepCAFsForGHCi.c
+++ b/compiler/ghci/keepCAFsForGHCi.c
@@ -1,16 +1,15 @@
 #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
+
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 675b26e..a2d75e5 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -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__"]



_______________________________________________
Cvs-ghc mailing list
Cvs-ghc@haskell.org
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to