[PATCH] Added support to cross-compile to android

Nathan nathan.huesken at posteo.de
Wed Jan 23 18:07:19 CET 2013


---
 aclocal.m4                          |    6 ++++++
 compiler/llvmGen/LlvmCodeGen/Ppr.hs |    3 +++
 compiler/utils/Platform.hs          |    2 ++
 3 files changed, 11 insertions(+)

diff --git a/aclocal.m4 b/aclocal.m4
index fca602f..806b5da 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -248,6 +248,9 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
         dragonfly|osf1|hpux|linuxaout|freebsd2|cygwin32|gnu|nextstep2|nextstep3|sunos4|ultrix|irix|aix)
             test -z "[$]2" || eval "[$]2=OSUnknown"
             ;;
+        linux-android)
+            test -z "[$]2" || eval "[$]2=OSAndroid"
+            ;;
         *)
             echo "Unknown OS '[$]1'"
             exit 1
@@ -1818,6 +1821,9 @@ AC_DEFUN([GHC_CONVERT_VENDOR],[
 # converts os from gnu to ghc naming, and assigns the result to $target_var
 AC_DEFUN([GHC_CONVERT_OS],[
 case "$1" in
+  linux-android*)
+    $2="linux-android"
+    ;;
   linux-*|linux)
     $2="linux"
     ;;
diff --git a/compiler/llvmGen/LlvmCodeGen/Ppr.hs b/compiler/llvmGen/LlvmCodeGen/Ppr.hs
index 218870a..5d9fb23 100644
--- a/compiler/llvmGen/LlvmCodeGen/Ppr.hs
+++ b/compiler/llvmGen/LlvmCodeGen/Ppr.hs
@@ -58,6 +58,9 @@ moduleLayout = sdocWithPlatform $ \platform ->
     Platform { platformArch = ArchARM {}, platformOS = OSLinux } ->
         text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32\""
         $+$ text "target triple = \"arm-unknown-linux-gnueabi\""
+    Platform { platformArch = ArchARM {}, platformOS = OSAndroid } ->
+        text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32\""
+        $+$ text "target triple = \"arm-unknown-linux-androideabi\""
     _ ->
         -- FIX: Other targets
         empty
diff --git a/compiler/utils/Platform.hs b/compiler/utils/Platform.hs
index 76c9fa3..d17ff3b 100644
--- a/compiler/utils/Platform.hs
+++ b/compiler/utils/Platform.hs
@@ -69,6 +69,7 @@ data OS
         | OSKFreeBSD
         | OSHaiku
         | OSOsf3
+        | OSAndroid
         deriving (Read, Show, Eq)
 
 -- | ARM Instruction Set Architecture, Extensions and ABI
@@ -109,6 +110,7 @@ osElfTarget OSMinGW32   = False
 osElfTarget OSKFreeBSD  = True
 osElfTarget OSHaiku     = True
 osElfTarget OSOsf3      = False -- I don't know if this is right, but as
+osElfTarget OSAndroid   = True
                                 -- per comment below it's safe
 osElfTarget OSUnknown   = False
  -- Defaulting to False is safe; it means don't rely on any
-- 
1.7.10.4


--------------070209080804090804000307--



More information about the ghc-devs mailing list