[clang] b541845 - [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 13 12:56:02 PDT 2021


Author: Martin Storsjö
Date: 2021-10-13T22:55:00+03:00
New Revision: b541845ea082d1dfca53074b4353e1ee0c22dd76

URL: https://github.com/llvm/llvm-project/commit/b541845ea082d1dfca53074b4353e1ee0c22dd76
DIFF: https://github.com/llvm/llvm-project/commit/b541845ea082d1dfca53074b4353e1ee0c22dd76.diff

LOG: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

This doesn't practically affect the code generation.

Differential Revision: https://reviews.llvm.org/D111707

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/MSVC.cpp
    clang/lib/Driver/ToolChains/MinGW.cpp
    clang/test/Driver/pic.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp
index 046ef8024c6e4..5b7600493893e 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -795,7 +795,8 @@ bool MSVCToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
 }
 
 bool MSVCToolChain::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+         getArch() == llvm::Triple::aarch64;
 }
 
 bool MSVCToolChain::isPIEDefault() const {
@@ -803,7 +804,8 @@ bool MSVCToolChain::isPIEDefault() const {
 }
 
 bool MSVCToolChain::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+         getArch() == llvm::Triple::aarch64;
 }
 
 void MSVCToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,

diff  --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index 1aaa941498322..6f1b7dd330fd0 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -474,13 +474,15 @@ bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const {
 }
 
 bool toolchains::MinGW::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+         getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPIEDefault() const { return false; }
 
 bool toolchains::MinGW::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+         getArch() == llvm::Triple::aarch64;
 }
 
 llvm::ExceptionHandling

diff  --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
index 57924cd1bbb43..6f8d6cc75c006 100644
--- a/clang/test/Driver/pic.c
+++ b/clang/test/Driver/pic.c
@@ -314,8 +314,12 @@
 // RUN: %clang -c %s -target aarch64-linux-android24 -fno-PIE -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 //
-// On Windows-X64 PIC is enabled by default
+// On Windows x86_64 and aarch64 PIC is enabled by default
 // RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
 // RUN: %clang -c %s -target x86_64-pc-windows-gnu -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-msvc -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target aarch64-windows-gnu -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2


        


More information about the cfe-commits mailing list