r245667 changed -static so that it doesn't override an explicit -fPIC
option, but -static should still change the default for Darwin for -fno-PIC.
This matches longstanding GCC and Clang behavior on Darwin and changing it
would be disruptive, with no significant benefit.
http://reviews.llvm.org/D15455
rdar://problem/
23811045
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256026
91177308-0d34-0410-b5e6-
96231b3b80d8
// ToolChain.getTriple() and Triple?
bool PIE = ToolChain.isPIEDefault();
bool PIC = PIE || ToolChain.isPICDefault();
+ // The Darwin default to use PIC does not apply when using -static.
+ if (ToolChain.getTriple().isOSDarwin() && Args.hasArg(options::OPT_static))
+ PIE = PIC = false;
bool IsPICLevelTwo = PIC;
bool KernelOrKext =
// RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=5.0.0 -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
// RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=6.0.0 -static -### 2>&1 \
-// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
//
// On OpenBSD, PIE is enabled by default, but can be disabled.
// RUN: %clang -c %s -target amd64-pc-openbsd -### 2>&1 \