summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2015-12-18 20:37:54 +0000
committerBob Wilson <bob.wilson@apple.com>2015-12-18 20:37:54 +0000
commit2b2a0ae76d36232a8ac67855dce8f36a956433f4 (patch)
tree610e720643903620afec630ae37f9a669c2ffc17
parent21dc8bdd9e3efd1b660b91c6f27eb9cb38517205 (diff)
downloadbcm5719-llvm-2b2a0ae76d36232a8ac67855dce8f36a956433f4.tar.gz
bcm5719-llvm-2b2a0ae76d36232a8ac67855dce8f36a956433f4.zip
PIC should not be enabled by default on Darwin with -static.
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 llvm-svn: 256026
-rw-r--r--clang/lib/Driver/Tools.cpp3
-rw-r--r--clang/test/Driver/pic.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index c35aa1c754d..a86308d9c3a 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -3226,6 +3226,9 @@ ParsePICArgs(const ToolChain &ToolChain, const llvm::Triple &Triple,
// 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 =
diff --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
index ca4b892e047..06b4204e60d 100644
--- a/clang/test/Driver/pic.c
+++ b/clang/test/Driver/pic.c
@@ -217,7 +217,7 @@
// 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 \
OpenPOWER on IntegriCloud