[commit: ghc] master: Fix #8696 - don't generate static intra-package references. (ed1aced)

git at git.haskell.org git at git.haskell.org
Mon Feb 24 20:14:38 UTC 2014


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

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

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

commit ed1aced403b50f1a15fbe06cc7eeca5b23e69e37
Author: Austin Seipp <austin at well-typed.com>
Date:   Mon Feb 24 13:03:34 2014 -0600

    Fix #8696 - don't generate static intra-package references.
    
    See the comments in Packages.lhs and the ticket for some more explanation.
    
    This is a temporary fix while we consider a way to re-enable intra-package
    references in the mean time.
    
    Authored-by: Reid Barton <rwbarton at gmail.com>
    Signed-off-by: Austin Seipp <austin at well-typed.com>


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

ed1aced403b50f1a15fbe06cc7eeca5b23e69e37
 compiler/main/Packages.lhs                             |   16 ++++++++++++++--
 testsuite/tests/ghci/scripts/T8696.script              |    4 ++++
 .../{boxy/T2193.stdout => ghci/scripts/T8696.stdout}   |    1 +
 testsuite/tests/ghci/scripts/T8696A.hs                 |    4 ++++
 testsuite/tests/ghci/scripts/T8696B.hs                 |    4 ++++
 testsuite/tests/ghci/scripts/all.T                     |    1 +
 6 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/compiler/main/Packages.lhs b/compiler/main/Packages.lhs
index aefb536..a13b359 100644
--- a/compiler/main/Packages.lhs
+++ b/compiler/main/Packages.lhs
@@ -1047,10 +1047,22 @@ isDllName :: DynFlags -> PackageId -> Module -> Name -> Bool
 -- Despite the "dll", I think this function just means that
 -- the synbol comes from another dynamically-linked package,
 -- and applies on all platforms, not just Windows
-isDllName dflags this_pkg this_mod name
+isDllName dflags _this_pkg this_mod name
   | gopt Opt_Static dflags = False
   | Just mod <- nameModule_maybe name
-    = if modulePackageId mod /= this_pkg
+    -- Issue #8696 - when GHC is dynamically linked, it will attempt
+    -- to load the dynamic dependencies of object files at compile
+    -- time for things like QuasiQuotes or
+    -- TemplateHaskell. Unfortunately, this interacts badly with
+    -- intra-package linking, because we don't generate indirect
+    -- (dynamic) symbols for intra-package calls. This means that if a
+    -- module with an intra-package call is loaded without its
+    -- dependencies, then GHC fails to link. This is the cause of #
+    --
+    -- In the mean time, always force dynamic indirections to be
+    -- generated: when the module name isn't the module being
+    -- compiled, references are dynamic.
+    = if mod /= this_mod
       then True
       else case dllSplit dflags of
            Nothing -> False
diff --git a/testsuite/tests/ghci/scripts/T8696.script b/testsuite/tests/ghci/scripts/T8696.script
new file mode 100644
index 0000000..8bc8b8a
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T8696.script
@@ -0,0 +1,4 @@
+:set -fobject-code
+:load T8696A T8696B
+T8696A.a
+T8696B.b
diff --git a/testsuite/tests/boxy/T2193.stdout b/testsuite/tests/ghci/scripts/T8696.stdout
similarity index 50%
copy from testsuite/tests/boxy/T2193.stdout
copy to testsuite/tests/ghci/scripts/T8696.stdout
index b8626c4..b944734 100644
--- a/testsuite/tests/boxy/T2193.stdout
+++ b/testsuite/tests/ghci/scripts/T8696.stdout
@@ -1 +1,2 @@
+3
 4
diff --git a/testsuite/tests/ghci/scripts/T8696A.hs b/testsuite/tests/ghci/scripts/T8696A.hs
new file mode 100644
index 0000000..465af37
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T8696A.hs
@@ -0,0 +1,4 @@
+module T8696A (a) where
+{-# NOINLINE a #-}
+a :: Int
+a = 3
diff --git a/testsuite/tests/ghci/scripts/T8696B.hs b/testsuite/tests/ghci/scripts/T8696B.hs
new file mode 100644
index 0000000..e57ab55
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T8696B.hs
@@ -0,0 +1,4 @@
+module T8696B (b) where
+import T8696A (a)
+b :: Int
+b = a+1
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index a7f6fa1..e9fe6e8 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -165,3 +165,4 @@ test('T8640', normal, ghci_script, ['T8640.script'])
 test('T8579', normal, ghci_script, ['T8579.script'])
 test('T8649', normal, ghci_script, ['T8649.script'])
 test('T8674', normal, ghci_script, ['T8674.script'])
+test('T8696', normal, ghci_script, ['T8696.script'])



More information about the ghc-commits mailing list