[commit: ghc] master: Include libraries which fill holes as deps when linking. (f3f624a)

git at git.haskell.org git at git.haskell.org
Tue Oct 3 21:56:24 UTC 2017


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/f3f624aeb1360c1f902930b3cc62346d2e5201c0/ghc

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

commit f3f624aeb1360c1f902930b3cc62346d2e5201c0
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


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

f3f624aeb1360c1f902930b3cc62346d2e5201c0
 compiler/main/Packages.hs                          |  4 ++-
 testsuite/tests/backpack/cabal/T14304/Makefile     | 36 ++++++++++++++++++++++
 .../backpack/cabal/{bkpcabal01 => T14304}/Setup.hs |  0
 .../cabal/T14304/T14304.stderr}                    |  2 ++
 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 +++++
 .../T8025/A.hs => backpack/cabal/T14304/th/TH.hs}  |  4 +--
 testsuite/tests/backpack/cabal/T14304/th/th.cabal  |  9 ++++++
 12 files changed, 86 insertions(+), 3 deletions(-)

diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index 172e181..949cc0f 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -1878,8 +1878,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/typecheck/T13168/T13168.stderr b/testsuite/tests/backpack/cabal/T14304/T14304.stderr
similarity index 66%
copy from testsuite/tests/typecheck/T13168/T13168.stderr
copy to testsuite/tests/backpack/cabal/T14304/T14304.stderr
index e69dbaa..89a07b9 100644
--- a/testsuite/tests/typecheck/T13168/T13168.stderr
+++ b/testsuite/tests/backpack/cabal/T14304/T14304.stderr
@@ -2,3 +2,5 @@ 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/th/should_compile/T8025/A.hs b/testsuite/tests/backpack/cabal/T14304/th/TH.hs
similarity index 51%
copy from testsuite/tests/th/should_compile/T8025/A.hs
copy to testsuite/tests/backpack/cabal/T14304/th/TH.hs
index c0e3083..5d921cf 100644
--- a/testsuite/tests/th/should_compile/T8025/A.hs
+++ b/testsuite/tests/backpack/cabal/T14304/th/TH.hs
@@ -1,3 +1,3 @@
 {-# LANGUAGE TemplateHaskell #-}
-module A where
-a = [|3|]
+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