diff options
| author | Clint Adams <clint@debian.org> | 2016-10-05 19:30:41 (GMT) |
|---|---|---|
| committer | Clint Adams <clint@debian.org> | 2016-10-05 20:13:44 (GMT) |
| commit | 6c85e8fa057c35e85231ab95d955b954160e6520 (patch) | |
| tree | 82100bcc1789776002b9e75eb404a7aeb5bf5bda | |
| parent | bcca282d8d28576d2f394fe564d5a96b69380df1 (diff) | |
ghc: backport patches to use gcc SMP primtives on powerpc and add missing MO_WriteBarrierghc_v7.10.3-10
| -rw-r--r-- | p/ghc/debian/changelog | 10 | ||||
| -rw-r--r-- | p/ghc/debian/patches/add-missing-MO_WriteBarrier | 40 | ||||
| -rw-r--r-- | p/ghc/debian/patches/ppc-smp-primitives | 100 | ||||
| -rw-r--r-- | p/ghc/debian/patches/series | 2 |
4 files changed, 150 insertions, 2 deletions
diff --git a/p/ghc/debian/changelog b/p/ghc/debian/changelog index 77467de..9688d9b 100644 --- a/p/ghc/debian/changelog +++ b/p/ghc/debian/changelog @@ -1,10 +1,16 @@ -ghc (7.10.3-10) UNRELEASED; urgency=medium +ghc (7.10.3-10) unstable; urgency=medium [ Balint Reczey ] * Disable PIE to fix build when PIE is the default in gcc (change taken/revised from Ubuntu, Closes: #712228) - -- Gianfranco Costamagna <locutusofborg@debian.org> Tue, 27 Sep 2016 17:00:13 +0200 + [ Clint Adams ] + * Backport upstream 563a4857abcee4a6e43c68323274309c58f42aa0 to use gcc's + SMP primitives instead of GHC's broken ones. + * Backport upstream 7053019e7b04842dd7364039381d8c4c069489a2 to add a + missing MO_WriteBarrier to emitPrimOp. + + -- Clint Adams <clint@debian.org> Wed, 05 Oct 2016 15:27:23 -0400 ghc (7.10.3-9) unstable; urgency=medium diff --git a/p/ghc/debian/patches/add-missing-MO_WriteBarrier b/p/ghc/debian/patches/add-missing-MO_WriteBarrier new file mode 100644 index 0000000..83f22a7 --- /dev/null +++ b/p/ghc/debian/patches/add-missing-MO_WriteBarrier @@ -0,0 +1,40 @@ +From: Ben Gamari <bgamari.foss@gmail.com> +Date: Tue, 30 Aug 2016 21:08:05 +0000 (-0400) +Subject: StgCmmPrim: Add missing MO_WriteBarrier +X-Git-Url: https://git.haskell.org/ghc.git/commitdiff_plain/7053019e7b04842dd7364039381d8c4c069489a2 + +StgCmmPrim: Add missing MO_WriteBarrier + +Test Plan: Good question + +Reviewers: austin, trommler, simonmar, rrnewton + +Reviewed By: simonmar + +Subscribers: RyanGlScott, thomie + +Differential Revision: https://phabricator.haskell.org/D2495 + +GHC Trac Issues: #12469 + +(cherry picked from commit d40d6df74a9fca382a84709ac9bc862897fbec18) +--- + +diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs +index 5d3b94f..3cb9f83 100644 +--- a/compiler/codeGen/StgCmmPrim.hs ++++ b/compiler/codeGen/StgCmmPrim.hs +@@ -310,8 +310,11 @@ emitPrimOp _ [res] GetCurrentCCSOp [_dummy_arg] + emitPrimOp dflags [res] ReadMutVarOp [mutv] + = emitAssign (CmmLocal res) (cmmLoadIndexW dflags mutv (fixedHdrSizeW dflags) (gcWord dflags)) + +-emitPrimOp dflags [] WriteMutVarOp [mutv,var] +- = do emitStore (cmmOffsetW dflags mutv (fixedHdrSizeW dflags)) var ++emitPrimOp dflags res@[] WriteMutVarOp [mutv,var] ++ = do -- Without this write barrier, other CPUs may see this pointer before ++ -- the writes for the closure it points to have occurred. ++ emitPrimCall res MO_WriteBarrier [] ++ emitStore (cmmOffsetW dflags mutv (fixedHdrSizeW dflags)) var + emitCCall + [{-no results-}] + (CmmLit (CmmLabel mkDirty_MUT_VAR_Label)) diff --git a/p/ghc/debian/patches/ppc-smp-primitives b/p/ghc/debian/patches/ppc-smp-primitives new file mode 100644 index 0000000..11b4108 --- /dev/null +++ b/p/ghc/debian/patches/ppc-smp-primitives @@ -0,0 +1,100 @@ +From: Peter Trommler <ptrommler@acm.org> +Date: Mon, 16 May 2016 13:19:09 +0000 (+0200) +Subject: PPC: Implement SMP primitives using gcc built-ins +X-Git-Tag: ghc-8.0.1-release~11 +X-Git-Url: https://git.haskell.org/ghc.git/commitdiff_plain/f4e6b32831bd718a040b382865ac7aea1254bf4e + +PPC: Implement SMP primitives using gcc built-ins + +The SMP primitives were missing appropriate memory barriers +(sync, isync instructions) on all PowerPCs. + +Use the built-ins _sync_* provided by gcc and clang. This +reduces code size significantly. + +Remove broken mark for concprog001 on powerpc64. The referenced +ticket number (11259) was wrong. + +Test Plan: validate on powerpc and ARM + +Reviewers: erikd, austin, simonmar, bgamari, hvr + +Reviewed By: bgamari, hvr + +Subscribers: thomie + +Differential Revision: https://phabricator.haskell.org/D2225 + +GHC Trac Issues: #12070 + +(cherry picked from commit 563a4857abcee4a6e43c68323274309c58f42aa0) +--- + +--- a/includes/stg/SMP.h ++++ b/includes/stg/SMP.h +@@ -119,14 +119,8 @@ + :"+r" (result), "+m" (*p) + : /* no input-only operands */ + ); +-#elif powerpc_HOST_ARCH +- __asm__ __volatile__ ( +- "1: lwarx %0, 0, %2\n" +- " stwcx. %1, 0, %2\n" +- " bne- 1b" +- :"=&r" (result) +- :"r" (w), "r" (p) +- ); ++#elif powerpc_HOST_ARCH || powerpc64_HOST_ARCH || powerpc64le_HOST_ARCH ++ result = __sync_lock_test_and_set(p, w); + #elif sparc_HOST_ARCH + result = w; + __asm__ __volatile__ ( +@@ -194,20 +188,8 @@ + :"=a"(o), "+m" (*(volatile unsigned int *)p) + :"0" (o), "r" (n)); + return o; +-#elif powerpc_HOST_ARCH +- StgWord result; +- __asm__ __volatile__ ( +- "1: lwarx %0, 0, %3\n" +- " cmpw %0, %1\n" +- " bne 2f\n" +- " stwcx. %2, 0, %3\n" +- " bne- 1b\n" +- "2:" +- :"=&r" (result) +- :"r" (o), "r" (n), "r" (p) +- :"cc", "memory" +- ); +- return result; ++#elif powerpc_HOST_ARCH || powerpc64_HOST_ARCH || powerpc64le_HOST_ARCH ++ return __sync_val_compare_and_swap(p, o, n); + #elif sparc_HOST_ARCH + __asm__ __volatile__ ( + "cas [%1], %2, %0" +@@ -268,6 +250,7 @@ + + // RRN: Generalized to arbitrary increments to enable fetch-and-add in + // Haskell code (fetchAddIntArray#). ++// PT: add-and-fetch, returns new value + EXTERN_INLINE StgWord + atomic_inc(StgVolatilePtr p, StgWord incr) + { +@@ -279,6 +262,8 @@ + "+r" (r), "+m" (*p): + ); + return r + incr; ++#elif powerpc_HOST_ARCH || powerpc64_HOST_ARCH || powerpc64le_HOST_ARCH ++ return __sync_add_and_fetch(p, incr); + #else + StgWord old, new_; + do { +@@ -300,6 +285,8 @@ + "+r" (r), "+m" (*p): + ); + return r-1; ++#elif powerpc_HOST_ARCH || powerpc64_HOST_ARCH || powerpc64le_HOST_ARCH ++ return __sync_sub_and_fetch(p, (StgWord) 1); + #else + StgWord old, new_; + do { diff --git a/p/ghc/debian/patches/series b/p/ghc/debian/patches/series index 0c2f607..64a287b 100644 --- a/p/ghc/debian/patches/series +++ b/p/ghc/debian/patches/series @@ -8,3 +8,5 @@ cabal-show-detail-direct.patch sh4-platform-detection-support.patch sparc64-initial-platform-support.patch do-not-use-SHELL +ppc-smp-primitives +add-missing-MO_WriteBarrier |
