iphone + LDC, a new ARM adventure
Dan Olson
zans.is.for.cans at yahoo.com
Sat Jan 4 13:56:26 PST 2014
Compiling LDC for iphone ARM. Running into expected problems, but
thought I'd post status so I am not working in a vacuum. I am new to
building LLVM as of this week so more likely to miss configuration
options.
During the LDC build, druntime and phobos run into a few problems (3
types of error), which don't suprise me because I don't think many have
tried this combo yet (arm-apple-darwin). However, I can compile a simple
standalone .d file to .o and link it into an xcode iphone arm project
and run it on hardware.
First class of error I run into is exception based. Any code that needs
to handle exceptions gets this:
Assertion failed: (getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"), function AssertOK, file /Users/dan/projects/ldc/llvm-3.3.src/lib/IR/Instructions.cpp, line 1084.
... snip
0. Running pass 'SJLJ Exception Handling preparation' on function '@_D4core8demangle8Demangle9parseTypeMFAaZAa'
/bin/sh: line 1: 53946 Illegal instruction: 4 /Users/dan/projects/ldc/buildldc-3.3-hacked-armv7/bin/ldc2 --output-o -c -I/Users/dan/projects/ldc/ldc-0.12.1-src/runtime/druntime/src -I/Users/dan/projects/ldc/ldc-0.12.1-src/runtime/druntime/src/gc /Users/dan/projects/ldc/ldc-0.12.1-src/runtime/druntime/src/core/demangle.d -of/Users/dan/projects/ldc/buildldc-3.3-hacked-armv7/runtime/src/core/demangle.o -w -d -march=thumb -relocation-model=static -O3 -release -disable-invariants
Any thoughts?
Dan
----
Build machine is Lion using clang x86_64-apple-darwin12.5.0
I tried various LLVM --target configurations (arm, armv7,
x86-apple-darwin), but they do not seem to make a difference in the
resulting ldc2. LLVM 3.3 yields fewer errors when build druntime than
3.2. Both give me the same exception error above.
I am using -march=thumb -relocation-model=static as I seem to encounter
fewer llvm failures with these flags. I updated
ldc-0.12.1-src/runtime/CMakeLists.txt and changed D_FLAGS to include
these.
The compiler reports this:
/Users/dan/projects/ldc/buildldc-3.3-hacked-armv7/bin/ldmd2 -help
LDC - the LLVM D compiler (0.12.0):
based on DMD v2.063.2 and LLVM 3.3
Default target: armv7-apple-darwin12.5.0
Host CPU: corei7-avx
http://dlang.org - http://wiki.dlang.org/LDC
Registered Targets:
aarch64 - AArch64
arm - ARM
cpp - C++ backend
hexagon - Hexagon
mblaze - MBlaze
mips - Mips
mips64 - Mips64 [experimental]
mips64el - Mips64el [experimental]
mipsel - Mipsel
msp430 - MSP430 [experimental]
nvptx - NVIDIA PTX 32-bit
nvptx64 - NVIDIA PTX 64-bit
ppc32 - PowerPC 32
ppc64 - PowerPC 64
sparc - Sparc
sparcv9 - Sparc V9
systemz - SystemZ
thumb - Thumb
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
xcore - XCore
Background:
About a year ago, I worked and gave up on making gdc build druntime and
phobos for iphone (ios arm). I could get a simple standalone D function
to run on an iphone but no further.
http://www.digitalmars.com/d/archives/D/gnu/iphone_D_getting_closer_4788.html
The problem was that gcc-4.8 had no support for iphone and the latest
sources that apple released were for gcc-4.2. I tried in vain to merge
the iphone changes into 4.8, but it was a losing battle.
I have always wanted to continue this adventure, trying LDC. Apple is
all clang/LLVM now and seems to be pushing out some of their LLVM
updates. So seems LDC is way to go!
More information about the digitalmars-d-ldc
mailing list