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 =
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 =
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits