[llvm-dev] [CLANG BUG] Generate ELF for aarch64-apple-iphoneos

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 13 09:47:12 PDT 2017


On 12 March 2017 at 17:21, Moritz Angermann <moritz.angermann at gmail.com> wrote:
> What’s the recommended approach to be taken from llvms point of view?
> with -arch and -march?

Well, -arch is used when Clang thinks it's targeting Darwin platforms,
and -march is used on ELF (they don't mix). Of course it gets messy
because each of those view what's being specified slightly
differently.

Roughly, Darwin thinks that -target covers the general Appleish
platform and how other command-line args should be interpreted, and
you should use -arch to specify the CPU type and the version-min
arguments to specify the OS. ELF thinks that all of those should be
covered by -target (and ignores -arch).

So if Clang didn't have any default, you might see this on Darwin:

    clang -target unknown-apple-darwin -arch arm64 -mios-version-min=10.0 ...

But for ELF:

    clang -target aarch64-linux-gnu ...

Of course, the Clang that comes with XCode knows it should default to
Darwin (as would any Clang built on macOS unless you specifically
changed it). So usually -target is omitted in the first line.

Finally, -march is used on ELF to select the sub-variant being
compiled for (e.g. v7, v8, v8.1 of the ARM architecture, or x86
variants).

> How would I differentiate macosx, ios, watchos then?

You'd do this via -mios-version-min, -mwatchos-verison-min and
-mmacosx-version-min arguments, in addition to an appropriate -arch.

> What would I set for aarch64-unknown-linux-android instead of the target?

That would be the -target option.

>> Darwin provides a limited set of named configurations rather than
>> using triples directly. The canonical way to compile for AArch64 there
>> is by specifying "-arch arm64" instead of -target.
>
> Is there some difference between aarch64 and arm64?

Nope (or at least there shouldn't be). ARM decided that the official
name for their 64-bit operation mode would be AArch64 rather than the
more natural ARM64 (I heard rumours it was for trademark reasons, but
that's pure speculation). Projects and companies went along with this
to varying degrees, and Clang has to support both camps.

> Thank you. That makes sense! Can I ask clang for the supported architectures then?

I'm afraid not. llc gives you that information with "-version", but
Clang doesn't. It wouldn't be a bad addition though (probably).

Cheers.

Tim.


More information about the llvm-dev mailing list