Skip to content

Commit 4e0275a

Browse files
authored
[Driver] Mark -arch as TargetSpecific (llvm#74365)
`-arch` is a Darwin-specific option that is ignored for other targets and not known by GCC. ``` % clang -arch arm64 -c a.c clang: warning: argument unused during compilation: '-arch arm64' [-Wunused-command-line-argument] ``` We are utilizing TargetSpecific (from https://reviews.llvm.org/D151590) to make more options lead to errors for unsupported targets.
1 parent 323451a commit 4e0275a

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ def all__load : Flag<["-"], "all_load">;
994994
def allowable__client : Separate<["-"], "allowable_client">;
995995
def ansi : Flag<["-", "--"], "ansi">, Group<CompileOnly_Group>;
996996
def arch__errors__fatal : Flag<["-"], "arch_errors_fatal">;
997-
def arch : Separate<["-"], "arch">, Flags<[NoXarchOption]>;
997+
def arch : Separate<["-"], "arch">, Flags<[NoXarchOption,TargetSpecific]>;
998998
def arch__only : Separate<["-"], "arch_only">;
999999
def autocomplete : Joined<["--"], "autocomplete=">;
10001000
def bind__at__load : Flag<["-"], "bind_at_load">;

clang/test/Driver/arc-exceptions.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang -### -x objective-c -arch x86_64 -fobjc-arc -fsyntax-only %s 2> %t.log
1+
// RUN: %clang -### -x objective-c --target=x86_64-apple-macos10.6 -fobjc-arc -fsyntax-only %s 2> %t.log
22
// RUN: grep objective-c %t.log
33
// RUN: not grep "fobjc-arc-exceptions" %t.log
4-
// RUN: %clang -### -x objective-c++ -arch x86_64 -fobjc-arc -fsyntax-only %s 2> %t.log
4+
// RUN: %clang -### -x objective-c++ --target=x86_64-apple-macos10.6 -fobjc-arc -fsyntax-only %s 2> %t.log
55
// RUN: grep "fobjc-arc-exceptions" %t.log

clang/test/Driver/arm-arch-darwin.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// On Darwin, arch should override CPU for triple purposes
22
// RUN: %clang -target armv7m-apple-darwin -arch armv7m -mcpu=cortex-m4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7M-DARWIN %s
33
// CHECK-V7M-DARWIN: "-cc1"{{.*}} "-triple" "thumbv7m-{{.*}} "-target-cpu" "cortex-m4"
4-
// RUN: %clang -target armv7m -arch armv7m -mcpu=cortex-m4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7M-OVERRIDDEN %s
5-
// CHECK-V7M-OVERRIDDEN: "-cc1"{{.*}} "-triple" "thumbv7em-{{.*}} "-target-cpu" "cortex-m4"
64

5+
/// -arch is unsupported for non-Darwin targets.
6+
// RUN: not %clang --target=armv7m -arch armv7m -mcpu=cortex-m4 -### -c %s 2>&1 | FileCheck -check-prefix=ERR %s
7+
// ERR: unsupported option '-arch' for target 'armv7m'

clang/test/Frontend/darwin-eabi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %clang -arch armv6m -dM -E %s | FileCheck %s
2-
// RUN: %clang -arch armv7m -dM -E %s | FileCheck %s
3-
// RUN: %clang -arch armv7em -dM -E %s | FileCheck %s
1+
// RUN: %clang --target=armv6m-apple-darwin -dM -E %s | FileCheck %s
2+
// RUN: %clang --target=armv7m-apple-darwin -dM -E %s | FileCheck %s
3+
// RUN: %clang --target=armv7em-apple-darwin -dM -E %s | FileCheck %s
44
// RUN: %clang_cc1 -triple thumbv7m-apple-unknown-macho -dM -E %s | FileCheck %s
55

66
// CHECK-NOT: __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__

0 commit comments

Comments
 (0)