clang: Support -nopie flag

This commit is contained in:
Fredrik Fornwall 2016-08-18 18:25:57 -04:00
parent 23a5092d83
commit 9cbdadb1fe
3 changed files with 24 additions and 19 deletions

View File

@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=http://clang.llvm.org/
TERMUX_PKG_DESCRIPTION="C and C++ frontend for the LLVM compiler" TERMUX_PKG_DESCRIPTION="C and C++ frontend for the LLVM compiler"
_PKG_MAJOR_VERSION=3.8 _PKG_MAJOR_VERSION=3.8
TERMUX_PKG_VERSION=${_PKG_MAJOR_VERSION}.1 TERMUX_PKG_VERSION=${_PKG_MAJOR_VERSION}.1
TERMUX_PKG_BUILD_REVISION=2 TERMUX_PKG_BUILD_REVISION=3
TERMUX_PKG_SRCURL=http://llvm.org/releases/${TERMUX_PKG_VERSION}/llvm-${TERMUX_PKG_VERSION}.src.tar.xz TERMUX_PKG_SRCURL=http://llvm.org/releases/${TERMUX_PKG_VERSION}/llvm-${TERMUX_PKG_VERSION}.src.tar.xz
TERMUX_PKG_HOSTBUILD=true TERMUX_PKG_HOSTBUILD=true
TERMUX_PKG_RM_AFTER_INSTALL="bin/macho-dump bin/bugpoint bin/llvm-tblgen lib/BugpointPasses.so lib/LLVMHello.so" TERMUX_PKG_RM_AFTER_INSTALL="bin/macho-dump bin/bugpoint bin/llvm-tblgen lib/BugpointPasses.so lib/LLVMHello.so"

View File

@ -1,15 +0,0 @@
See http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150302/124624.html
where PIE as default on Android was removed. This patch brings it back.
diff -u -r ../llvm-3.7.0.src/tools/clang/lib/Driver/ToolChains.cpp ./tools/clang/lib/Driver/ToolChains.cpp
--- ../llvm-3.7.0.src/tools/clang/lib/Driver/ToolChains.cpp 2015-07-13 19:27:56.000000000 -0400
+++ ./tools/clang/lib/Driver/ToolChains.cpp 2015-09-04 10:38:53.984720577 -0400
@@ -3598,7 +3598,7 @@
}
}
-bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
+bool Linux::isPIEDefault() const { return true; }
SanitizerMask Linux::getSupportedSanitizers() const {
const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;

View File

@ -1,6 +1,6 @@
diff -u -r ../llvm-3.8.0.src/tools/clang/lib/Driver/Tools.cpp ./tools/clang/lib/Driver/Tools.cpp diff -u -r ../llvm-3.8.1.src/tools/clang/lib/Driver/Tools.cpp ./tools/clang/lib/Driver/Tools.cpp
--- ../llvm-3.8.0.src/tools/clang/lib/Driver/Tools.cpp 2016-02-12 17:51:41.000000000 -0500 --- ../llvm-3.8.1.src/tools/clang/lib/Driver/Tools.cpp 2016-02-12 17:51:41.000000000 -0500
+++ ./tools/clang/lib/Driver/Tools.cpp 2016-05-01 23:01:30.148998957 -0400 +++ ./tools/clang/lib/Driver/Tools.cpp 2016-08-18 10:00:30.287138752 -0400
@@ -733,11 +733,11 @@ @@ -733,11 +733,11 @@
ABI = FloatABI::SoftFP; ABI = FloatABI::SoftFP;
break; break;
@ -15,3 +15,23 @@ diff -u -r ../llvm-3.8.0.src/tools/clang/lib/Driver/Tools.cpp ./tools/clang/lib/
if (Triple.getOS() != llvm::Triple::UnknownOS || if (Triple.getOS() != llvm::Triple::UnknownOS ||
!Triple.isOSBinFormatMachO()) !Triple.isOSBinFormatMachO())
D.Diag(diag::warn_drv_assuming_mfloat_abi_is) << "soft"; D.Diag(diag::warn_drv_assuming_mfloat_abi_is) << "soft";
@@ -8773,9 +8773,18 @@
const llvm::Triple::ArchType Arch = ToolChain.getArch();
const bool isAndroid = ToolChain.getTriple().isAndroid();
const bool IsPIE =
!Args.hasArg(options::OPT_shared) && !Args.hasArg(options::OPT_static) &&
- (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault());
+ (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault()
+ /* Termux modification: Revert
+ http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150302/124624.html
+ as we really want pie by default: */
+ // On Android every code is PIC so every executable is PIE
+ // Cannot use isPIEDefault here since otherwise
+ // PIE only logic will be enabled during compilation
+ || isAndroid)
+ && !Args.hasArg(options::OPT_nopie);
+
const bool HasCRTBeginEndFiles =
ToolChain.getTriple().hasEnvironment() ||
(ToolChain.getTriple().getVendor() != llvm::Triple::MipsTechnologies);