[commit: ghc] ghc-7.10: Fix linker interaction between Template Haskell and HPC (#9762) (3afe35d)

git at git.haskell.org git at git.haskell.org
Sat Dec 27 12:12:16 UTC 2014


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

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/3afe35d13daa3c18fc8cc4d8bfd2294d1f6c7d8d/ghc

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

commit 3afe35d13daa3c18fc8cc4d8bfd2294d1f6c7d8d
Author: Reid Barton <rwbarton at gmail.com>
Date:   Tue Dec 23 16:53:16 2014 -0500

    Fix linker interaction between Template Haskell and HPC (#9762)
    
    I'm not really happy about perpetuating the hackish fix for #8696,
    but at least in the context of building with -fhpc, the performance
    cost should be negligible.
    
    I'm suspicious about PlainModuleInitLabel and the Windows stuff too,
    but I don't know what it does / can't test it (respectively) so I'll
    leave those alone for now.
    
    Hopefully out-of-process TH will save us from these hacks some day.
    
    The test is an adaptation of T8696. It's a bit more awkward since
    I couldn't think of a way to get cross-module tickbox references
    without optimizations (inlining), but ghci doesn't permit -O for
    some reason.
    
    (cherry picked from commit 3e3aa9258b521d362d3a51cb48969df3eeab4981)


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

3afe35d13daa3c18fc8cc4d8bfd2294d1f6c7d8d
 compiler/cmm/CLabel.hs                                      | 2 +-
 testsuite/tests/ghci/scripts/Makefile                       | 3 +++
 testsuite/tests/ghci/scripts/T9762.script                   | 3 +++
 testsuite/tests/ghci/scripts/{T8696.stdout => T9762.stdout} | 0
 testsuite/tests/ghci/scripts/T9762A.hs                      | 5 +++++
 testsuite/tests/ghci/scripts/T9762B.hs                      | 4 ++++
 testsuite/tests/ghci/scripts/all.T                          | 2 ++
 7 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
index 603f213..ebf902f 100644
--- a/compiler/cmm/CLabel.hs
+++ b/compiler/cmm/CLabel.hs
@@ -897,7 +897,7 @@ labelDynamic dflags this_pkg this_mod lbl =
 
    PlainModuleInitLabel m -> not (gopt Opt_Static dflags) && this_pkg /= (modulePackageKey m)
 
-   HpcTicksLabel m        -> not (gopt Opt_Static dflags) && this_pkg /= (modulePackageKey m)
+   HpcTicksLabel m        -> not (gopt Opt_Static dflags) && this_mod /= m
 
    -- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
    _                 -> False
diff --git a/testsuite/tests/ghci/scripts/Makefile b/testsuite/tests/ghci/scripts/Makefile
index 873de43..1ccd62f 100644
--- a/testsuite/tests/ghci/scripts/Makefile
+++ b/testsuite/tests/ghci/scripts/Makefile
@@ -44,3 +44,6 @@ T9367:
 	'$(TEST_HC)' $(TEST_HC_OPTS) --interactive -v0 -ignore-dot-ghci                   < T9367.script > T9367-raw.run.stdout
 	cmp T9367-raw.run.stdout T9367-raw.stdout
 
+.PHONY: T9762_prep
+T9762_prep:
+	'$(TEST_HC)' $(TEST_HC_OPTS) -O -fhpc -dynamic T9762B.hs
diff --git a/testsuite/tests/ghci/scripts/T9762.script b/testsuite/tests/ghci/scripts/T9762.script
new file mode 100644
index 0000000..c41dbfd
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T9762.script
@@ -0,0 +1,3 @@
+:load T9762A T9762B
+T9762A.a
+T9762B.b
diff --git a/testsuite/tests/ghci/scripts/T8696.stdout b/testsuite/tests/ghci/scripts/T9762.stdout
similarity index 100%
copy from testsuite/tests/ghci/scripts/T8696.stdout
copy to testsuite/tests/ghci/scripts/T9762.stdout
diff --git a/testsuite/tests/ghci/scripts/T9762A.hs b/testsuite/tests/ghci/scripts/T9762A.hs
new file mode 100644
index 0000000..cd386ed
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T9762A.hs
@@ -0,0 +1,5 @@
+module T9762A (a) where
+-- By marking a INLINE, we create a reference from B to A's tickboxes.
+{-# INLINE a #-}
+a :: Int
+a = 3
diff --git a/testsuite/tests/ghci/scripts/T9762B.hs b/testsuite/tests/ghci/scripts/T9762B.hs
new file mode 100644
index 0000000..387d0e2
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T9762B.hs
@@ -0,0 +1,4 @@
+module T9762B (b) where
+import T9762A (a)
+b :: Int
+b = a+1
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index a78068a..c8462c1 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -193,4 +193,6 @@ test('T9086b', normal, ghci_script, ['T9086b.script'])
 test('T9140', combined_output, ghci_script, ['T9140.script'])
 test('T9658', normal, ghci_script, ['T9658.script'])
 test('T9293', normal, ghci_script_without_flag('-fno-warn-tabs'), ['T9293.script'])
+test('T9762', [pre_cmd('$MAKE -s --no-print-directory T9762_prep')],
+     ghci_script, ['T9762.script'])
 test('T9881', normal, ghci_script, ['T9881.script'])



More information about the ghc-commits mailing list