]> granicus.if.org Git - clang/commitdiff
Generalize r256026 to apply to all MachO targets, not just Darwin targets.
authorBob Wilson <bob.wilson@apple.com>
Wed, 13 Jan 2016 01:19:02 +0000 (01:19 +0000)
committerBob Wilson <bob.wilson@apple.com>
Wed, 13 Jan 2016 01:19:02 +0000 (01:19 +0000)
The PIC default is set for the MachO toolchain, not just the Darwin toolchain,
so this treats those the same. The behavior with -static should be the same
for all MachO targets. rdar://24152327

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257556 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/pic.c

index 9a1a9498a90543f1c443d7c112cd0f0ed10378a7..5a2dbd388fc113e2d8ce5e4324c19acbb22ccbcb 100644 (file)
@@ -3263,8 +3263,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))
+  // The Darwin/MachO default to use PIC does not apply when using -static.
+  if (ToolChain.getTriple().isOSBinFormatMachO() &&
+      Args.hasArg(options::OPT_static))
     PIE = PIC = false;
   bool IsPICLevelTwo = PIC;
 
index 06b4204e60da1591a6682a649dc6b16e504afd42..aeb2ee33114c9d4c285acca3fae2ed32644f5c2d 100644 (file)
 // 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-NO-PIC
+// RUN: %clang -c %s -target armv7-apple-unknown-macho -static -### 2>&1 \
+// 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 \