iphone + LDC, a new ARM adventure

Dan Olson zans.is.for.cans at yahoo.com
Tue Feb 11 23:18:35 PST 2014


David Nadlinger <code at klickverbot.at> writes:

> On Mon, Feb 10, 2014 at 5:39 PM, Dan Olson
> <zans.is.for.cans at yahoo.com> wrote> Works
>> ../buildldc/bin/ldc2 -c ../ldc-git/runtime/druntime/src/core/demangle.d -mtriple=thumbv7-apple-darwin -float-abi=softfp -O
>>
>> Fails
>> ../buildldc/bin/ldc2 -c ../ldc-git/runtime/druntime/src/core/demangle.d -mtriple=thumbv7-apple-darwin -O
>>
>> […]
>>
>> It has something to do with TargetOptions UseSoftFloat = 1.
>>
>> I can file an issue if you like.  Perhaps it is an llvm bug though.
>
> Ah, yes, that's not really surprising. Unimplemented floating point
> lowerings tend to be responsible for a good share of strange error
> messages when targeting non-x86 platforms with LLVM, in my experience.
>
> The decision whether to use "soft", "softfp" or "hard" by default is
> (unfortunately) made in the LDC driver code, based on the target
> triple: https://github.com/ldc-developers/ldc/blob/master/driver/targetmachine.cpp.
> The logic is supposed to mirror what Clang does, but maybe I missed
> something. I'd definitely double-check the behavior against Clang,
> although this should really be moved into an LLVM support library –
> every flexible ARM compiler is going to need something similar.
>
> Another potential cause is that "thumbv7-apple-darwin" might not be
> the right target triple for iOS (thus leading to hardware floating
> point support being incorrectly disabled), but I'd have to reboot into
> OS X to check right now.

Hi David,

Clang does a bunch of munging of the -target it is handed.  It seems
very extensive for darwin targets with many special cases.  I discovered
a couple weeks ago that clang converts -target armv7-apple-darwin into
-triple thumbv7-apple-ios5.0.0.  I later found in an article that iOS
prefers thumb2 to minimize code size.  So that is why I suppose armv7 is
converted to thumbv7.  Anyway, I was curious just now so looked through
clang/lib/Driver/ToolChains.pp and found
Darwin::ComputeEffectiveClangTriple() is where the conversion is.

and

ToolChain::ComputeLLVMTriple()
    ...
    // Thumb2 is the default for V7 on Darwin.

elsewhere

tools::arm::getARMFloatABI()
   ...
      // Darwin defaults to "softfp" for v6 and v7.

For now I am just fine with having to tell ldc2 to use

-mtriple=thumbv7-apple-ios5.0.0 -float-abi=softfp

It works.

I am hoping to get changes up to an ldc github fork soon along with
build instructions and some sample apps.  Being new to git/github, there
is a bit for me to learn about best practices for forks and submodules.
For example, my instinct would be to put any example apps, scripts, and
notes in the forked repo, but looking at others forked repos, it seems
like they don't do that.

P.S. I did have to add llvm::Triple::IOS to ldc main.cpp in the switch
that sets D versions.  So far very few changes to ldc to get D breathing
on iOS.
-- 
Dan


More information about the digitalmars-d-ldc mailing list