[clang] [clang][driver] Fix -print-target-triple OS version for apple targets (PR #104037)
Martin Storsjö via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 16 13:59:21 PDT 2024
mstorsjo wrote:
> @mstorsjo I think you put the finger on something I don't really understand at the moment. What is the relationship between `armv7` and `thumbv7` as a target triple? Is there any documentation on what an "effective triple" is in comparison to a "non-effective triple"?
Sorry, I'm not sure if there's any formal definition of what Clang considers `--print-effective-triple` vs `--print-target-triple`, neither is exactly what is input. So far, the output of `--print-target-triple` used to be _exactly_ the directory name used for per-target runtime subdirectories, but with this change, it no longer was that.
> Separately from this, we noticed that `clang -target armv7k-apple-watchos` would pass `-target thumbv7-apple-watchos` to the frontend, but using `clang -target thumbv7-apple-watchos` directly in the driver doesn't work. Is `thumbv7-apple-watchos` the "effective" triple of `armv7k-apple-watchos`? Why do both spellings exist, and what is each spelling used for?
I think `thumbv7-apple-watchos` may be the effective triple of `armv7k-apple-watchos` yes - whatever that means.
As a brief background: For the 32 bit ARM execution mode, you can have instructions in two different forms - "ARM" mode, where each instruction is 32 bit, and Thumb mode, where each instruction is 16 bit. Some ARM environments can only execute ARM mode code, some environments can mix both, and some can only have Thumb. Those that can mix, can essentially do this on a per-function basis (so in a single assembly file, you could have some functions be ARM and some be Thumb).
Then, I guess the situation is, when generating code, we output only one or another - and in the lower level LLVM layers, I guess the switch between the two is done by using either an `arm*` or `thumb*` triple. But on the higher levels, things mostly expect to work with triples in the form `arm*` and aren't really expecting to see the `thumb*` triples.
(FWIW, on the topic of whether lower level triples can be fed back to clang as the `-target` argument - Darwin is kinda special in that regard for other architectures as well. E.g. for aarch64, the effective/internal triple is `aarch64-*`, but on the Clang driver level, you're mostly supposed to call it `arm64-*`.)
https://github.com/llvm/llvm-project/pull/104037
More information about the cfe-commits
mailing list