  exportWordToAddr :: Word -> Addr# -> Int# -> IO Word
 +#ifdef ghcjs_HOST_OS
 +exportWordToAddr (W# w#) addr# e# = js_exportWordToAddr w# addr# e#
-+foreign import javascript unsafe "h$ghcjsb_exportToAddr_w($1,$2_1,$2_2,$3)" js_exportWordToAddr :: Word# -> Addr# -> Int# -> IO Word
++foreign import javascript unsafe "h$ghcjsbn_exportToAddr_w($1,$2_1,$2_2,$3)" js_exportWordToAddr :: Word# -> Addr# -> Int# -> IO Word
 +#else
  exportWordToAddr (W# w#) addr
    = c_mpn_export1ToAddr# w# addr 0# -- TODO: we don't calling GMP for that

-install-includes: HsIntegerGmp.h ghc-gmp.h
+install-includes: HsIntegerGmp.h
diff -X ../utils/updatePatches.excludes -Nru upstream/pkg/integer-gmp/integer-gmp.cabal boot/pkg/integer-gmp/integer-gmp.cabal
--- upstream/pkg/integer-gmp/integer-gmp.cabal	2018-12-24 07:45:51.000000000 +0100
+++ boot/pkg/integer-gmp/integer-gmp.cabal	2018-12-24 07:45:51.676965858 +0100
@@ -67,6 +67,9 @@
   c-sources:
     cbits/wrappers.c

+}
+
+// (b ^ s1) % s2 :: BigNat -> BigNat -> BigNat -> BigNat
+function h$ghcjsbn_modPow_bbb(b, e, m) {
+  var r = h$ghcjsbn_one_b, b = h$ghcjsbn_rem_bb(b, m);
+  while(!h$ghcjsbn_eq_bw(e, 0)) {
+    if(h$ghcjsbn_testBit_b(e, 0)) {
+      r = h$ghcjsbn_rem_bb(h$ghcjsbn_mul_bb(r, b), m);
+    }
+    e = h$ghcjsbn_shr_b(e, 1);
+    b = h$ghcjsbn_rem_bb(h$ghcjsbn_mul_bb(b, b), m);
+  }
+  return r;
+}
+
+// (b ^ s1) % s2 :: BigNat -> Int -> Int -> Int
+function h$ghcjsbn_modPow_bss(b, e, m) {
+  return h$ghcjsbn_modPow_sss(h$ghcjsbn_rem_bw(b, m), e, m);
+}
+// (s1 ^ s2) % s3 :: Int -> Int -> Int -> Int
+function h$ghcjsbn_modPow_sss(b, e, m) {
+  return h$integer_gmp_powm_word(b, e, m);
+}
+
+function h$integer_gmp_powm_word(b, e, m) {
+  var r = 1, b = b % m;
+  while(e !== 0) {
+    if(e % 2 === 1) r = (r * b) % m;
+    e = e >>> 1;
+    b = (b * b) % m;
+  }
+  return r;
+}
+
+// r = gcd(b1,b2) BigNat -> BigNat -> BigNat
+function h$ghcjsbn_gcd_bb(b1, b2) {
