[commit: ghc] ghc-8.2: Include libraries which fill holes as deps when linking. (876fec0)

git at git.haskell.org git at git.haskell.org
Tue Oct 3 21:58:47 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/876fec04c04061d5a2257675fcd0deb35ecb0aaf/ghc

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

commit 876fec04c04061d5a2257675fcd0deb35ecb0aaf
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Tue Oct 3 15:08:24 2017 -0400

    Include libraries which fill holes as deps when linking.
    
    Fixes the issue reported at https://github.com/haskell/cabal/issues/4755
    and fixes #14304 in the GHC tracker.
    
    Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
    
    Test Plan: validate
    
    Reviewers: bgamari, austin, goldfire
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie
    
    GHC Trac Issues: #14304
    
    Differential Revision: https://phabricator.haskell.org/D4057
    
    (cherry picked from commit f3f624aeb1360c1f902930b3cc62346d2e5201c0)


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

876fec04c04061d5a2257675fcd0deb35ecb0aaf
 compiler/main/Packages.hs                          |  4 ++-
 testsuite/tests/backpack/cabal/T14304/Makefile     | 36 ++++++++++++++++++++++
 .../backpack/cabal/{bkpcabal01 => T14304}/Setup.hs |  0
 .../tests/backpack/cabal/T14304/T14304.stderr      |  6 ++++
 testsuite/tests/backpack/cabal/T14304/all.T        |  9 ++++++
 .../tests/backpack/cabal/T14304/indef/Indef.hs     |  3 ++
 .../tests/backpack/cabal/T14304/indef/Sig.hsig     |  2 ++
 .../tests/backpack/cabal/T14304/indef/indef.cabal  |  9 ++++++
 testsuite/tests/backpack/cabal/T14304/p/P.hs       |  3 ++
 testsuite/tests/backpack/cabal/T14304/p/p.cabal    |  8 +++++
 .../Sub1.hs => backpack/cabal/T14304/th/TH.hs}     |  4 +--
 testsuite/tests/backpack/cabal/T14304/th/th.cabal  |  9 ++++++
 12 files changed, 90 insertions(+), 3 deletions(-)

diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index 2c5833f..08b0ceb 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -1875,8 +1875,10 @@ listVisibleModuleNames dflags =
 -- | Find all the 'PackageConfig' in both the preload packages from 'DynFlags' and corresponding to the list of
 -- 'PackageConfig's
 getPreloadPackagesAnd :: DynFlags -> [PreloadUnitId] -> IO [PackageConfig]
-getPreloadPackagesAnd dflags pkgids =
+getPreloadPackagesAnd dflags pkgids0 =
   let
+      pkgids  = pkgids0 ++ map (toInstalledUnitId . moduleUnitId . snd)
+                               (thisUnitIdInsts dflags)
       state   = pkgState dflags
       pkg_map = pkgIdMap state
       preload = preloadPackages state
diff --git a/testsuite/tests/backpack/cabal/T14304/Makefile b/testsuite/tests/backpack/cabal/T14304/Makefile
new file mode 100644
index 0000000..1f58184
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/T14304/Makefile
@@ -0,0 +1,36 @@
+TOP=../../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+SETUP='$(PWD)/Setup' -v0
+CONFIGURE=$(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db='$(PWD)/tmp.d' --prefix='$(PWD)/inst' --enable-shared
+
+T14304: clean
+	$(MAKE) -s --no-print-directory clean
+	'$(GHC_PKG)' init tmp.d
+	'$(TEST_HC)' -v0 --make Setup
+	# typecheck indef
+	rm -rf indef/dist
+	(cd indef; $(CONFIGURE) --ipid "indef-0.1")
+	(cd indef; $(SETUP) build)
+	(cd indef; $(SETUP) copy)
+	(cd indef; $(SETUP) register)
+	# build p
+	rm -rf p/dist
+	(cd p; $(CONFIGURE) --ipid "p-0.1")
+	(cd p; $(SETUP) build)
+	(cd p; $(SETUP) copy)
+	(cd p; $(SETUP) register)
+	# build indef instantiated with p
+	rm -rf indef/dist
+	(cd indef; $(CONFIGURE) --ipid "indef-0.1" --instantiate-with "Sig=p-0.1:P")
+	(cd indef; $(SETUP) build)
+	(cd indef; $(SETUP) copy)
+	(cd indef; $(SETUP) register)
+	# build th (which tests if we have correct linkage)
+	rm -rf th/dist
+	(cd th; $(CONFIGURE))
+	(cd th; $(SETUP) build)
+
+clean :
+	$(RM) -r tmp.d inst dist Setup$(exeext)
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/Setup.hs b/testsuite/tests/backpack/cabal/T14304/Setup.hs
similarity index 100%
copy from testsuite/tests/backpack/cabal/bkpcabal01/Setup.hs
copy to testsuite/tests/backpack/cabal/T14304/Setup.hs
diff --git a/testsuite/tests/backpack/cabal/T14304/T14304.stderr b/testsuite/tests/backpack/cabal/T14304/T14304.stderr
new file mode 100644
index 0000000..89a07b9
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/T14304/T14304.stderr
@@ -0,0 +1,6 @@
+Warning: -rtsopts and -with-rtsopts have no effect with -shared.
+    Call hs_init_ghc() from your main() function to set these options.
+Warning: -rtsopts and -with-rtsopts have no effect with -shared.
+    Call hs_init_ghc() from your main() function to set these options.
+Warning: -rtsopts and -with-rtsopts have no effect with -shared.
+    Call hs_init_ghc() from your main() function to set these options.
diff --git a/testsuite/tests/backpack/cabal/T14304/all.T b/testsuite/tests/backpack/cabal/T14304/all.T
new file mode 100644
index 0000000..f25285d
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/T14304/all.T
@@ -0,0 +1,9 @@
+if config.cleanup:
+   cleanup = 'CLEANUP=1'
+else:
+   cleanup = 'CLEANUP=0'
+
+test('T14304',
+     extra_files(['p', 'indef', 'th', 'Setup.hs']),
+     run_command,
+     ['$MAKE -s --no-print-directory T14304 ' + cleanup])
diff --git a/testsuite/tests/backpack/cabal/T14304/indef/Indef.hs b/testsuite/tests/backpack/cabal/T14304/indef/Indef.hs
new file mode 100644
index 0000000..0bd438e
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/T14304/indef/Indef.hs
@@ -0,0 +1,3 @@
+module Indef where
+import Sig
+data T = MkT B
diff --git a/testsuite/tests/backpack/cabal/T14304/indef/Sig.hsig b/testsuite/tests/backpack/cabal/T14304/indef/Sig.hsig
new file mode 100644
index 0000000..a37b190
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/T14304/indef/Sig.hsig
@@ -0,0 +1,2 @@
+signature Sig where
+data B
diff --git a/testsuite/tests/backpack/cabal/T14304/indef/indef.cabal b/testsuite/tests/backpack/cabal/T14304/indef/indef.cabal
new file mode 100644
index 0000000..d89f055
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/T14304/indef/indef.cabal
@@ -0,0 +1,9 @@
+name: indef
+version: 1.0
+build-type: Simple
+cabal-version: >= 2.0
+
+library
+    build-depends: base
+    signatures: Sig
+    exposed-modules: Indef
diff --git a/testsuite/tests/backpack/cabal/T14304/p/P.hs b/testsuite/tests/backpack/cabal/T14304/p/P.hs
new file mode 100644
index 0000000..f570e0b
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/T14304/p/P.hs
@@ -0,0 +1,3 @@
+module P where
+type B = Foo
+newtype Foo = Foo Double
diff --git a/testsuite/tests/backpack/cabal/T14304/p/p.cabal b/testsuite/tests/backpack/cabal/T14304/p/p.cabal
new file mode 100644
index 0000000..f49ce42
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/T14304/p/p.cabal
@@ -0,0 +1,8 @@
+name: p
+version: 1.0
+build-type: Simple
+cabal-version: >= 2.0
+
+library
+    build-depends: base
+    exposed-modules: P
diff --git a/testsuite/tests/driver/recomp009/Sub1.hs b/testsuite/tests/backpack/cabal/T14304/th/TH.hs
similarity index 51%
copy from testsuite/tests/driver/recomp009/Sub1.hs
copy to testsuite/tests/backpack/cabal/T14304/th/TH.hs
index 25ea755..5d921cf 100644
--- a/testsuite/tests/driver/recomp009/Sub1.hs
+++ b/testsuite/tests/backpack/cabal/T14304/th/TH.hs
@@ -1,3 +1,3 @@
 {-# LANGUAGE TemplateHaskell #-}
-module Sub where
-x = [| 1 |]
+module TH where
+$( return [] )
diff --git a/testsuite/tests/backpack/cabal/T14304/th/th.cabal b/testsuite/tests/backpack/cabal/T14304/th/th.cabal
new file mode 100644
index 0000000..2b17f09
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/T14304/th/th.cabal
@@ -0,0 +1,9 @@
+name: th
+version: 1.0
+build-type: Simple
+cabal-version: >= 2.0
+
+library
+    build-depends: p, indef, base
+    mixins: p (P as Sig)
+    exposed-modules: TH



More information about the ghc-commits mailing list