[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Recommitted with a fix for the M1  openMP issue:

To https://github.com/llvm/llvm-project.git

  3aaac01aab2f..6b938d2ead2c  main -> main


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D100807#2720277 , @thakis wrote:

> In D100807#2719873 , @arphaman 
> wrote:
>
>> We have M1  CI running internally but it's post 
>> commit only right now
>
> Which tests is it running?

We run check-all for our enabled projects, so that has things like check-clang 
and check-llvm.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D100807#2719873 , @arphaman wrote:

> We have M1  CI running internally but it's post 
> commit only right now

Which tests is it running?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-27 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D100807#2719561 , @thakis wrote:

> In D100807#2718006 , @arphaman 
> wrote:
>
>> It appears that your bot is running on a Mac with M1 
>>  is that correct? Which OS do you have 
>> installed? Thanks
>
> Correct, it's an M1  Mini. I had to get 
> check-clang and check-llvm to pass on M1  
> (PR46647, PR46644) so it looks like nobody else is running this config (why 
> not?). check-builtins is e.g. still failing (PR49918). Kind of on that note, 
> the clang y'all ship with Xcode is > 5% slower than it needs to be due to you 
> apparently building it with profiles collected on an intel machine instead of 
> with profiles collected on an arm machine (data: 
> https://bugs.chromium.org/p/chromium/issues/detail?id=1103322#c34 There's a 
> prebuilt binary at 
> http://commondatastorage.googleapis.com/chromium-browser-clang/Mac_arm64/clang-llvmorg-13-init-7296-ga749bd76-2.tgz
>  with profiles collected on arm that is ~ 12.5% faster than Xcode's clang, 
> see comment 29 on that same crbug).
>
> The bot is running macOS 11.3 IIRC.

We have M1  CI running internally but it's post 
commit only right now (that's something we're hoping to change in the future), 
so this would've been caught in our internal CI. I didn't verify this specific 
patch on an M1  myself though, which is something 
that's probably a good idea to do going forward for driver changes. I didn't 
know there's another M1  bot running in the open 
so I will be mindful of it :)

Thanks for the pointer, I'll take a look the profile data issue, and we will 
work on rectifying it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D100807#2718006 , @arphaman wrote:

> It appears that your bot is running on a Mac with M1 
>  is that correct? Which OS do you have 
> installed? Thanks

Correct, it's an M1  Mini. I had to get 
check-clang and check-llvm to pass on M1  
(PR46647, PR46644) so it looks like nobody else is running this config (why 
not?). check-builtins is e.g. still failing (PR49918). Kind of on that note, 
the clang y'all ship with Xcode is > 5% slower than it needs to be due to you 
apparently building it with profiles collected on an intel machine instead of 
with profiles collected on an arm machine (data: 
https://bugs.chromium.org/p/chromium/issues/detail?id=1103322#c34 There's a 
prebuilt binary at 
http://commondatastorage.googleapis.com/chromium-browser-clang/Mac_arm64/clang-llvmorg-13-init-7296-ga749bd76-2.tgz
 with profiles collected on arm that is ~ 12.5% faster than Xcode's clang, see 
comment 29 on that same crbug).

The bot is running macOS 11.3 IIRC.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Reverted in ab0df6c0346e 
 for now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D100807#2717778 , @thakis wrote:

> Looks like this breaks tests on mac/arm (by making two unexpectedly pass): 
> http://45.33.8.238/macm1/8249/step_7.txt
>
> Please take a look, and please revert for now if it takes a while to fix.

I will revert it now.

It appears that your bot is running on a Mac M1  
is that correct? Which OS do you have installed? Thanks


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D100807#2717778 , @thakis wrote:

> Looks like this breaks tests on mac/arm (by making two unexpectedly pass): 
> http://45.33.8.238/macm1/8249/step_7.txt
>
> Please take a look, and please revert for now if it takes a while to fix.

Thanks, I will take a look.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-26 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on mac/arm (by making two unexpectedly pass): 
http://45.33.8.238/macm1/8249/step_7.txt

Please take a look, and please revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-26 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6cc62043c8bf: [clang][driver] Use the provided arch name for 
a Darwin target triple (authored by arphaman).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm64_32-link.c
  clang/test/Driver/darwin-version.c
  clang/test/Driver/default-toolchain.c


Index: clang/test/Driver/default-toolchain.c
===
--- clang/test/Driver/default-toolchain.c
+++ clang/test/Driver/default-toolchain.c
@@ -6,3 +6,6 @@
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t
 // RUN: grep 'Target: powerpc-apple-darwin9' %t
+
+// RUN: %clang -target x86_64-apple-macos11 -arch arm64 -v 2>&1 | FileCheck 
--check-prefix=ARM64 %s
+// ARM64: Target: arm64-apple-macos11
Index: clang/test/Driver/darwin-version.c
===
--- clang/test/Driver/darwin-version.c
+++ clang/test/Driver/darwin-version.c
@@ -60,17 +60,17 @@
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
-// CHECK-VERSION-OSX4: "i386-apple-macosx10.4.0"
+// CHECK-VERSION-OSX4: "i686-apple-macosx10.4.0"
 // RUN: %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.5 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
-// CHECK-VERSION-OSX5: "i386-apple-macosx10.5.0"
+// CHECK-VERSION-OSX5: "i686-apple-macosx10.5.0"
 // RUN: %clang -target i686-apple-darwin10 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX6 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.6 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX6 %s
-// CHECK-VERSION-OSX6: "i386-apple-macosx10.6.0"
+// CHECK-VERSION-OSX6: "i686-apple-macosx10.6.0"
 // RUN: %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
 // RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.10 -c %s 
-### 2>&1 | \
@@ -100,7 +100,7 @@
 
 // Check environment variable gets interpreted correctly
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
-// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
 // RUN:   %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
Index: clang/test/Driver/arm64_32-link.c
===
--- clang/test/Driver/arm64_32-link.c
+++ clang/test/Driver/arm64_32-link.c
@@ -1,4 +1,4 @@
 // RUN: %clang -target x86_64-apple-darwin -arch arm64_32 
-miphoneos-version-min=8.0 %s -### 2>&1 | FileCheck %s
 
-// CHECK: "-cc1"{{.*}} "-triple" "aarch64_32-apple-ios8.0.0"
+// CHECK: "-cc1"{{.*}} "-triple" "arm64_32-apple-ios8.0.0"
 // CHECK: ld{{.*}} "-arch" "arm64_32"
Index: clang/test/Driver/aarch64-cpus.c
===
--- clang/test/Driver/aarch64-cpus.c
+++ clang/test/Driver/aarch64-cpus.c
@@ -33,7 +33,7 @@
 // ARM64E-DARWIN: "-cc1"{{.*}} "-triple" "arm64e{{.*}}" "-target-cpu" 
"apple-a12"
 
 // RUN: %clang -target arm64-apple-darwin -arch arm64_32 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64_32-DARWIN %s
-// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "aarch64_32{{.*}}" "-target-cpu" 
"apple-s4"
+// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "arm64_32{{.*}}" "-target-cpu" 
"apple-s4"
 
 // RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA35 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -74,12 +74,12 @@
   const llvm::Triple::ArchType Arch = getArchTypeForMachOArchName(Str);
   llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(Str);
   T.setArch(Arch);
-
-  if (Str == "x86_64h" || Str == "arm64e")
+  if (Arch != llvm::Triple::UnknownArch)
 T.setArchName(Str);
-  else if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
-   ArchKind == llvm::ARM::ArchKind::ARMV7M ||
-   ArchKind == llvm::ARM::ArchKind::ARMV7EM) {
+
+  if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
+  ArchKind == 

[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-26 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab accepted this revision.
ab added a comment.
This revision is now accepted and ready to land.

Neat, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D100807#2702675 , @ab wrote:

> This sounds nice!  One idea, maybe more dangerous, not sure which is better:  
> in `setTripleTypeForMachOArchName`, we already have a couple `setArchName` 
> calls, I think that's why `arm64e` is left alone in the `aarch64-cpus.c` 
> test.  Maybe we can do the `setArchName` call for every arch there?

Thanks for the suggestion! I like your idea better, so I updated the patch.

> Another question, probably a completely separate problem: why is it still 
> reporting darwin?  Ideally we'd want it to report macos, right?  With that + 
> your change the triple there would be the actual triple we use to build.  
> (but maybe the macos bit only comes later when we pick up an SDK in 
> DarwinClang or whatever?)

I think that's the default we set in the build. I do want to get rid of the 
'Darwin' triple OS and just leave it as an alias for the driver at some point 
in the future as I don't think it's serving a good purpose anymore, but I 
haven't gotten around to it. I can explore using 'macOS' triples for the build 
before then though.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 339027.
arphaman added a comment.

Updated with Ahmed's suggestion.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm64_32-link.c
  clang/test/Driver/darwin-version.c
  clang/test/Driver/default-toolchain.c


Index: clang/test/Driver/default-toolchain.c
===
--- clang/test/Driver/default-toolchain.c
+++ clang/test/Driver/default-toolchain.c
@@ -6,3 +6,6 @@
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t
 // RUN: grep 'Target: powerpc-apple-darwin9' %t
+
+// RUN: %clang -target x86_64-apple-macos11 -arch arm64 -v 2>&1 | FileCheck 
--check-prefix=ARM64 %s
+// ARM64: Target: arm64-apple-macos11
Index: clang/test/Driver/darwin-version.c
===
--- clang/test/Driver/darwin-version.c
+++ clang/test/Driver/darwin-version.c
@@ -60,17 +60,17 @@
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
-// CHECK-VERSION-OSX4: "i386-apple-macosx10.4.0"
+// CHECK-VERSION-OSX4: "i686-apple-macosx10.4.0"
 // RUN: %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.5 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
-// CHECK-VERSION-OSX5: "i386-apple-macosx10.5.0"
+// CHECK-VERSION-OSX5: "i686-apple-macosx10.5.0"
 // RUN: %clang -target i686-apple-darwin10 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX6 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.6 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX6 %s
-// CHECK-VERSION-OSX6: "i386-apple-macosx10.6.0"
+// CHECK-VERSION-OSX6: "i686-apple-macosx10.6.0"
 // RUN: %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
 // RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.10 -c %s 
-### 2>&1 | \
@@ -100,7 +100,7 @@
 
 // Check environment variable gets interpreted correctly
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
-// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
 // RUN:   %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
Index: clang/test/Driver/arm64_32-link.c
===
--- clang/test/Driver/arm64_32-link.c
+++ clang/test/Driver/arm64_32-link.c
@@ -1,4 +1,4 @@
 // RUN: %clang -target x86_64-apple-darwin -arch arm64_32 
-miphoneos-version-min=8.0 %s -### 2>&1 | FileCheck %s
 
-// CHECK: "-cc1"{{.*}} "-triple" "aarch64_32-apple-ios8.0.0"
+// CHECK: "-cc1"{{.*}} "-triple" "arm64_32-apple-ios8.0.0"
 // CHECK: ld{{.*}} "-arch" "arm64_32"
Index: clang/test/Driver/aarch64-cpus.c
===
--- clang/test/Driver/aarch64-cpus.c
+++ clang/test/Driver/aarch64-cpus.c
@@ -33,7 +33,7 @@
 // ARM64E-DARWIN: "-cc1"{{.*}} "-triple" "arm64e{{.*}}" "-target-cpu" 
"apple-a12"
 
 // RUN: %clang -target arm64-apple-darwin -arch arm64_32 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64_32-DARWIN %s
-// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "aarch64_32{{.*}}" "-target-cpu" 
"apple-s4"
+// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "arm64_32{{.*}}" "-target-cpu" 
"apple-s4"
 
 // RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA35 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -74,12 +74,12 @@
   const llvm::Triple::ArchType Arch = getArchTypeForMachOArchName(Str);
   llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(Str);
   T.setArch(Arch);
-
-  if (Str == "x86_64h" || Str == "arm64e")
+  if (Arch != llvm::Triple::UnknownArch)
 T.setArchName(Str);
-  else if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
-   ArchKind == llvm::ARM::ArchKind::ARMV7M ||
-   ArchKind == llvm::ARM::ArchKind::ARMV7EM) {
+
+  if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
+  ArchKind == llvm::ARM::ArchKind::ARMV7M ||
+  ArchKind == llvm::ARM::ArchKind::ARMV7EM) {
 T.setOS(llvm::Triple::UnknownOS);
 

[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-20 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab added a comment.

This sounds nice!  One idea, maybe more dangerous, not sure which is better:  
in `setTripleTypeForMachOArchName`, we already have a couple `setArchName` 
calls, I think that's why `arm64e` is left alone in the `aarch64-cpus.c` test.  
Maybe we can do the `setArchName` call for every arch there?

Another question, probably a completely separate problem: why is it still 
reporting darwin?  Ideally we'd want it to report macos, right?  With that + 
your change the triple there would be the actual triple we use to build.  (but 
maybe the macos bit only comes later when we pick up an SDK in DarwinClang or 
whatever?)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100807/new/

https://reviews.llvm.org/D100807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: ab, t.p.northover.
Herald added subscribers: ributzka, kristof.beyls.
arphaman requested review of this revision.
Herald added a project: clang.

Clang's driver currently prints out different default triples when it's invoked 
like this on Apple Silicon:

  $ clang --version
  Target: arm64-apple-darwin19.0.0
  $ clang -arch arm64 --version
  Target: aarch64-apple-darwin19.0.0

This change ensures that the driver uses the canonical arch names for a Darwin 
triple when the target triple is being printed out by the driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100807

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm64_32-link.c
  clang/test/Driver/default-toolchain.c


Index: clang/test/Driver/default-toolchain.c
===
--- clang/test/Driver/default-toolchain.c
+++ clang/test/Driver/default-toolchain.c
@@ -2,7 +2,10 @@
 // RUN: grep 'Target: x86_64-unknown-unknown' %t
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc -m64 -v 2> %t
-// RUN: grep 'Target: powerpc64-apple-darwin9' %t
+// RUN: grep 'Target: ppc64-apple-darwin9' %t
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t
-// RUN: grep 'Target: powerpc-apple-darwin9' %t
+// RUN: grep 'Target: ppc-apple-darwin9' %t
+
+// RUN: %clang -target x86_64-apple-macos11 -arch arm64 -v 2>&1 | FileCheck 
--check-prefix=ARM64 %s
+// ARM64: Target: arm64-apple-macos11
Index: clang/test/Driver/arm64_32-link.c
===
--- clang/test/Driver/arm64_32-link.c
+++ clang/test/Driver/arm64_32-link.c
@@ -1,4 +1,4 @@
 // RUN: %clang -target x86_64-apple-darwin -arch arm64_32 
-miphoneos-version-min=8.0 %s -### 2>&1 | FileCheck %s
 
-// CHECK: "-cc1"{{.*}} "-triple" "aarch64_32-apple-ios8.0.0"
+// CHECK: "-cc1"{{.*}} "-triple" "arm64_32-apple-ios8.0.0"
 // CHECK: ld{{.*}} "-arch" "arm64_32"
Index: clang/test/Driver/aarch64-cpus.c
===
--- clang/test/Driver/aarch64-cpus.c
+++ clang/test/Driver/aarch64-cpus.c
@@ -33,7 +33,7 @@
 // ARM64E-DARWIN: "-cc1"{{.*}} "-triple" "arm64e{{.*}}" "-target-cpu" 
"apple-a12"
 
 // RUN: %clang -target arm64-apple-darwin -arch arm64_32 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64_32-DARWIN %s
-// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "aarch64_32{{.*}}" "-target-cpu" 
"apple-s4"
+// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "arm64_32{{.*}}" "-target-cpu" 
"apple-s4"
 
 // RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA35 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -237,7 +237,13 @@
   StringRef getDefaultUniversalArchName() const;
 
   std::string getTripleString() const {
-return Triple.getTriple();
+if (!Triple.isOSDarwin())
+  return Triple.getTriple();
+// Use the default architecture name (that's expected by -arch) for a
+// Darwin triple to provide consistent triple output to the user.
+llvm::Triple TT = Triple;
+TT.setArchName(getDefaultUniversalArchName());
+return TT.getTriple();
   }
 
   /// Get the toolchain's effective clang triple.


Index: clang/test/Driver/default-toolchain.c
===
--- clang/test/Driver/default-toolchain.c
+++ clang/test/Driver/default-toolchain.c
@@ -2,7 +2,10 @@
 // RUN: grep 'Target: x86_64-unknown-unknown' %t
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc -m64 -v 2> %t
-// RUN: grep 'Target: powerpc64-apple-darwin9' %t
+// RUN: grep 'Target: ppc64-apple-darwin9' %t
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t
-// RUN: grep 'Target: powerpc-apple-darwin9' %t
+// RUN: grep 'Target: ppc-apple-darwin9' %t
+
+// RUN: %clang -target x86_64-apple-macos11 -arch arm64 -v 2>&1 | FileCheck --check-prefix=ARM64 %s
+// ARM64: Target: arm64-apple-macos11
Index: clang/test/Driver/arm64_32-link.c
===
--- clang/test/Driver/arm64_32-link.c
+++ clang/test/Driver/arm64_32-link.c
@@ -1,4 +1,4 @@
 // RUN: %clang -target x86_64-apple-darwin -arch arm64_32 -miphoneos-version-min=8.0 %s -### 2>&1 | FileCheck %s
 
-// CHECK: "-cc1"{{.*}} "-triple" "aarch64_32-apple-ios8.0.0"
+// CHECK: "-cc1"{{.*}} "-triple" "arm64_32-apple-ios8.0.0"
 // CHECK: ld{{.*}} "-arch" "arm64_32"
Index: clang/test/Driver/aarch64-cpus.c
===
--- clang/test/Driver/aarch64-cpus.c
+++ clang/test/Driver/aarch64-cpus.c
@@ -33,7 +33,7 @@
 //