summaryrefslogtreecommitdiffhomepage
path: root/patches/clang_host
diff options
context:
space:
mode:
Diffstat (limited to 'patches/clang_host')
-rw-r--r--patches/clang_host/clang-0001-Add-Alpine-Linux-distro.patch34
-rw-r--r--patches/clang_host/clang-0002-Use-z-relro-on-Alpine-Linux.patch25
-rw-r--r--patches/clang_host/clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch27
-rw-r--r--patches/clang_host/clang-0004-Add-musl-targets-and-dynamic-linker.patch222
-rw-r--r--patches/clang_host/clang-0005-Enable-PIE-by-default-for-alpine-linux.patch69
-rw-r--r--patches/clang_host/clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch28
-rw-r--r--patches/clang_host/clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch69
-rw-r--r--patches/clang_host/clang-0008-LLVM_PREFIX.patch11
8 files changed, 485 insertions, 0 deletions
diff --git a/patches/clang_host/clang-0001-Add-Alpine-Linux-distro.patch b/patches/clang_host/clang-0001-Add-Alpine-Linux-distro.patch
new file mode 100644
index 00000000..6cbed09d
--- /dev/null
+++ b/patches/clang_host/clang-0001-Add-Alpine-Linux-distro.patch
@@ -0,0 +1,34 @@
+From 4559c66aabd8b56f7127c8b1f5d22f59d3ca2390 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 18 Feb 2016 17:40:00 +0100
+Subject: [PATCH 1/7] Add Alpine Linux distro
+
+---
+ lib/Driver/ToolChains.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
+index 99c7b8e..70b53bd 100644
+--- a/lib/Driver/ToolChains.cpp
++++ b/lib/Driver/ToolChains.cpp
+@@ -3374,6 +3374,7 @@ enum Distro {
+ // NB: Releases of a particular Linux distro should be kept together
+ // in this enum, because some tests are done by integer comparison against
+ // the first and last known member in the family, e.g. IsRedHat().
++ AlpineLinux,
+ ArchLinux,
+ DebianLenny,
+ DebianSqueeze,
+@@ -3497,6 +3498,9 @@ static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
+ if (D.getVFS().exists("/etc/arch-release"))
+ return ArchLinux;
+
++ if (D.getVFS().exists("/etc/alpine-release"))
++ return AlpineLinux;
++
+ return UnknownDistro;
+ }
+
+--
+2.7.3
+
diff --git a/patches/clang_host/clang-0002-Use-z-relro-on-Alpine-Linux.patch b/patches/clang_host/clang-0002-Use-z-relro-on-Alpine-Linux.patch
new file mode 100644
index 00000000..090ec3d5
--- /dev/null
+++ b/patches/clang_host/clang-0002-Use-z-relro-on-Alpine-Linux.patch
@@ -0,0 +1,25 @@
+From 1898d32d22fddf3ba6c88addbd2af0159600b506 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 18 Feb 2016 17:41:23 +0100
+Subject: [PATCH 2/7] Use "-z relro" on Alpine Linux
+
+---
+ lib/Driver/ToolChains.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
+index 70b53bd..46326f0 100644
+--- a/lib/Driver/ToolChains.cpp
++++ b/lib/Driver/ToolChains.cpp
+@@ -3667,7 +3667,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+
+ Distro Distro = DetectDistro(D, Arch);
+
+- if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
++ if (IsOpenSUSE(Distro) || IsUbuntu(Distro) || Distro == AlpineLinux) {
+ ExtraOpts.push_back("-z");
+ ExtraOpts.push_back("relro");
+ }
+--
+2.7.3
+
diff --git a/patches/clang_host/clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch b/patches/clang_host/clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch
new file mode 100644
index 00000000..4dc9842f
--- /dev/null
+++ b/patches/clang_host/clang-0003-Use-hash-style-gnu-for-Alpine-Linux.patch
@@ -0,0 +1,27 @@
+From b880ea7037ea3232be9ba2e96cc179da92ea4b9c Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 18 Feb 2016 17:43:51 +0100
+Subject: [PATCH 3/7] Use --hash-style=gnu for Alpine Linux
+
+---
+ lib/Driver/ToolChains.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
+index 46326f0..6b0b31d 100644
+--- a/lib/Driver/ToolChains.cpp
++++ b/lib/Driver/ToolChains.cpp
+@@ -3687,8 +3687,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+ // ABI requires a mapping between the GOT and the symbol table.
+ // Android loader does not support .gnu.hash.
+ if (!IsMips && !IsAndroid) {
+- if (IsRedhat(Distro) || IsOpenSUSE(Distro) ||
+- (IsUbuntu(Distro) && Distro >= UbuntuMaverick))
++ if (IsRedhat(Distro) || IsOpenSUSE(Distro) || Distro == AlpineLinux ||
++ (IsUbuntu(Distro) && Distro >= UbuntuMaverick))
+ ExtraOpts.push_back("--hash-style=gnu");
+
+ if (IsDebian(Distro) || IsOpenSUSE(Distro) || Distro == UbuntuLucid ||
+--
+2.7.3
+
diff --git a/patches/clang_host/clang-0004-Add-musl-targets-and-dynamic-linker.patch b/patches/clang_host/clang-0004-Add-musl-targets-and-dynamic-linker.patch
new file mode 100644
index 00000000..6384b088
--- /dev/null
+++ b/patches/clang_host/clang-0004-Add-musl-targets-and-dynamic-linker.patch
@@ -0,0 +1,222 @@
+From 4777c16fc6e717a852366fa2a447c852cca3b62d Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Fri, 19 Feb 2016 13:35:08 +0100
+Subject: [PATCH 4/7] Add musl targets and dynamic linker
+
+---
+ lib/Basic/Targets.cpp | 2 ++
+ lib/CodeGen/TargetInfo.cpp | 6 +++++-
+ lib/Driver/ToolChains.cpp | 15 ++++++++++-----
+ lib/Driver/Tools.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++-
+ 4 files changed, 60 insertions(+), 7 deletions(-)
+
+diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
+index af8aea0..1e27c7a 100644
+--- a/lib/Basic/Targets.cpp
++++ b/lib/Basic/Targets.cpp
+@@ -4513,6 +4513,8 @@ public:
+ case llvm::Triple::Android:
+ case llvm::Triple::GNUEABI:
+ case llvm::Triple::GNUEABIHF:
++ case llvm::Triple::MuslEABI:
++ case llvm::Triple::MuslEABIHF:
+ setABI("aapcs-linux");
+ break;
+ case llvm::Triple::EABIHF:
+diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
+index 3d1ddef..f6b3474 100644
+--- a/lib/CodeGen/TargetInfo.cpp
++++ b/lib/CodeGen/TargetInfo.cpp
+@@ -4757,6 +4757,8 @@ public:
+ case llvm::Triple::EABIHF:
+ case llvm::Triple::GNUEABI:
+ case llvm::Triple::GNUEABIHF:
++ case llvm::Triple::MuslEABI:
++ case llvm::Triple::MuslEABIHF:
+ return true;
+ default:
+ return false;
+@@ -4767,6 +4769,7 @@ public:
+ switch (getTarget().getTriple().getEnvironment()) {
+ case llvm::Triple::EABIHF:
+ case llvm::Triple::GNUEABIHF:
++ case llvm::Triple::MuslEABIHF:
+ return true;
+ default:
+ return false;
+@@ -7492,7 +7495,8 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() {
+ Kind = ARMABIInfo::AAPCS16_VFP;
+ else if (CodeGenOpts.FloatABI == "hard" ||
+ (CodeGenOpts.FloatABI != "soft" &&
+- Triple.getEnvironment() == llvm::Triple::GNUEABIHF))
++ (Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
++ Triple.getEnvironment() == llvm::Triple::MuslEABIHF)))
+ Kind = ARMABIInfo::AAPCS_VFP;
+
+ return *(TheTargetCodeGenInfo = new ARMTargetCodeGenInfo(Types, Kind));
+diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
+index 6b0b31d..0db9644 100644
+--- a/lib/Driver/ToolChains.cpp
++++ b/lib/Driver/ToolChains.cpp
+@@ -1523,7 +1523,8 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs));
+- if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) {
++ if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF ||
++ TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) {
+ TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples));
+ } else {
+ TripleAliases.append(begin(ARMTriples), end(ARMTriples));
+@@ -1532,7 +1533,8 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
+ case llvm::Triple::armeb:
+ case llvm::Triple::thumbeb:
+ LibDirs.append(begin(ARMebLibDirs), end(ARMebLibDirs));
+- if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) {
++ if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF ||
++ TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) {
+ TripleAliases.append(begin(ARMebHFTriples), end(ARMebHFTriples));
+ } else {
+ TripleAliases.append(begin(ARMebTriples), end(ARMebTriples));
+@@ -3528,7 +3530,8 @@ static std::string getMultiarchTriple(const Driver &D,
+ // regardless of what the actual target triple is.
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+- if (TargetEnvironment == llvm::Triple::GNUEABIHF) {
++ if (TargetEnvironment == llvm::Triple::GNUEABIHF ||
++ TargetEnvironment == llvm::Triple::MuslEABIHF) {
+ if (D.getVFS().exists(SysRoot + "/lib/arm-linux-gnueabihf"))
+ return "arm-linux-gnueabihf";
+ } else {
+@@ -3538,7 +3541,8 @@ static std::string getMultiarchTriple(const Driver &D,
+ break;
+ case llvm::Triple::armeb:
+ case llvm::Triple::thumbeb:
+- if (TargetEnvironment == llvm::Triple::GNUEABIHF) {
++ if (TargetEnvironment == llvm::Triple::GNUEABIHF ||
++ TargetEnvironment == llvm::Triple::MuslEABIHF) {
+ if (D.getVFS().exists(SysRoot + "/lib/armeb-linux-gnueabihf"))
+ return "armeb-linux-gnueabihf";
+ } else {
+@@ -3969,7 +3973,8 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
+ break;
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+- if (getTriple().getEnvironment() == llvm::Triple::GNUEABIHF)
++ if (getTriple().getEnvironment() == llvm::Triple::GNUEABIHF ||
++ getTriple().getEnvironment() == llvm::Triple::MuslEABIHF)
+ MultiarchIncludeDirs = ARMHFMultiarchIncludeDirs;
+ else
+ MultiarchIncludeDirs = ARMMultiarchIncludeDirs;
+diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
+index b7ac24f..ea1ce6f 100644
+--- a/lib/Driver/Tools.cpp
++++ b/lib/Driver/Tools.cpp
+@@ -712,6 +712,7 @@ arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) {
+ case llvm::Triple::FreeBSD:
+ switch (Triple.getEnvironment()) {
+ case llvm::Triple::GNUEABIHF:
++ case llvm::Triple::MuslEABIHF:
+ ABI = FloatABI::Hard;
+ break;
+ default:
+@@ -725,6 +726,7 @@ arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) {
+ switch (Triple.getEnvironment()) {
+ case llvm::Triple::GNUEABIHF:
+ case llvm::Triple::EABIHF:
++ case llvm::Triple::MuslEABIHF:
+ ABI = FloatABI::Hard;
+ break;
+ case llvm::Triple::GNUEABI:
+@@ -968,6 +970,8 @@ void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args,
+ case llvm::Triple::Android:
+ case llvm::Triple::GNUEABI:
+ case llvm::Triple::GNUEABIHF:
++ case llvm::Triple::MuslEABI:
++ case llvm::Triple::MuslEABIHF:
+ ABIName = "aapcs-linux";
+ break;
+ case llvm::Triple::EABIHF:
+@@ -7857,6 +7861,8 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
+ switch (getToolChain().getTriple().getEnvironment()) {
+ case llvm::Triple::GNUEABIHF:
+ case llvm::Triple::GNUEABI:
++ case llvm::Triple::MuslEABIHF:
++ case llvm::Triple::MuslEABI:
+ case llvm::Triple::EABI:
+ CmdArgs.push_back("-meabi=5");
+ break;
+@@ -8199,10 +8205,12 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+ switch (getToolChain().getTriple().getEnvironment()) {
+ case llvm::Triple::EABI:
+ case llvm::Triple::GNUEABI:
++ case llvm::Triple::MuslEABI:
+ CmdArgs.push_back("armelf_nbsd_eabi");
+ break;
+ case llvm::Triple::EABIHF:
+ case llvm::Triple::GNUEABIHF:
++ case llvm::Triple::MuslEABIHF:
+ CmdArgs.push_back("armelf_nbsd_eabihf");
+ break;
+ default:
+@@ -8219,10 +8227,12 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+ switch (getToolChain().getTriple().getEnvironment()) {
+ case llvm::Triple::EABI:
+ case llvm::Triple::GNUEABI:
++ case llvm::Triple::MuslEABI:
+ CmdArgs.push_back("armelfb_nbsd_eabi");
+ break;
+ case llvm::Triple::EABIHF:
+ case llvm::Triple::GNUEABIHF:
++ case llvm::Triple::MuslEABIHF:
+ CmdArgs.push_back("armelfb_nbsd_eabihf");
+ break;
+ default:
+@@ -8623,11 +8633,43 @@ static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
+ CmdArgs.push_back("-ldl");
+ }
+
++static std::string getMuslDynamicLinker(const llvm::Triple::ArchType Arch,
++ const llvm::Triple::EnvironmentType Env) {
++ switch (Arch) {
++ case llvm::Triple::arm:
++ case llvm::Triple::thumb:
++ return Env == llvm::Triple::MuslEABIHF ?
++ "/lib/ld-musl-armhf.so.1" : "/lib/ld-musl-arm.so.1";
++ case llvm::Triple::armeb:
++ case llvm::Triple::thumbeb:
++ return Env == llvm::Triple::MuslEABIHF ?
++ "/lib/ld-musl-armebhf.so.1" : "/lib/ld-musl-armeb.so.1";
++ case llvm::Triple::aarch64:
++ return "/lib/ld-musl-aarch64.so.1";
++ case llvm::Triple::aarch64_be:
++ return "/lib/ld-musl-aarch64_be.so.1";
++ case llvm::Triple::mips:
++ return "/lib/ld-musl-mips.so.1";
++ case llvm::Triple::mipsel:
++ return "/lib/ld-musl-mipsel.so.1";
++ case llvm::Triple::ppc:
++ return "/lib/ld-musl-powerpc.so.1";
++ case llvm::Triple::x86:
++ return "/lib/ld-musl-i386.so.1";
++//case llvm::Triple::x86_64:
++ default:
++ return "/lib/ld-musl-x86_64.so.1";
++ }
++ return NULL;
++}
++
+ static std::string getLinuxDynamicLinker(const ArgList &Args,
+ const toolchains::Linux &ToolChain) {
+ const llvm::Triple::ArchType Arch = ToolChain.getArch();
+
+- if (ToolChain.getTriple().isAndroid()) {
++ if (ToolChain.getTriple().isMusl()) {
++ return getMuslDynamicLinker(Arch, ToolChain.getTriple().getEnvironment());
++ } else if (ToolChain.getTriple().isAndroid()) {
+ if (ToolChain.getTriple().isArch64Bit())
+ return "/system/bin/linker64";
+ else
+--
+2.7.3
+
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 <ncopa@alpinelinux.org>
+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
+
diff --git a/patches/clang_host/clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch b/patches/clang_host/clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch
new file mode 100644
index 00000000..a7ad2d8c
--- /dev/null
+++ b/patches/clang_host/clang-0006-Link-with-z-now-by-default-for-Alpine-Linux.patch
@@ -0,0 +1,28 @@
+From e089ab63916eada060fdfffbf7422c9b20bafe84 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Tue, 23 Feb 2016 10:08:17 +0000
+Subject: [PATCH 6/7] Link with -z now by default for Alpine Linux
+
+---
+ lib/Driver/ToolChains.cpp | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
+index 82449bf..1a8ebf5 100644
+--- a/lib/Driver/ToolChains.cpp
++++ b/lib/Driver/ToolChains.cpp
+@@ -3671,6 +3671,11 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+
+ Distro Distro = DetectDistro(D, Arch);
+
++ if (Distro == AlpineLinux) {
++ ExtraOpts.push_back("-z");
++ ExtraOpts.push_back("now");
++ }
++
+ if (IsOpenSUSE(Distro) || IsUbuntu(Distro) || Distro == AlpineLinux) {
+ ExtraOpts.push_back("-z");
+ ExtraOpts.push_back("relro");
+--
+2.7.3
+
diff --git a/patches/clang_host/clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch b/patches/clang_host/clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch
new file mode 100644
index 00000000..a4cb9261
--- /dev/null
+++ b/patches/clang_host/clang-0007-Enable-stack-protector-by-default-for-alpine-linux.patch
@@ -0,0 +1,69 @@
+From da8ea517105fff702f936695dcfae844ac85260d Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Tue, 23 Feb 2016 10:16:54 +0000
+Subject: [PATCH 7/7] Enable stack protector by default for alpine linux
+
+---
+ lib/Driver/ToolChains.cpp | 7 +++++++
+ lib/Driver/ToolChains.h | 1 +
+ test/Driver/stack-protector.c | 14 ++++++++++++++
+ 3 files changed, 22 insertions(+)
+
+diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
+index 1a8ebf5..59b7601 100644
+--- a/lib/Driver/ToolChains.cpp
++++ b/lib/Driver/ToolChains.cpp
+@@ -4193,6 +4193,13 @@ void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args,
+ ToolChain::addProfileRTLibs(Args, CmdArgs);
+ }
+
++unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const {
++ StringRef VendorName = Linux::getTriple().getVendorName();
++ if (VendorName.compare("alpine") == 0)
++ return 2;
++ return 1;
++}
++
+ /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
+
+ DragonFly::DragonFly(const Driver &D, const llvm::Triple &Triple,
+diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
+index f940e58..977ea66 100644
+--- a/lib/Driver/ToolChains.h
++++ b/lib/Driver/ToolChains.h
+@@ -796,6 +796,7 @@ public:
+ void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
+ bool isPIEDefault() const override;
++ unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override;
+ SanitizerMask getSupportedSanitizers() const override;
+ void addProfileRTLibs(const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs) const override;
+diff --git a/test/Driver/stack-protector.c b/test/Driver/stack-protector.c
+index 487af56..2fbd39a 100644
+--- a/test/Driver/stack-protector.c
++++ b/test/Driver/stack-protector.c
+@@ -24,6 +24,20 @@
+ // SSP-ALL: "-stack-protector" "3"
+ // SSP-ALL-NOT: "-stack-protector-buffer-size"
+
++// RUN: %clang -target x86_64-alpine-linux-musl -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE
++// ALPINE: "-stack-protector" "2"
++
++// RUN: %clang -target x86_64-alpine-linux-musl -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE_SPS
++// ALPINE_SPS: "-stack-protector" "2"
++
++// RUN: %clang -target x86_64-alpine-linux-musl -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE_ALL
++// ALPINE_ALL: "-stack-protector" "3"
++// ALPINE_ALL-NOT: "-stack-protector-buffer-size"
++
++// RUN: %clang -target x86_64-alpine-linux-musl -fno-stack-protector -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE_NOSSP
++// ALPINE_NOSSP-NOT: "-stack-protector"
++// ALPINE_NOSSP-NOT: "-stack-protector-buffer-size"
++
+ // RUN: %clang -target x86_64-scei-ps4 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4
+ // RUN: %clang -target x86_64-scei-ps4 -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4
+ // SSP-PS4: "-stack-protector" "2"
+--
+2.7.3
+
diff --git a/patches/clang_host/clang-0008-LLVM_PREFIX.patch b/patches/clang_host/clang-0008-LLVM_PREFIX.patch
new file mode 100644
index 00000000..8599276c
--- /dev/null
+++ b/patches/clang_host/clang-0008-LLVM_PREFIX.patch
@@ -0,0 +1,11 @@
+--- cfe-3.8.1.src/lib/Driver/CMakeLists.txt.orig 2015-07-02 04:45:27.000000000 +0000
++++ cfe-3.8.1.src/lib/Driver/CMakeLists.txt 2017-01-19 19:22:36.869663323 +0000
+@@ -3,6 +3,8 @@
+ Support
+ )
+
++add_definitions(-DLLVM_PREFIX="${LLVM_PREFIX}")
++
+ add_clang_library(clangDriver
+ Action.cpp
+ Compilation.cpp