From 58542697c14bae5c8d81bb2c1cc60dd015cdc0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz=20=28arab=2C=20vx?= =?UTF-8?q?p=29?= Date: Thu, 19 Jan 2017 19:04:09 +0100 Subject: {clang,llvm}_host: adds clang v3.8.1 and llvm v3.8.1 (via Redfoxmoon.) --- ...05-Enable-PIE-by-default-for-alpine-linux.patch | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 patches/clang_host/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch (limited to 'patches/clang_host/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch') diff --git a/patches/clang_host/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch b/patches/clang_host/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch new file mode 100644 index 00000000..a1d49eeb --- /dev/null +++ b/patches/clang_host/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch @@ -0,0 +1,69 @@ +From efbdf70c883a356106fc1bcb1c2917ec6c0a6157 Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Tue, 23 Feb 2016 09:35:26 +0100 +Subject: [PATCH 5/7] Enable PIE by default for alpine linux + +Alpine Linux uses PIE by default. +--- + lib/Driver/ToolChains.cpp | 5 ++++- + lib/Driver/Tools.cpp | 4 +++- + test/Driver/pic.c | 12 ++++++++++++ + 3 files changed, 19 insertions(+), 2 deletions(-) + +diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp +index 0db9644..82449bf 100644 +--- a/lib/Driver/ToolChains.cpp ++++ b/lib/Driver/ToolChains.cpp +@@ -4143,7 +4143,10 @@ void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs, + } + } + +-bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); } ++bool Linux::isPIEDefault() const { ++ return getSanitizerArgs().requiresPIE() || ++ Linux::getTriple().getVendorName().compare("alpine") == 0; ++} + + SanitizerMask Linux::getSupportedSanitizers() const { + const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; +diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp +index ea1ce6f..8fd3649 100644 +--- a/lib/Driver/Tools.cpp ++++ b/lib/Driver/Tools.cpp +@@ -7919,7 +7919,9 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA, + if (!D.SysRoot.empty()) + CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); + +- if (IsPIE) ++ if (Args.hasArg(options::OPT_nopie)) ++ CmdArgs.push_back("-nopie"); ++ else if (IsPIE) + CmdArgs.push_back("-pie"); + + if (Args.hasArg(options::OPT_static)) { +diff --git a/test/Driver/pic.c b/test/Driver/pic.c +index aeb2ee3..9b8e0f6 100644 +--- a/test/Driver/pic.c ++++ b/test/Driver/pic.c +@@ -243,6 +243,18 @@ + // RUN: %clang %s -target i386-pc-openbsd -nopie -### 2>&1 \ + // RUN: | FileCheck %s --check-prefix=CHECK-NOPIE-LD + // ++// On Alpine Linux, we want similar PIE-by-default behavior ++// RUN: %clang -c %s -target x86_64-alpine-linux-musl -### 2>&1 \ ++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 ++// RUN: %clang -c %s -target i686-alpine-linux-musl -### 2>&1 \ ++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 ++// RUN: %clang -c %s -target armv6-alpine-linux-musleabihf -### 2>&1 \ ++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 ++// RUN: %clang -c %s -target armv7-alpine-linux-musleabihf -### 2>&1 \ ++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 ++// RUN: %clang %s -target x86_64-alpine-linux-musl -nopie -### 2>&1 \ ++// RUN: | FileCheck %s --check-prefix=CHECK-NOPIE-LD ++// + // On Android PIC is enabled by default + // RUN: %clang -c %s -target i686-linux-android -### 2>&1 \ + // RUN: | FileCheck %s --check-prefix=CHECK-PIC2 +-- +2.7.3 + -- cgit v1.2.3