From 912cd508e909dfd23d57dee3b14bfeb5dce32116 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sun, 28 Jun 2015 04:23:33 +0000 Subject: [PATCH] [Driver] x86-64 Windows is always PIC This fixes PR23963. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240902 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains.cpp | 8 ++++++-- test/Driver/pic.c | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 27bc357f34..df74b41b02 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -2021,11 +2021,15 @@ bool Generic_GCC::IsUnwindTablesDefault() const { return getArch() == llvm::Triple::x86_64; } -bool Generic_GCC::isPICDefault() const { return false; } +bool Generic_GCC::isPICDefault() const { + return getArch() == llvm::Triple::x86_64 && getTriple().isOSWindows(); +} bool Generic_GCC::isPIEDefault() const { return false; } -bool Generic_GCC::isPICDefaultForced() const { return false; } +bool Generic_GCC::isPICDefaultForced() const { + return getArch() == llvm::Triple::x86_64 && getTriple().isOSWindows(); +} bool Generic_GCC::IsIntegratedAssemblerDefault() const { switch (getTriple().getArch()) { diff --git a/test/Driver/pic.c b/test/Driver/pic.c index a515f8117a..120e66a92a 100644 --- a/test/Driver/pic.c +++ b/test/Driver/pic.c @@ -242,3 +242,9 @@ // RUN: | FileCheck %s --check-prefix=CHECK-PIC1 // RUN: %clang -c %s -target arm64-linux-android -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-PIC1 +// +// On Windows-X64 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 -- 2.40.0