[PATCH] D15455: [Driver] Let -static override the toolchain default PIC setting.
Frederic Riss via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 11 09:23:09 PST 2015
friss created this revision.
friss added reviewers: jyknight, rnk, joerg.
friss added a subscriber: cfe-commits.
In r245667 -static was changed not to disable -fPIC as they control
2 different concepts. On toolchains that enable -fPIC by default,
this means that now you have to pass "-static -fno-PIC" to get the
previous behavior.
As static usually means that we do not need PIC, this patches allows
-static to override the toolchain default. You can still build all the
combinations, but -static doesn't require -fno-PIC anymore on default-PIC
toolchains.
http://reviews.llvm.org/D15455
Files:
lib/Driver/Tools.cpp
test/Driver/pic.c
Index: test/Driver/pic.c
===================================================================
--- test/Driver/pic.c
+++ 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 \
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3121,8 +3121,9 @@
const ArgList &Args) {
// FIXME: why does this code...and so much everywhere else, use both
// ToolChain.getTriple() and Triple?
- bool PIE = ToolChain.isPIEDefault();
- bool PIC = PIE || ToolChain.isPICDefault();
+ bool isStatic = Args.hasArg(options::OPT_static);
+ bool PIE = ToolChain.isPIEDefault() && !isStatic;
+ bool PIC = PIE || (ToolChain.isPICDefault() && !isStatic);
bool IsPICLevelTwo = PIC;
bool KernelOrKext =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15455.42529.patch
Type: text/x-patch
Size: 1278 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151211/0fa4cb3d/attachment.bin>
More information about the cfe-commits
mailing list