[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 00:15:44 PDT 2024


mstorsjo wrote:

This broke things for non-darwin targets.

`clang --print-target-triple` is used to evaluate the arch to use for e.g. compiler-rt builtins, and for getting the right subdirectory for per-target runtime directories.

Previously, `clang -target armv7-windows-gnu --print-target-triple` used to output `armv7-unknown-windows-gnu`, while it now outputs `thumbv7-unknown-windows-gnu`. (The `--print-effective-triple` option has printed `thumbv7-unknown-windows-gnu` consistently all the time though.) Making `--print-target-triple` print a `thumbv7` triple makes compiler-rt not build any builtins/runtimes for that, since that arch name is unrecognized there. (I also remember looking into making compiler-rt support `thumbv7` as architecture name, when some normalization attempted to use `--print-effective-triple` at some point, but iirc it wasn't a clear cut thing to do.)

Additionally, having `--print-target-triple` output `thumbv7-unknown-windows-gnu` is wrong when the driver in fact will look for per-target runtimes in a subdirectory named `armv7-unknown-windows-gnu` (this is what the driver printed as path when it failed to find runtimes after this change).

Darwin targets don't use the per-target runtime directory, but if they would do, I doubt that having the OS version appended on those directories would be the right thing to do...

---

Thus, I request we revert this (and will push a revert later today unless we agree on something else) - this breaks things way outside of what was intended in the change itself.

(I don't have a strong opinion on whether the initialization should be kept only for darwin targets, or if a different option than `--print-target-triple` should be used for conveying such things. In one sense, `--print-effective-triple` maybe would be more appropriate? For the arm vs thumb case, that does print the actual `thumbv7` arch already, but for the darwin targets, it doesn't include the OS version right now.)

https://github.com/llvm/llvm-project/pull/104037


More information about the cfe-commits mailing list