diff --git a/ghci-ng.cabal b/ghci-ng.cabal
--- a/ghci-ng.cabal
+++ b/ghci-ng.cabal
@@ -1,5 +1,5 @@
 name: ghci-ng
-version: 7.6.3.1
+version: 7.6.3.2
 license: BSD3
 license-file: LICENSE
 author: The GHC Team
@@ -20,6 +20,8 @@
     .
     * @:complete@ command for non-interactive completion
       (proposed for GHC 7.8.1, <http://ghc.haskell.org/trac/ghc/ticket/5687>)
+
+extra-source-files: src/HsVersions.h rts/PosixSource.h
 
 executable ghci-ng
     default-language: Haskell2010
diff --git a/rts/PosixSource.h b/rts/PosixSource.h
new file mode 100644
--- /dev/null
+++ b/rts/PosixSource.h
@@ -0,0 +1,42 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team, 1998-2005
+ *
+ * Include this file into sources which should not need any non-Posix services.
+ * That includes most RTS C sources.
+ * ---------------------------------------------------------------------------*/
+
+#ifndef POSIXSOURCE_H
+#define POSIXSOURCE_H
+
+#include <ghcplatform.h>
+
+#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS)
+#define _POSIX_C_SOURCE 200112L
+#define _XOPEN_SOURCE   600
+#else
+#define _POSIX_SOURCE   1
+#define _POSIX_C_SOURCE 199506L
+#define _XOPEN_SOURCE   500
+// FreeBSD takes a different approach to _ISOC99_SOURCE: on FreeBSD it
+// means "I want *just* C99 things", whereas on GNU libc and Solaris
+// it means "I also want C99 things".  
+//
+// On both GNU libc and FreeBSD, _ISOC99_SOURCE is implied by
+// _XOPEN_SOURCE==600, but on Solaris it is an error to omit it.
+#define _ISOC99_SOURCE
+// Defining __USE_MINGW_ANSI_STDIO is the most portable way to tell
+// mingw that we want to use the standard %lld style format specifiers,
+// rather than the Windows %I64d style
+#define __USE_MINGW_ANSI_STDIO 1
+#endif
+
+#if defined(darwin_HOST_OS)
+/* If we don't define this the including sysctl breaks with things like
+    /usr/include/bsm/audit.h:224:0:
+         error: syntax error before 'u_char'
+*/
+#define _DARWIN_C_SOURCE 1
+#endif
+
+#endif /* POSIXSOURCE_H */
diff --git a/src/HsVersions.h b/src/HsVersions.h
new file mode 100644
--- /dev/null
+++ b/src/HsVersions.h
@@ -0,0 +1,8 @@
+/* Hack needed because of http://hackage.haskell.org/trac/ghc/ticket/8040 */
+
+#define ASSERT(e)      if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
+
+#define GLOBAL_VAR(name,value,ty)  \
+{-# NOINLINE name #-};             \
+name :: IORef (ty);                \
+name = Util.global (value);
