[clang] [Driver] Mark -arch as TargetSpecific (PR #74365)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 16:47:29 PST 2023


MaskRay wrote:

When the target triple is aarch64 and `-arch ` is specified, e.g. `--target=aarch64 -arch arm64e`, there is currently no warning/error, because `clang/lib/Driver/ToolChains/Arch/AArch64.cpp` claims `OPT_arch` in quite a few places.
We can safely remove these references now that https://reviews.llvm.org/D55731 has checked `isOSDarwin` (which covers macOS/iOS/watchOS/DriverKit).

> Are we supposed to pass -target to clang in addition to -arch if we want to be sure to compile with Apple's triple?

If the default target triple is not Apple's triple, `--target=` is required. `clang -arch arm64` without `--target=` does not work.
This is the desired behavior.

> It might be reasonable, but in such case many tests which use -arch without -target actually might run with undesired non-Apple triple - I find such behavior a bit misleading. Is this "by design"?

These tests need to be fixed to specify `--target=` if it may run on a non-Apple target.
It's possible that `-arch ` is redundant with `--target=`.


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


More information about the cfe-commits mailing list