[commit: ghc] master: Finish adding support for 2 DLLs in the ghc package; fixes #5987 (56353e3)

Ian Lynagh igloo at earth.li
Wed Mar 13 03:29:12 CET 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/56353e3da9d5718dfd25e25ccf61c78b25deefe8

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

commit 56353e3da9d5718dfd25e25ccf61c78b25deefe8
Author: Ian Lynagh <igloo at earth.li>
Date:   Tue Mar 12 22:12:38 2013 +0100

    Finish adding support for 2 DLLs in the ghc package; fixes #5987

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

 ghc.mk                     |  3 ---
 rules/build-package-way.mk | 20 +++++++++++++++++---
 utils/ghc-cabal/Main.hs    | 27 +++++++++++++++++++++++++--
 3 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/ghc.mk b/ghc.mk
index 864cc30..6d0b379 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -887,9 +887,6 @@ install_packages: rts/package.conf.install
 	$(call installLibsTo, $(RTS_INSTALL_LIBS), "$(DESTDIR)$(topdir)/rts-1.0")
 	$(foreach p, $(INSTALL_DYNLIBS), \
 	    $(call installLibsTo, $(wildcard libraries/$p/dist-install/build/*.so libraries/$p/dist-install/build/*.dll libraries/$p/dist-install/build/*.dylib), "$(DESTDIR)$(topdir)/$p-$(libraries/$p_dist-install_VERSION)"))
-ifneq "$(compiler_stage2_dyn_LIB0)" ""
-	$(call installLibsTo, $(compiler_stage2_dyn_LIB0), "$(DESTDIR)$(topdir)/ghc-$(compiler_stage2_VERSION)")
-endif
 	$(foreach p, $(INSTALL_PACKAGES),                             \
 	    $(call make-command,                                      \
 	           "$(ghc-cabal_INPLACE)" copy                        \
diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk
index c67e258..8a0dc64 100644
--- a/rules/build-package-way.mk
+++ b/rules/build-package-way.mk
@@ -27,7 +27,6 @@ $1_$2_$3_LIB_NAME = libHS$$($1_PACKAGE)-$$($1_$2_VERSION)$$($3_libsuf)
 $1_$2_$3_LIB = $1/$2/build/$$($1_$2_$3_LIB_NAME)
 $$($1_PACKAGE)-$$($1_$2_VERSION)_$2_$3_LIB = $$($1_$2_$3_LIB)
 
-ifeq "$3" "dyn"
 ifeq "$$(HostOS_CPP)" "mingw32"
 ifneq "$$($1_$2_dll0_HS_OBJS)" ""
 $1_$2_$3_LIB0_ROOT = HS$$($1_PACKAGE)-$$($1_$2_VERSION)-0$$($3_libsuf)
@@ -35,7 +34,6 @@ $1_$2_$3_LIB0_NAME = lib$$($1_$2_$3_LIB0_ROOT)
 $1_$2_$3_LIB0 = $1/$2/build/$$($1_$2_$3_LIB0_NAME)
 endif
 endif
-endif
 
 # Note [inconsistent distdirs]
 # hack: the DEPS_LIBS mechanism assumes that the distdirs for packages
@@ -63,12 +61,19 @@ ifeq "$3" "dyn"
 ifeq "$$(HostOS_CPP)" "mingw32"
 $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
 ifneq "$$($1_$2_$3_LIB0)" ""
-	$$(call build-dll,$1,$2,$3,,$$($1_$2_dll0_HS_OBJS) $$($1_$2_$3_NON_HS_OBJS),$$($1_$2_$3_LIB0))
 	$$(call build-dll,$1,$2,$3,-L$1/$2/build -l$$($1_$2_$3_LIB0_ROOT),$$(filter-out $$($1_$2_dll0_HS_OBJS),$$($1_$2_$3_HS_OBJS)) $$($1_$2_$3_NON_HS_OBJS),$$@)
 else
 	$$(call build-dll,$1,$2,$3,,$$($1_$2_$3_HS_OBJS) $$($1_$2_$3_NON_HS_OBJS),$$@)
 endif
+
+ifneq "$$($1_$2_$3_LIB0)" ""
+$$($1_$2_$3_LIB) : $$($1_$2_$3_LIB0)
+$$($1_$2_$3_LIB0) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
+	$$(call build-dll,$1,$2,$3,,$$($1_$2_dll0_HS_OBJS) $$($1_$2_$3_NON_HS_OBJS),$$($1_$2_$3_LIB0))
+endif
+
 else
+
 $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
 	$$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) $$($1_$2_$3_GHC_LD_OPTS) $$($1_$2_$3_ALL_OBJS) \
          -shared -dynamic -dynload deploy \
@@ -92,6 +97,15 @@ else
 	"$$(XARGS)" $$(XARGS_OPTS) "$$($1_$2_AR)" $$($1_$2_AR_OPTS) $$($1_$2_EXTRA_AR_ARGS) $$@ < $$@.contents
 endif
 	$$(call removeFiles,$$@.contents)
+
+ifeq "$$(HostOS_CPP)" "mingw32"
+ifneq "$$($1_$2_$3_LIB0)" ""
+$$($1_$2_$3_LIB) : $$($1_$2_$3_LIB0)
+$$($1_$2_$3_LIB0) :
+	$$(call cmd,$1_$2_AR) $$($1_$2_AR_OPTS) $$($1_$2_EXTRA_AR_ARGS) $$@
+endif
+endif
+
 endif
 
 $(call all-target,$1_$2,all_$1_$2_$3)
diff --git a/utils/ghc-cabal/Main.hs b/utils/ghc-cabal/Main.hs
index f3e64f4..991b2b8 100644
--- a/utils/ghc-cabal/Main.hs
+++ b/utils/ghc-cabal/Main.hs
@@ -6,6 +6,7 @@ import Distribution.PackageDescription
 import Distribution.PackageDescription.Check hiding (doesFileExist)
 import Distribution.PackageDescription.Configuration
 import Distribution.PackageDescription.Parse
+import Distribution.System
 import Distribution.Simple
 import Distribution.Simple.Configure
 import Distribution.Simple.LocalBuildInfo
@@ -280,6 +281,25 @@ fixupPackageId ipinfos (InstalledPackageId ipi)
            f [] = error ("Installed package ID not registered: " ++ show ipi)
        in f ipinfos
 
+-- On Windows we need to split the ghc package into 2 pieces, or the
+-- DLL that it makes contains too many symbols (#5987). There are
+-- therefore 2 libraries, not just the 1 that Cabal assumes.
+mangleLbi :: FilePath -> FilePath -> LocalBuildInfo -> LocalBuildInfo
+mangleLbi "compiler" "stage2" lbi
+ | isWindows =
+    let ccs' = [ (cn, updateComponentLocalBuildInfo clbi, cns)
+               | (cn, clbi, cns) <- componentsConfigs lbi ]
+        updateComponentLocalBuildInfo clbi@(LibComponentLocalBuildInfo {})
+            = let cls' = concat [ [ LibraryName n, LibraryName (n ++ "-0") ]
+                                | LibraryName n <- componentLibraries clbi ]
+              in clbi { componentLibraries = cls' }
+        updateComponentLocalBuildInfo clbi = clbi
+    in lbi { componentsConfigs = ccs' }
+    where isWindows = case hostPlatform lbi of
+                      Platform _ Windows -> True
+                      _                  -> False
+mangleLbi _ _ lbi = lbi
+
 generate :: [String] -> FilePath -> FilePath -> IO ()
 generate config_args distdir directory
  = withCurrentDirectory directory
@@ -290,8 +310,11 @@ generate config_args distdir directory
       withArgs (["configure", "--distdir", distdir] ++ config_args)
                runDefaultMain
 
-      lbi <- getPersistBuildConfig distdir
-      let pd0 = localPkgDescr lbi
+      lbi0 <- getPersistBuildConfig distdir
+      let lbi = mangleLbi directory distdir lbi0
+          pd0 = localPkgDescr lbi
+
+      writePersistBuildConfig distdir lbi
 
       hooked_bi <-
            if (buildType pd0 == Just Configure) || (buildType pd0 == Just Custom)





More information about the ghc-commits mailing list