Bad arm -O0 codegen (was Re: Hope d has great development in Raspberry Pi)

Dan Olson via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Fri Feb 5 23:01:51 PST 2016


Dan Olson <gorox at comcast.net> writes:

> Joakim <dlang at joakim.fea.st> writes:
>> I tried it out a couple summers ago, following in your footsteps with
>> iOS, and Kai and I ran into the same issue, though we didn't look into
>> the codegen like you have:
>>
>> http://forum.dlang.org/post/rdrhocrqfldcanrqxlgz@forum.dlang.org
>
> I didn't realize the history.  That's a long time ago.  I never ran into
> this specific problem because it seems to be unique to gnueabi targets,
> and only -relocation-model=dynamic-no-pic (the default for
> arm-linux-gnueabih).
>
> The problem is still in LLVM 3.8.
>
> I also found using triple thumb-linux-gnueabihf sidesteps this problem.
> Trying thumb on Pi (armv6) was good because I discovered that druntime
> is missing thumb support (original, not thumb-2) and am preparing a PR.
>
> I still think immediate solution for LDC is to see what clang is doing.
> We may have some wrong target options.

Follow up: -relocation-model=dynamic-no-pic is all wrong.  Clang even
emits an error if you try to use it on any other OS than darwin.

$ clang++ -target arm-linux-gnueabihf -S -c fun.cpp -O0 -mdynamic-no-pic
clang: error: unsupported option '-mdynamic-no-pic' for target 'arm--linux-gnueabihf'

The source is tools/clang/lib/Driver/Tools.cpp function ParsePICArgs():

  if (Arg *A = Args.getLastArg(options::OPT_mdynamic_no_pic)) {
    // This is a very special mode. It trumps the other modes, almost no one
    // uses it, and it isn't even valid on any OS but Darwin.
    if (!ToolChain.getTriple().isOSDarwin())
      ToolChain.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
          << A->getSpelling() << ToolChain.getTriple().str();

There is a disconnect because llvm chooses dynamic-no-pic as default for
all except darwin in lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp.
That is really backwards.  At least there is an explanation and now a
fix.
-- 
Dan


More information about the digitalmars-d-ldc mailing list