Index: ubuntu/rts/posix/OSThreads.c
===================================================================
--- ubuntu.orig/rts/posix/OSThreads.c	2011-01-13 10:50:13.380652334 +0000
+++ ubuntu/rts/posix/OSThreads.c	2011-01-13 10:50:16.560899833 +0000
@@ -7,10 +7,10 @@
  *
  * --------------------------------------------------------------------------*/
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__GLIBC__)
 /* We want GNU extensions in DEBUG mode for mutex error checking */
 /* We also want the affinity API, which requires _GNU_SOURCE */
-#define _GNU_SOURCE
+#define _GNU_SOURCE 1
 #endif
 
 #include "PosixSource.h"
Index: ubuntu/driver/mangler/ghc-asm.lprl
===================================================================
--- ubuntu.orig/driver/mangler/ghc-asm.lprl	2011-01-13 10:50:13.400653909 +0000
+++ ubuntu/driver/mangler/ghc-asm.lprl	2011-01-13 10:50:16.560899833 +0000
@@ -216,7 +216,7 @@
     $T_HDR_vector   = "\.text\n\t\.align 8\n";
 
     #--------------------------------------------------------#
-    } elsif ( $TargetPlatform =~ /^x86_64-.*-(linux|openbsd|freebsd|dragonfly|netbsd)$/m ) {
+    } elsif ( $TargetPlatform =~ /^x86_64-.*-(linux|openbsd|freebsd|dragonfly|netbsd|kfreebsdgnu)$/m ) {
 
     $T_STABBY       = 0; # 1 iff .stab things (usually if a.out format)
     $T_US           = ''; # _ if symbols have an underscore on the front
Index: ubuntu/rts/Linker.c
===================================================================
--- ubuntu.orig/rts/Linker.c	2011-01-13 10:50:13.390653119 +0000
+++ ubuntu/rts/Linker.c	2011-01-13 10:50:16.560899833 +0000
@@ -13,8 +13,8 @@
 /* Linux needs _GNU_SOURCE to get RTLD_DEFAULT from <dlfcn.h> and
    MREMAP_MAYMOVE from <sys/mman.h>.
  */
-#ifdef __linux__
-#define _GNU_SOURCE
+#ifdef defined(__linux__)  || defined(__GLIBC__)
+#define _GNU_SOURCE 1
 #endif
 
 #include "Rts.h"
@@ -63,7 +63,7 @@
 #include <sys/wait.h>
 #endif
 
-#if defined(linux_HOST_OS) || defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS) || defined(darwin_HOST_OS)
+#if defined(linux_HOST_OS) || defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS) || defined(darwin_HOST_OS) || defined(kfreebsdgnu_HOST_OS)
 #define USE_MMAP
 #include <fcntl.h>
 #include <sys/mman.h>
@@ -74,7 +74,7 @@
 
 #endif
 
-#if defined(linux_HOST_OS) || defined(solaris2_HOST_OS) || defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS)
+#if defined(linux_HOST_OS) || defined(solaris2_HOST_OS) || defined(freebsd_HOST_OS) || defined(kfreebsdgnu_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS)
 #  define OBJFORMAT_ELF
 #elif defined(cygwin32_HOST_OS) || defined (mingw32_HOST_OS)
 #  define OBJFORMAT_PEi386
@@ -1410,7 +1410,7 @@
        } else {
            if ((W_)result > 0x80000000) {
                // oops, we were given memory over 2Gb
-#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS)
+#if defined(freebsd_HOST_OS) || defined(kfreebsdgnu_HOST_OS) || defined(dragonfly_HOST_OS)
                // Some platforms require MAP_FIXED.  This is normally
                // a bad idea, because MAP_FIXED will overwrite
                // existing mappings.
