diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2014-12-27 21:11:52 +1100 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2014-12-29 10:42:53 +1100 |
commit | 58ac9c8f6e986bac817ad08d5a2fd11cd167f029 (patch) | |
tree | 3a8889d2ae51f3301629f29fddfb1b43c01dc861 /compiler/llvmGen | |
parent | 0cc0cc8688ddb53db65a73d7d562e9564cfad22b (diff) | |
download | haskell-58ac9c8f6e986bac817ad08d5a2fd11cd167f029.tar.gz |
LlvmCodeGen cross-compiling fixes (#9895)
Summary:
* Throw an error when cross-compiling without a target definition.
When cross compiling via LLVM, a target 'datalayout' and 'triple' must
be defined or LLVM will generate code for the compile host instead of
the compile target.
* Add aarch64-unknown-linux-gnu target.
The datalayout and triple lines were found by using clang to compile a
small C program and -emit-llvm to get the LLVM IR output.
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
Test Plan: validate
Reviewers: rwbarton, carter, hvr, bgamari, austin
Reviewed By: austin
Subscribers: carter, thomie, garious
Differential Revision: https://phabricator.haskell.org/D585
GHC Trac Issues: #9895
Diffstat (limited to 'compiler/llvmGen')
-rw-r--r-- | compiler/llvmGen/LlvmCodeGen/Ppr.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen/Ppr.hs b/compiler/llvmGen/LlvmCodeGen/Ppr.hs index ed21685b55..5dd27ab33b 100644 --- a/compiler/llvmGen/LlvmCodeGen/Ppr.hs +++ b/compiler/llvmGen/LlvmCodeGen/Ppr.hs @@ -68,9 +68,19 @@ moduleLayout = sdocWithPlatform $ \platform -> Platform { platformArch = ArchARM64, platformOS = OSiOS } -> text "target datalayout = \"e-p:64:64:64-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:128:128-a0:0:64-n32:64-S128\"" $+$ text "target triple = \"arm64-apple-ios7.0.0\"" + Platform { platformArch = ArchARM64, platformOS = OSLinux } -> + text "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"" + $+$ text "target triple = \"aarch64-unknown-linux-gnu\"" _ -> - -- FIX: Other targets - empty + if platformIsCrossCompiling platform + then panic "LlvmCodeGen.Ppr: Cross compiling without valid target info." + else empty + -- If you see the above panic, GHC is missing the required target datalayout + -- and triple information. You can obtain this info by compiling a simple + -- 'hello world' C program with the clang C compiler eg: + -- clang hello.c -emit-llvm -o hello.ll + -- and the first two lines of hello.ll should provide the 'target datalayout' + -- and 'target triple' lines required. -- | Pretty print LLVM data code |