From 9cbdadb1fe2c58f1be7cfaa6b502f5d363303d65 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 18 Aug 2016 18:25:57 -0400 Subject: [PATCH] clang: Support -nopie flag --- packages/clang/build.sh | 2 +- ...ools-clang-lib-Driver-ToolChains.cpp.patch | 15 ----------- .../tools-clang-lib-Driver-Tools.cpp.patch | 26 ++++++++++++++++--- 3 files changed, 24 insertions(+), 19 deletions(-) delete mode 100644 packages/clang/tools-clang-lib-Driver-ToolChains.cpp.patch diff --git a/packages/clang/build.sh b/packages/clang/build.sh index b148d4943..772b7fca2 100644 --- a/packages/clang/build.sh +++ b/packages/clang/build.sh @@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=http://clang.llvm.org/ TERMUX_PKG_DESCRIPTION="C and C++ frontend for the LLVM compiler" _PKG_MAJOR_VERSION=3.8 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_HOSTBUILD=true TERMUX_PKG_RM_AFTER_INSTALL="bin/macho-dump bin/bugpoint bin/llvm-tblgen lib/BugpointPasses.so lib/LLVMHello.so" diff --git a/packages/clang/tools-clang-lib-Driver-ToolChains.cpp.patch b/packages/clang/tools-clang-lib-Driver-ToolChains.cpp.patch deleted file mode 100644 index 09c3f2a21..000000000 --- a/packages/clang/tools-clang-lib-Driver-ToolChains.cpp.patch +++ /dev/null @@ -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; diff --git a/packages/clang/tools-clang-lib-Driver-Tools.cpp.patch b/packages/clang/tools-clang-lib-Driver-Tools.cpp.patch index 4ccaae3ba..edc2ca996 100644 --- a/packages/clang/tools-clang-lib-Driver-Tools.cpp.patch +++ b/packages/clang/tools-clang-lib-Driver-Tools.cpp.patch @@ -1,6 +1,6 @@ -diff -u -r ../llvm-3.8.0.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 -+++ ./tools/clang/lib/Driver/Tools.cpp 2016-05-01 23:01:30.148998957 -0400 +diff -u -r ../llvm-3.8.1.src/tools/clang/lib/Driver/Tools.cpp ./tools/clang/lib/Driver/Tools.cpp +--- ../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-08-18 10:00:30.287138752 -0400 @@ -733,11 +733,11 @@ ABI = FloatABI::SoftFP; 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 || !Triple.isOSBinFormatMachO()) 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);