r256026 - PIC should not be enabled by default on Darwin with -static.
Bob Wilson via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 18 12:37:54 PST 2015
Author: bwilson
Date: Fri Dec 18 14:37:54 2015
New Revision: 256026
URL: http://llvm.org/viewvc/llvm-project?rev=256026&view=rev
Log:
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
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/pic.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256026&r1=256025&r2=256026&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Dec 18 14:37:54 2015
@@ -3226,6 +3226,9 @@ ParsePICArgs(const ToolChain &ToolChain,
// 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 =
Modified: cfe/trunk/test/Driver/pic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/pic.c?rev=256026&r1=256025&r2=256026&view=diff
==============================================================================
--- cfe/trunk/test/Driver/pic.c (original)
+++ cfe/trunk/test/Driver/pic.c Fri Dec 18 14:37:54 2015
@@ -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 \
More information about the cfe-commits
mailing list