summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--build/pkg.build16
-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
-rw-r--r--patches/llvm_host/llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch112
-rw-r--r--patches/llvm_host/llvm-0002-Fix-build-with-musl-libc.patch35
-rw-r--r--patches/llvm_host/llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch33
-rw-r--r--patches/llvm_host/llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch99
-rw-r--r--patches/llvm_host/llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch181
-rw-r--r--patches/llvm_host/llvm-0006-clone-every-functions-debug-info.patch129
-rw-r--r--patches/llvm_host/llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch102
-rw-r--r--patches/llvm_host/llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch107
-rw-r--r--patches/llvm_host/llvm-0009-nm-workaround.patch27
-rw-r--r--vars/build.vars57
-rw-r--r--vars/clang_host.vars28
-rw-r--r--vars/cmake.vars2
-rw-r--r--vars/llvm_host.vars25
-rw-r--r--vars/python3.vars2
23 files changed, 1413 insertions, 27 deletions
diff --git a/build/pkg.build b/build/pkg.build
index ddfea695..97b7adbb 100644
--- a/build/pkg.build
+++ b/build/pkg.build
@@ -58,7 +58,7 @@ if ! is_build_script_done build_dir; then
set_build_script_done build_dir -patch_pre;
fi;
if ! is_build_script_done patch_pre; then
- for __ in \
+ for __ in \
${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}_pre.local.patch \
${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}_pre.local@${BUILD_HNAME}.patch \
${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}_pre.local.patch \
@@ -108,6 +108,13 @@ if [ -e ${PKG_SUBDIR}/configure -o \
set_build_script_done autoconf -patch;
fi;
if ! is_build_script_done patch; then
+ if [ -d ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME} ]; then
+ set +o noglob;
+ for __patch_fname in ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}/*.patch; do
+ patch -b -d ${PKG_SUBDIR} -p1 < ${__patch_fname};
+ done;
+ set -o noglob;
+ fi;
for __patch_fname in \
${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local.patch \
${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch \
@@ -132,16 +139,19 @@ cd ${PKG_BUILD_DIR};
if [ "${PKG_BUILD_TYPE}" = "host" ]; then
export AR=ar;
export CC=gcc;
+ export CXX=g++;
export RANLIB=ranlib;
else
export AR=${PKG_TARGET}-ar;
export CC=${PKG_TARGET}-gcc;
+ export CXX=${PKG_TARGET}-g++;
export RANLIB=${PKG_TARGET}-ranlib;
fi;
if [ -x ${PKG_CONFIGURE} ]; then
export CFLAGS_FOR_BUILD="${HOST_TOOLCHAIN_CFLAGS_CONFIGURE_DEFAULT}";
fi;
if [ -x ${PKG_CONFIGURE} ]\
+|| test_cmd pkg_${PKG_NAME}_configure\
&& ! is_build_script_done configure; then
if test_cmd pkg_${PKG_NAME}_configure; then
pkg_${PKG_NAME}_configure;
@@ -250,7 +260,9 @@ if ! is_build_script_done install; then
esac; shift;
done);
fi;
- if test_cmd perk && test_cmd ${PKG_TARGET}-dlltool; then
+ if [ "${PKG_BUILD_TYPE}" != "host" ] \
+ && test_cmd perk \
+ && test_cmd ${PKG_TARGET}-dlltool; then
for __so_fname in \
$(find \( -name "*.so" \
-or -name "*.so.[0-9]" \
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
diff --git a/patches/llvm_host/llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch b/patches/llvm_host/llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch
new file mode 100644
index 00000000..c1dfc5bd
--- /dev/null
+++ b/patches/llvm_host/llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch
@@ -0,0 +1,112 @@
+From 1cec99f6d53d442d8a8c9d2ed9f4a58f8fdc6412 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 18 Feb 2016 08:30:07 +0100
+Subject: [PATCH 1/3] Add Musl, MuslEABI and Musl EABIHF triples
+
+---
+ include/llvm/ADT/Triple.h | 11 +++++++++++
+ lib/Support/Triple.cpp | 7 +++++++
+ lib/Target/ARM/ARMSubtarget.h | 3 +++
+ lib/Target/ARM/ARMTargetMachine.cpp | 2 ++
+ 4 files changed, 23 insertions(+)
+
+diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
+index e01db0a..2fc4fc1 100644
+--- a/include/llvm/ADT/Triple.h
++++ b/include/llvm/ADT/Triple.h
+@@ -174,6 +174,10 @@ public:
+ EABIHF,
+ Android,
+
++ Musl,
++ MuslEABI,
++ MuslEABIHF,
++
+ MSVC,
+ Itanium,
+ Cygnus,
+@@ -544,6 +548,13 @@ public:
+ /// Tests whether the target is Android
+ bool isAndroid() const { return getEnvironment() == Triple::Android; }
+
++ /// Tests whether the target is musl libc
++ bool isMusl() const {
++ return getEnvironment() == Triple::Musl ||
++ getEnvironment() == Triple::MuslEABI ||
++ getEnvironment() == Triple::MuslEABIHF;
++ }
++
+ /// @}
+ /// @name Mutators
+ /// @{
+diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
+index 11afcf7..d90a06a 100644
+--- a/lib/Support/Triple.cpp
++++ b/lib/Support/Triple.cpp
+@@ -199,6 +199,9 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
+ case CODE16: return "code16";
+ case EABI: return "eabi";
+ case EABIHF: return "eabihf";
++ case Musl: return "musl";
++ case MuslEABIHF: return "muslgnueabihf";
++ case MuslEABI: return "muslgnueabi";
+ case Android: return "android";
+ case MSVC: return "msvc";
+ case Itanium: return "itanium";
+@@ -454,6 +457,9 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
+ .StartsWith("code16", Triple::CODE16)
+ .StartsWith("gnu", Triple::GNU)
+ .StartsWith("android", Triple::Android)
++ .StartsWith("muslgnueabihf", Triple::MuslEABIHF)
++ .StartsWith("muslgnueabi", Triple::MuslEABI)
++ .StartsWith("musl", Triple::Musl)
+ .StartsWith("msvc", Triple::MSVC)
+ .StartsWith("itanium", Triple::Itanium)
+ .StartsWith("cygnus", Triple::Cygnus)
+@@ -1431,6 +1437,7 @@ StringRef Triple::getARMCPUForArch(StringRef MArch) const {
+ switch (getEnvironment()) {
+ case llvm::Triple::EABIHF:
+ case llvm::Triple::GNUEABIHF:
++ case llvm::Triple::MuslEABIHF:
+ return "arm1176jzf-s";
+ default:
+ return "arm7tdmi";
+diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h
+index 4d54e57..7ed7ab7 100644
+--- a/lib/Target/ARM/ARMSubtarget.h
++++ b/lib/Target/ARM/ARMSubtarget.h
+@@ -405,8 +405,10 @@ public:
+ bool isTargetEHABICompatible() const {
+ return (TargetTriple.getEnvironment() == Triple::EABI ||
+ TargetTriple.getEnvironment() == Triple::GNUEABI ||
++ TargetTriple.getEnvironment() == Triple::MuslEABI ||
+ TargetTriple.getEnvironment() == Triple::EABIHF ||
+ TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
++ TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
+ isTargetAndroid()) &&
+ !isTargetDarwin() && !isTargetWindows();
+ }
+@@ -415,6 +417,7 @@ public:
+ // FIXME: this is invalid for WindowsCE
+ return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
+ TargetTriple.getEnvironment() == Triple::EABIHF ||
++ TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
+ isTargetWindows() || isAAPCS16_ABI();
+ }
+ bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
+diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp
+index fca1901..25f5cf9 100644
+--- a/lib/Target/ARM/ARMTargetMachine.cpp
++++ b/lib/Target/ARM/ARMTargetMachine.cpp
+@@ -101,6 +101,8 @@ computeTargetABI(const Triple &TT, StringRef CPU,
+ case llvm::Triple::GNUEABIHF:
+ case llvm::Triple::EABIHF:
+ case llvm::Triple::EABI:
++ case llvm::Triple::MuslEABI:
++ case llvm::Triple::MuslEABIHF:
+ TargetABI = ARMBaseTargetMachine::ARM_ABI_AAPCS;
+ break;
+ case llvm::Triple::GNU:
+--
+2.7.3
+
diff --git a/patches/llvm_host/llvm-0002-Fix-build-with-musl-libc.patch b/patches/llvm_host/llvm-0002-Fix-build-with-musl-libc.patch
new file mode 100644
index 00000000..1a690808
--- /dev/null
+++ b/patches/llvm_host/llvm-0002-Fix-build-with-musl-libc.patch
@@ -0,0 +1,35 @@
+From 5c571082fdaf61f6df19d9b7137dc26d71334058 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 18 Feb 2016 10:33:04 +0100
+Subject: [PATCH 2/3] Fix build with musl libc
+
+On musl libc the fopen64 and fopen are the same thing, but for
+compatibility they have a `#define fopen64 fopen`. Same applies for
+fseek64, fstat64, fstatvfs64, ftello64, lstat64, stat64 and tmpfile64.
+---
+ include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
+index 7becdf0..7f14427 100644
+--- a/include/llvm/Analysis/TargetLibraryInfo.h
++++ b/include/llvm/Analysis/TargetLibraryInfo.h
+@@ -18,6 +18,15 @@
+ #include "llvm/IR/Module.h"
+ #include "llvm/Pass.h"
+
++#undef fopen64
++#undef fseeko64
++#undef fstat64
++#undef fstatvfs64
++#undef ftello64
++#undef lstat64
++#undef stat64
++#undef tmpfile64
++
+ namespace llvm {
+ /// VecDesc - Describes a possible vectorization of a function.
+ /// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
+--
+2.7.3
+
diff --git a/patches/llvm_host/llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch b/patches/llvm_host/llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch
new file mode 100644
index 00000000..d5d7f07b
--- /dev/null
+++ b/patches/llvm_host/llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch
@@ -0,0 +1,33 @@
+From d12ecb83d01dcb580dd94f4d57828f33d3eb4c35 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 18 Feb 2016 15:33:21 +0100
+Subject: [PATCH 3/3] Fix DynamicLibrary to build with musl libc
+
+stdin/out/err is part of the libc and not the kernel so we check for the
+specific libc that does the unexpected instead of linux.
+
+This is needed for making it build with musl libc.
+---
+ lib/Support/DynamicLibrary.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp
+index 9a7aeb5..0c1c8f8 100644
+--- a/lib/Support/DynamicLibrary.cpp
++++ b/lib/Support/DynamicLibrary.cpp
+@@ -140,10 +140,10 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
+ #define EXPLICIT_SYMBOL(SYM) \
+ if (!strcmp(symbolName, #SYM)) return &SYM
+
+-// On linux we have a weird situation. The stderr/out/in symbols are both
++// On GNU libc we have a weird situation. The stderr/out/in symbols are both
+ // macros and global variables because of standards requirements. So, we
+ // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
+-#if defined(__linux__) and !defined(__ANDROID__)
++#if defined(__GLIBC__)
+ {
+ EXPLICIT_SYMBOL(stderr);
+ EXPLICIT_SYMBOL(stdout);
+--
+2.7.3
+
diff --git a/patches/llvm_host/llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch b/patches/llvm_host/llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch
new file mode 100644
index 00000000..9945bf35
--- /dev/null
+++ b/patches/llvm_host/llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch
@@ -0,0 +1,99 @@
+From c8ce9e59a883f452bc538b5f16fb83649472dc3e Mon Sep 17 00:00:00 2001
+From: Keno Fischer <kfischer@college.harvard.edu>
+Date: Wed, 13 Jul 2016 01:28:12 +0000
+Subject: [PATCH] Fix ScalarEvolutionExpander step scaling bug
+
+The expandAddRecExprLiterally function incorrectly transforms
+`[Start + Step * X]` into `Step * [Start + X]` instead of the correct
+transform of `[Step * X] + Start`.
+
+This caused https://github.com/JuliaLang/julia/issues/14704#issuecomment-174126219
+due to what appeared to be sufficiently complicated loop interactions.
+
+Patch by Jameson Nash (jameson@juliacomputing.com).
+
+Reviewers: sanjoy
+Differential Revision: http://reviews.llvm.org/D16505
+
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275239 91177308-0d34-0410-b5e6-96231b3b80d8
+
+Alpine maintainer notes:
+This patch replaces deps/patches/llvm-3.7.1_3.patch from Julia.
+---
+ lib/Analysis/ScalarEvolutionExpander.cpp | 7 ++++
+ .../ScalarEvolution/incorrect-offset-scaling.ll | 48 ++++++++++++++++++++++
+ 2 files changed, 55 insertions(+)
+ create mode 100644 test/Analysis/ScalarEvolution/incorrect-offset-scaling.ll
+
+diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp
+index 7716435..77e4ec7 100644
+--- a/lib/Analysis/ScalarEvolutionExpander.cpp
++++ b/lib/Analysis/ScalarEvolutionExpander.cpp
+@@ -1288,6 +1288,13 @@ Value *SCEVExpander::expandAddRecExprLiterally(const SCEVAddRecExpr *S) {
+ if (!SE.dominates(Step, L->getHeader())) {
+ PostLoopScale = Step;
+ Step = SE.getConstant(Normalized->getType(), 1);
++ if (!Start->isZero()) {
++ // The normalization below assumes that Start is constant zero, so if
++ // it isn't re-associate Start to PostLoopOffset.
++ assert(!PostLoopOffset && "Start not-null but PostLoopOffset set?");
++ PostLoopOffset = Start;
++ Start = SE.getConstant(Normalized->getType(), 0);
++ }
+ Normalized =
+ cast<SCEVAddRecExpr>(SE.getAddRecExpr(
+ Start, Step, Normalized->getLoop(),
+diff --git a/test/Analysis/ScalarEvolution/incorrect-offset-scaling.ll b/test/Analysis/ScalarEvolution/incorrect-offset-scaling.ll
+new file mode 100644
+index 0000000..7ffb093
+--- /dev/null
++++ b/test/Analysis/ScalarEvolution/incorrect-offset-scaling.ll
+@@ -0,0 +1,48 @@
++; RUN: opt -S -loop-reduce < %s | FileCheck %s
++
++target triple = "x86_64-unknown-unknown"
++target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
++
++define void @incorrect_offset_scaling(i64, i64*) {
++top:
++ br label %L
++
++L: ; preds = %idxend.10, %idxend, %L2, %top
++ br i1 undef, label %L, label %L1
++
++L1: ; preds = %L1.preheader, %L2
++ %r13 = phi i64 [ %r1, %L2 ], [ 1, %L ]
++; CHECK: %lsr.iv = phi i64 [ 0, %L{{[^ ]+}} ], [ %lsr.iv.next, %L2 ]
++; CHECK-NOT: %lsr.iv = phi i64 [ -1, %L{{[^ ]+}} ], [ %lsr.iv.next, %L2 ]
++; CHECK: br
++ %r0 = add i64 %r13, -1
++ br label %idxend.8
++
++L2: ; preds = %idxend.8
++ %r1 = add i64 %r13, 1
++ br i1 undef, label %L, label %L1
++
++if6: ; preds = %idxend.8
++ %r2 = add i64 %0, -1
++ %r3 = load i64, i64* %1, align 8
++; CHECK-NOT: %r2
++; CHECK: %r3 = load i64
++ br label %ib
++
++idxend.8: ; preds = %L1
++ br i1 undef, label %if6, label %L2
++
++ib: ; preds = %if6
++ %r4 = mul i64 %r3, %r0
++ %r5 = add i64 %r2, %r4
++ %r6 = icmp ult i64 %r5, undef
++; CHECK %2 = mul i64 %lsr.iv, %r3
++; CHECK %3 = add i64 %1, -1
++; CHECK %4 = add i64 %0, %r3
++; CHECK %r6
++ %r7 = getelementptr i64, i64* undef, i64 %r5
++ store i64 1, i64* %r7, align 8
++; CHECK %5 = mul i64 %lsr.iv, %r3
++; CHECK %6 = add i64 %5, -1
++ br label %L
++}
diff --git a/patches/llvm_host/llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch b/patches/llvm_host/llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch
new file mode 100644
index 00000000..7f891b66
--- /dev/null
+++ b/patches/llvm_host/llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch
@@ -0,0 +1,181 @@
+From 1ca1fcaa5b4c75a65a202badfd5df8240a36ca0f Mon Sep 17 00:00:00 2001
+From: "Arch D. Robison" <arch.robison@intel.com>
+Date: Mon, 25 Apr 2016 22:22:39 +0000
+Subject: [PATCH] Optimize store of "bitcast" from vector to aggregate.
+
+This patch is what was the "instcombine" portion of D14185, with an additional
+test added (see julia_pseudovec in test/Transforms/InstCombine/insert-val-extract-elem.ll).
+The patch causes instcombine to replace sequences of extractelement-insertvalue-store
+that act essentially like a bitcast followed by a store.
+
+Differential review: http://reviews.llvm.org/D14260
+
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267482 91177308-0d34-0410-b5e6-96231b3b80d8
+
+Alpine maintainer notes:
+ - Updated for llvm 3.8.1.
+ - This patch replaces llvm-D14260.patch from Julia.
+---
+ .../InstCombine/InstCombineLoadStoreAlloca.cpp | 60 ++++++++++++++++++
+ .../InstCombine/insert-val-extract-elem.ll | 74 ++++++++++++++++++++++
+ 2 files changed, 134 insertions(+)
+ create mode 100644 test/Transforms/InstCombine/insert-val-extract-elem.ll
+
+diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+index 96f0908..0ee6045 100644
+--- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
++++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+@@ -913,6 +913,61 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
+ return nullptr;
+ }
+
++/// \brief Look for extractelement/insertvalue sequence that acts like a bitcast.
++///
++/// \returns underlying value that was "cast", or nullptr otherwise.
++///
++/// For example, if we have:
++///
++/// %E0 = extractelement <2 x double> %U, i32 0
++/// %V0 = insertvalue [2 x double] undef, double %E0, 0
++/// %E1 = extractelement <2 x double> %U, i32 1
++/// %V1 = insertvalue [2 x double] %V0, double %E1, 1
++///
++/// and the layout of a <2 x double> is isomorphic to a [2 x double],
++/// then %V1 can be safely approximated by a conceptual "bitcast" of %U.
++/// Note that %U may contain non-undef values where %V1 has undef.
++static Value *likeBitCastFromVector(InstCombiner &IC, Value *V) {
++ Value *U = nullptr;
++ while (auto *IV = dyn_cast<InsertValueInst>(V)) {
++ auto *E = dyn_cast<ExtractElementInst>(IV->getInsertedValueOperand());
++ if (!E)
++ return nullptr;
++ auto *W = E->getVectorOperand();
++ if (!U)
++ U = W;
++ else if (U != W)
++ return nullptr;
++ auto *CI = dyn_cast<ConstantInt>(E->getIndexOperand());
++ if (!CI || IV->getNumIndices() != 1 || CI->getZExtValue() != *IV->idx_begin())
++ return nullptr;
++ V = IV->getAggregateOperand();
++ }
++ if (!isa<UndefValue>(V) ||!U)
++ return nullptr;
++
++ auto *UT = cast<VectorType>(U->getType());
++ auto *VT = V->getType();
++ // Check that types UT and VT are bitwise isomorphic.
++ const auto &DL = IC.getDataLayout();
++ if (DL.getTypeStoreSizeInBits(UT) != DL.getTypeStoreSizeInBits(VT)) {
++ return nullptr;
++ }
++ if (auto *AT = dyn_cast<ArrayType>(VT)) {
++ if (AT->getNumElements() != UT->getNumElements())
++ return nullptr;
++ } else {
++ auto *ST = cast<StructType>(VT);
++ if (ST->getNumElements() != UT->getNumElements())
++ return nullptr;
++ for (const auto *EltT : ST->elements()) {
++ if (EltT != UT->getElementType())
++ return nullptr;
++ }
++ }
++ return U;
++}
++
+ /// \brief Combine stores to match the type of value being stored.
+ ///
+ /// The core idea here is that the memory does not have any intrinsic type and
+@@ -924,6 +979,11 @@
+ return true;
+ }
+
++ if (Value *U = likeBitCastFromVector(IC, V)) {
++ combineStoreToNewValue(IC, SI, U);
++ return true;
++ }
++
+ // FIXME: We should also canonicalize loads of vectors when their elements are
+ // cast to other types.
+ return false;
+diff --git a/test/Transforms/InstCombine/insert-val-extract-elem.ll b/test/Transforms/InstCombine/insert-val-extract-elem.ll
+new file mode 100644
+index 0000000..db7b403
+--- /dev/null
++++ b/test/Transforms/InstCombine/insert-val-extract-elem.ll
+@@ -0,0 +1,74 @@
++; RUN: opt -S -instcombine %s | FileCheck %s
++
++; CHECK-LABEL: julia_2xdouble
++; CHECK-NOT: insertvalue
++; CHECK-NOT: extractelement
++; CHECK: store <2 x double>
++define void @julia_2xdouble([2 x double]* sret, <2 x double>*) {
++top:
++ %x = load <2 x double>, <2 x double>* %1
++ %x0 = extractelement <2 x double> %x, i32 0
++ %i0 = insertvalue [2 x double] undef, double %x0, 0
++ %x1 = extractelement <2 x double> %x, i32 1
++ %i1 = insertvalue [2 x double] %i0, double %x1, 1
++ store [2 x double] %i1, [2 x double]* %0, align 4
++ ret void
++}
++
++; Test with two inserts to the same index
++; CHECK-LABEL: julia_2xi64
++; CHECK-NOT: insertvalue
++; CHECK-NOT: extractelement
++; CHECK: store <2 x i64>
++define void @julia_2xi64([2 x i64]* sret, <2 x i64>*) {
++top:
++ %x = load <2 x i64>, <2 x i64>* %1
++ %x0 = extractelement <2 x i64> %x, i32 1
++ %i0 = insertvalue [2 x i64] undef, i64 %x0, 0
++ %x1 = extractelement <2 x i64> %x, i32 1
++ %i1 = insertvalue [2 x i64] %i0, i64 %x1, 1
++ %x2 = extractelement <2 x i64> %x, i32 0
++ %i2 = insertvalue [2 x i64] %i1, i64 %x2, 0
++ store [2 x i64] %i2, [2 x i64]* %0, align 4
++ ret void
++}
++
++; CHECK-LABEL: julia_4xfloat
++; CHECK-NOT: insertvalue
++; CHECK-NOT: extractelement
++; CHECK: store <4 x float>
++define void @julia_4xfloat([4 x float]* sret, <4 x float>*) {
++top:
++ %x = load <4 x float>, <4 x float>* %1
++ %x0 = extractelement <4 x float> %x, i32 0
++ %i0 = insertvalue [4 x float] undef, float %x0, 0
++ %x1 = extractelement <4 x float> %x, i32 1
++ %i1 = insertvalue [4 x float] %i0, float %x1, 1
++ %x2 = extractelement <4 x float> %x, i32 2
++ %i2 = insertvalue [4 x float] %i1, float %x2, 2
++ %x3 = extractelement <4 x float> %x, i32 3
++ %i3 = insertvalue [4 x float] %i2, float %x3, 3
++ store [4 x float] %i3, [4 x float]* %0, align 4
++ ret void
++}
++
++%pseudovec = type { float, float, float, float }
++
++; CHECK-LABEL: julia_pseudovec
++; CHECK-NOT: insertvalue
++; CHECK-NOT: extractelement
++; CHECK: store <4 x float>
++define void @julia_pseudovec(%pseudovec* sret, <4 x float>*) {
++top:
++ %x = load <4 x float>, <4 x float>* %1
++ %x0 = extractelement <4 x float> %x, i32 0
++ %i0 = insertvalue %pseudovec undef, float %x0, 0
++ %x1 = extractelement <4 x float> %x, i32 1
++ %i1 = insertvalue %pseudovec %i0, float %x1, 1
++ %x2 = extractelement <4 x float> %x, i32 2
++ %i2 = insertvalue %pseudovec %i1, float %x2, 2
++ %x3 = extractelement <4 x float> %x, i32 3
++ %i3 = insertvalue %pseudovec %i2, float %x3, 3
++ store %pseudovec %i3, %pseudovec* %0, align 4
++ ret void
++}
diff --git a/patches/llvm_host/llvm-0006-clone-every-functions-debug-info.patch b/patches/llvm_host/llvm-0006-clone-every-functions-debug-info.patch
new file mode 100644
index 00000000..567ddcad
--- /dev/null
+++ b/patches/llvm_host/llvm-0006-clone-every-functions-debug-info.patch
@@ -0,0 +1,129 @@
+From 11adcc4de0797c83e61ae0240927f0bafcf041a9 Mon Sep 17 00:00:00 2001
+From: Keno Fischer <kfischer@college.harvard.edu>
+Date: Sat, 13 Feb 2016 02:04:29 +0000
+Subject: [PATCH] [Cloning] Clone every Function's Debug Info
+
+Summary:
+Export the CloneDebugInfoMetadata utility, which clones all debug info
+associated with a function into the first module. Also use this function
+in CloneModule on each function we clone (the CloneFunction entrypoint
+already does this).
+
+Without this, cloning a module will lead to DI quality regressions,
+especially since r252219 reversed the Function <-> DISubprogram edge
+(before we could get lucky and have this edge preserved if the
+DISubprogram itself was, e.g. due to location metadata).
+
+This was verified to fix missing debug information in julia and
+a unittest to verify the new behavior is included.
+
+Patch by Yichao Yu! Thanks!
+
+Reviewers: loladiro, pcc
+Differential Revision: http://reviews.llvm.org/D17165
+
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260791 91177308-0d34-0410-b5e6-96231b3b80d8
+
+Alpine maintainer notes:
+ - Corresponds to llvm-D17165-D18583.patch in Julia.
+---
+ include/llvm/Transforms/Utils/Cloning.h | 5 +++++
+ lib/Transforms/Utils/CloneFunction.cpp | 4 ++--
+ lib/Transforms/Utils/CloneModule.cpp | 1 +
+ unittests/Transforms/Utils/Cloning.cpp | 25 +++++++++++++++++++++++++
+ 4 files changed, 33 insertions(+), 2 deletions(-)
+
+diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h
+index 4f006f2..0bae2bd 100644
+--- a/include/llvm/Transforms/Utils/Cloning.h
++++ b/include/llvm/Transforms/Utils/Cloning.h
+@@ -130,6 +130,11 @@ Function *CloneFunction(const Function *F, ValueToValueMapTy &VMap,
+ bool ModuleLevelChanges,
+ ClonedCodeInfo *CodeInfo = nullptr);
+
++/// Clone the module-level debug info associated with OldFunc. The cloned data
++/// will point to NewFunc instead.
++void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
++ ValueToValueMapTy &VMap);
++
+ /// Clone OldFunc into NewFunc, transforming the old arguments into references
+ /// to VMap values. Note that if NewFunc already has basic blocks, the ones
+ /// cloned into it will be added to the end of the function. This function
+diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
+index 6454afb..8b5692a 100644
+--- a/lib/Transforms/Utils/CloneFunction.cpp
++++ b/lib/Transforms/Utils/CloneFunction.cpp
+@@ -187,8 +187,8 @@ static void AddOperand(DICompileUnit *CU, DISubprogramArray SPs,
+
+ // Clone the module-level debug info associated with OldFunc. The cloned data
+ // will point to NewFunc instead.
+-static void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
+- ValueToValueMapTy &VMap) {
++void llvm::CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
++ ValueToValueMapTy &VMap) {
+ DebugInfoFinder Finder;
+ Finder.processModule(*OldFunc->getParent());
+
+diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp
+index 53de62a..b16a02a 100644
+--- a/lib/Transforms/Utils/CloneModule.cpp
++++ b/lib/Transforms/Utils/CloneModule.cpp
+@@ -136,6 +136,7 @@ std::unique_ptr<Module> llvm::CloneModule(
+ VMap[&*J] = &*DestI++;
+ }
+
++ CloneDebugInfoMetadata(F, &*I, VMap);
+ SmallVector<ReturnInst*, 8> Returns; // Ignore returns cloned.
+ CloneFunctionInto(F, &*I, VMap, /*ModuleLevelChanges=*/true, Returns);
+ }
+diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp
+index 25e322e..b761e4e 100644
+--- a/unittests/Transforms/Utils/Cloning.cpp
++++ b/unittests/Transforms/Utils/Cloning.cpp
+@@ -423,6 +423,7 @@ class CloneModule : public ::testing::Test {
+ void SetupModule() { OldM = new Module("", C); }
+
+ void CreateOldModule() {
++ DIBuilder DBuilder(*OldM);
+ IRBuilder<> IBuilder(C);
+
+ auto *FuncType = FunctionType::get(Type::getVoidTy(C), false);
+@@ -431,9 +432,25 @@ class CloneModule : public ::testing::Test {
+ auto *F =
+ Function::Create(FuncType, GlobalValue::PrivateLinkage, "f", OldM);
+ F->setPersonalityFn(PersFn);
++
++ // Create debug info
++ auto *File = DBuilder.createFile("filename.c", "/file/dir/");
++ DITypeRefArray ParamTypes = DBuilder.getOrCreateTypeArray(None);
++ DISubroutineType *DFuncType = DBuilder.createSubroutineType(ParamTypes);
++ auto *CU =
++ DBuilder.createCompileUnit(dwarf::DW_LANG_C99, "filename.c",
++ "/file/dir", "CloneModule", false, "", 0);
++ // Function DI
++ auto *Subprogram = DBuilder.createFunction(CU, "f", "f", File, 4, DFuncType,
++ true, true, 3, 0, false);
++ F->setSubprogram(Subprogram);
++
+ auto *Entry = BasicBlock::Create(C, "", F);
+ IBuilder.SetInsertPoint(Entry);
+ IBuilder.CreateRetVoid();
++
++ // Finalize the debug info
++ DBuilder.finalize();
+ }
+
+ void CreateNewModule() { NewM = llvm::CloneModule(OldM).release(); }
+@@ -447,4 +464,12 @@ TEST_F(CloneModule, Verify) {
+ EXPECT_FALSE(verifyModule(*NewM));
+ }
+
++TEST_F(CloneModule, Subprogram) {
++ Function *NewF = NewM->getFunction("f");
++ DISubprogram *SP = NewF->getSubprogram();
++ EXPECT_TRUE(SP != nullptr);
++ EXPECT_EQ(SP->getName(), "f");
++ EXPECT_EQ(SP->getFile()->getFilename(), "filename.c");
++ EXPECT_EQ(SP->getLine(), (unsigned)4);
++}
+ }
diff --git a/patches/llvm_host/llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch b/patches/llvm_host/llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch
new file mode 100644
index 00000000..0930c28e
--- /dev/null
+++ b/patches/llvm_host/llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch
@@ -0,0 +1,102 @@
+From af289e04413504c3bdc252e08c3fe17bf7ea6dc8 Mon Sep 17 00:00:00 2001
+From: Peter Collingbourne <peter@pcc.me.uk>
+Date: Wed, 30 Mar 2016 22:05:13 +0000
+Subject: [PATCH] Cloning: Reduce complexity of debug info cloning and fix
+ correctness issue.
+
+Commit r260791 contained an error in that it would introduce a cross-module
+reference in the old module. It also introduced O(N^2) complexity in the
+module cloner by requiring the entire module to be visited for each function.
+Fix both of these problems by avoiding use of the CloneDebugInfoMetadata
+function (which is only designed to do intra-module cloning) and cloning
+function-attached metadata in the same way that we clone all other metadata.
+
+Differential Revision: http://reviews.llvm.org/D18583
+
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264935 91177308-0d34-0410-b5e6-96231b3b80d8
+
+Alpine maintainer notes:
+ - Corresponds to llvm-D17165-D18583.patch in Julia.
+---
+ include/llvm/Transforms/Utils/Cloning.h | 5 -----
+ lib/Transforms/Utils/CloneFunction.cpp | 13 +++++++++++--
+ lib/Transforms/Utils/CloneModule.cpp | 1 -
+ unittests/Transforms/Utils/Cloning.cpp | 6 ++++++
+ 4 files changed, 17 insertions(+), 8 deletions(-)
+
+diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h
+index 0bae2bd..4f006f2 100644
+--- a/include/llvm/Transforms/Utils/Cloning.h
++++ b/include/llvm/Transforms/Utils/Cloning.h
+@@ -130,11 +130,6 @@ Function *CloneFunction(const Function *F, ValueToValueMapTy &VMap,
+ bool ModuleLevelChanges,
+ ClonedCodeInfo *CodeInfo = nullptr);
+
+-/// Clone the module-level debug info associated with OldFunc. The cloned data
+-/// will point to NewFunc instead.
+-void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
+- ValueToValueMapTy &VMap);
+-
+ /// Clone OldFunc into NewFunc, transforming the old arguments into references
+ /// to VMap values. Note that if NewFunc already has basic blocks, the ones
+ /// cloned into it will be added to the end of the function. This function
+diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
+index 05b0a17..8e1715a 100644
+--- a/lib/Transforms/Utils/CloneFunction.cpp
++++ b/lib/Transforms/Utils/CloneFunction.cpp
+@@ -119,6 +119,15 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
+ .addAttributes(NewFunc->getContext(), AttributeSet::FunctionIndex,
+ OldAttrs.getFnAttributes()));
+
++ SmallVector<std::pair<unsigned, MDNode *>, 1> MDs;
++ OldFunc->getAllMetadata(MDs);
++ for (auto MD : MDs)
++ NewFunc->setMetadata(
++ MD.first,
++ MapMetadata(MD.second, VMap,
++ ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges,
++ TypeMapper, Materializer));
++
+ // Loop over all of the basic blocks in the function, cloning them as
+ // appropriate. Note that we save BE this way in order to handle cloning of
+ // recursive functions into themselves.
+@@ -187,8 +196,8 @@ static void AddOperand(DICompileUnit *CU, DISubprogramArray SPs,
+
+ // Clone the module-level debug info associated with OldFunc. The cloned data
+ // will point to NewFunc instead.
+-void llvm::CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
+- ValueToValueMapTy &VMap) {
++static void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
++ ValueToValueMapTy &VMap) {
+ DebugInfoFinder Finder;
+ Finder.processModule(*OldFunc->getParent());
+
+diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp
+index 494e275..929f51b 100644
+--- a/lib/Transforms/Utils/CloneModule.cpp
++++ b/lib/Transforms/Utils/CloneModule.cpp
+@@ -138,7 +138,6 @@ std::unique_ptr<Module> llvm::CloneModule(
+ VMap[&*J] = &*DestI++;
+ }
+
+- CloneDebugInfoMetadata(F, &*I, VMap);
+ SmallVector<ReturnInst*, 8> Returns; // Ignore returns cloned.
+ CloneFunctionInto(F, &*I, VMap, /*ModuleLevelChanges=*/true, Returns);
+ }
+diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp
+index b761e4e..f06a20f 100644
+--- a/unittests/Transforms/Utils/Cloning.cpp
++++ b/unittests/Transforms/Utils/Cloning.cpp
+@@ -464,6 +464,12 @@ TEST_F(CloneModule, Verify) {
+ EXPECT_FALSE(verifyModule(*NewM));
+ }
+
++TEST_F(CloneModule, OldModuleUnchanged) {
++ DebugInfoFinder Finder;
++ Finder.processModule(*OldM);
++ EXPECT_EQ(1U, Finder.subprogram_count());
++}
++
+ TEST_F(CloneModule, Subprogram) {
+ Function *NewF = NewM->getFunction("f");
+ DISubprogram *SP = NewF->getSubprogram();
diff --git a/patches/llvm_host/llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch b/patches/llvm_host/llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch
new file mode 100644
index 00000000..b66584dc
--- /dev/null
+++ b/patches/llvm_host/llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch
@@ -0,0 +1,107 @@
+From 3c80c2658022201214241e9229ac35097cc476d2 Mon Sep 17 00:00:00 2001
+From: Eli Friedman <eli.friedman@gmail.com>
+Date: Thu, 16 Jun 2016 02:33:42 +0000
+Subject: [PATCH] [InstCombine] Don't widen metadata on store-to-load
+ forwarding
+
+The original check for load CSE or store-to-load forwarding is wrong
+when the forwarded stored value happened to be a load.
+
+Ref https://github.com/JuliaLang/julia/issues/16894
+
+Differential Revision: http://reviews.llvm.org/D21271
+
+Patch by Yichao Yu!
+
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272868 91177308-0d34-0410-b5e6-96231b3b80d8
+
+Alpine maintainer notes:
+ - Updated for llvm 3.8.1.
+ - Corresponds to llvm-D21271-instcombine-tbaa-3.8.patch in Julia.
+---
+ include/llvm/Analysis/Loads.h | 3 ++-
+ lib/Analysis/Loads.cpp | 5 ++++-
+ .../InstCombine/InstCombineLoadStoreAlloca.cpp | 6 ++++--
+ test/Transforms/InstCombine/tbaa-store-to-load.ll | 17 +++++++++++++++++
+ 4 files changed, 27 insertions(+), 4 deletions(-)
+ create mode 100644 test/Transforms/InstCombine/tbaa-store-to-load.ll
+
+diff --git a/include/llvm/Analysis/Loads.h b/include/llvm/Analysis/Loads.h
+index e5bd0c8..9d24b7b 100644
+--- a/include/llvm/Analysis/Loads.h
++++ b/include/llvm/Analysis/Loads.h
+@@ -82,7 +82,8 @@ Value *FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
+ BasicBlock::iterator &ScanFrom,
+ unsigned MaxInstsToScan = DefMaxInstsToScan,
+ AliasAnalysis *AA = nullptr,
+- AAMDNodes *AATags = nullptr);
++ AAMDNodes *AATags = nullptr,
++ bool *IsLoadCSE = nullptr);
+
+ }
+
+diff --git a/lib/Analysis/Loads.cpp b/lib/Analysis/Loads.cpp
+index dce243c..7d3fd59 100644
+--- a/lib/Analysis/Loads.cpp
++++ b/lib/Analysis/Loads.cpp
+@@ -322,7 +322,8 @@ llvm::DefMaxInstsToScan("available-load-scan-limit", cl::init(6), cl::Hidden,
+ Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
+ BasicBlock::iterator &ScanFrom,
+ unsigned MaxInstsToScan,
+- AliasAnalysis *AA, AAMDNodes *AATags) {
++ AliasAnalysis *AA, AAMDNodes *AATags,
++ bool *IsLoadCSE) {
+ if (MaxInstsToScan == 0)
+ MaxInstsToScan = ~0U;
+
+@@ -374,6 +375,8 @@ Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
+
+ if (AATags)
+ LI->getAAMetadata(*AATags);
++ if (IsLoadCSE)
++ *IsLoadCSE = true;
+ return LI;
+ }
+
+diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+index 6a5d5a6..d312983 100644
+--- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
++++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+@@ -800,10 +800,12 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
+ // separated by a few arithmetic operations.
+ BasicBlock::iterator BBI(LI);
+ AAMDNodes AATags;
++ bool IsLoadCSE = false;
+ if (Value *AvailableVal =
+ FindAvailableLoadedValue(Op, LI.getParent(), BBI,
+- DefMaxInstsToScan, AA, &AATags)) {
+- if (LoadInst *NLI = dyn_cast<LoadInst>(AvailableVal)) {
++ DefMaxInstsToScan, AA, &AATags, &IsLoadCSE)) {
++ if (IsLoadCSE) {
++ LoadInst *NLI = cast<LoadInst>(AvailableVal);
+ unsigned KnownIDs[] = {
+ LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope,
+ LLVMContext::MD_noalias, LLVMContext::MD_range,
+diff --git a/test/Transforms/InstCombine/tbaa-store-to-load.ll b/test/Transforms/InstCombine/tbaa-store-to-load.ll
+new file mode 100644
+index 0000000..707be73
+--- /dev/null
++++ b/test/Transforms/InstCombine/tbaa-store-to-load.ll
+@@ -0,0 +1,17 @@
++; RUN: opt -S -instcombine < %s 2>&1 | FileCheck %s
++
++define i64 @f(i64* %p1, i64* %p2) {
++top:
++ ; check that the tbaa is preserved
++ ; CHECK-LABEL: @f(
++ ; CHECK: %v1 = load i64, i64* %p1, align 8, !tbaa !0
++ ; CHECK: store i64 %v1, i64* %p2, align 8
++ ; CHECK: ret i64 %v1
++ %v1 = load i64, i64* %p1, align 8, !tbaa !0
++ store i64 %v1, i64* %p2, align 8
++ %v2 = load i64, i64* %p2, align 8
++ ret i64 %v2
++}
++
++!0 = !{!1, !1, i64 0}
++!1 = !{!"load_tbaa"}
diff --git a/patches/llvm_host/llvm-0009-nm-workaround.patch b/patches/llvm_host/llvm-0009-nm-workaround.patch
new file mode 100644
index 00000000..5755e57f
--- /dev/null
+++ b/patches/llvm_host/llvm-0009-nm-workaround.patch
@@ -0,0 +1,27 @@
+From https://llvm.org/bugs/show_bug.cgi?id=24115
+
+diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
+index e7ee312..b9e4779 100644
+--- a/tools/llvm-nm/llvm-nm.cpp
++++ b/tools/llvm-nm/llvm-nm.cpp
+@@ -486,7 +486,7 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
+ std::string ArchiveName,
+ std::string ArchitectureName) {
+ if (!NoSort) {
+- std::function<bool(const NMSymbol &, const NMSymbol &)> Cmp;
++ bool (*Cmp)(const NMSymbol &, const NMSymbol &);
+ if (NumericSort)
+ Cmp = compareSymbolAddress;
+ else if (SizeSort)
+@@ -495,8 +495,9 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
+ Cmp = compareSymbolName;
+
+ if (ReverseSort)
+- Cmp = [=](const NMSymbol &A, const NMSymbol &B) { return Cmp(B, A); };
+- std::sort(SymbolList.begin(), SymbolList.end(), Cmp);
++ std::sort(SymbolList.begin(), SymbolList.end(), [=](const NMSymbol &A, const NMSymbol &B) { return Cmp(B, A); });
++ else
++ std::sort(SymbolList.begin(), SymbolList.end(), Cmp);
+ }
+
+ if (!PrintFileName) {
diff --git a/vars/build.vars b/vars/build.vars
index 8f7f524d..1fd92d8b 100644
--- a/vars/build.vars
+++ b/vars/build.vars
@@ -84,11 +84,11 @@ HOST_TOOLCHAIN_PREFIX="${PREFIX_CROSS}";
: ${PKG_SLIBTOOL_HOST_URL:=${GITROOT}/slibtool};
: ${PKG_SLIBTOOL_HOST_URL_TYPE:=git};
: ${PKG_SLIBTOOL_HOST_CONFIGURE_ARGS:=--host= --prefix=};
-: ${PKG_SLIBTOOL_HOST_MAKEFLAGS_INSTALL=DESTDIR=${PREFIX}};
+: ${PKG_SLIBTOOL_HOST_MAKEFLAGS_INSTALL:=DESTDIR=${PREFIX}};
: ${PKG_PERK_HOST_URL:=${GITROOT}/perk};
: ${PKG_PERK_HOST_URL_TYPE:=git};
-: ${PKG_PERK_HOST_CONFIGURE_ARGS="--prefix=/usr"};
-: ${PKG_PERK_HOST_MAKEFLAGS_INSTALL="DESTDIR=${PREFIX}"};
+: ${PKG_PERK_HOST_CONFIGURE_ARGS:="--prefix=/usr"};
+: ${PKG_PERK_HOST_MAKEFLAGS_INSTALL:="DESTDIR=${PREFIX}"};
: ${PKG_BINUTILS_HOST_SHA256SUM:=250d3b2925c6b211fb16173b0b25bc091c58829fbcad3eb849645e0af52cf7fa};
: ${PKG_BINUTILS_HOST_VERSION:=2.24.51};
: ${PKG_BINUTILS_HOST_URL:=ftp://sourceware.org/pub/binutils/snapshots/binutils-${PKG_BINUTILS_HOST_VERSION}.tar.bz2};
@@ -116,10 +116,10 @@ NATIVE_TOOLCHAIN_PACKAGES="slibtool perk pkgconf gmp mpfr mpc libelf binutils mu
NATIVE_TOOLCHAIN_PREFIX="${PREFIX_NATIVE}";
: ${PKG_SLIBTOOL_URL:=git://midipix.org/slibtool};
: ${PKG_SLIBTOOL_URL_TYPE:=git};
-: ${PKG_SLIBTOOL_CONFIGURE_ARGS="--host=${TARGET} --prefix= --target=${TARGET}"};
+: ${PKG_SLIBTOOL_CONFIGURE_ARGS:="--host=${TARGET} --prefix= --target=${TARGET}"};
: ${PKG_PERK_URL:=${GITROOT}/perk};
: ${PKG_PERK_URL_TYPE:=git};
-: ${PKG_PERK_CONFIGURE_ARGS="--prefix=/usr --target=${TARGET}"};
+: ${PKG_PERK_CONFIGURE_ARGS:="--prefix=/usr --target=${TARGET}"};
: ${PKG_PKGCONF_SHA256SUM:=7ec8b516e655e247f4ba976837cee808134785819ab8f538f652fe919cc6c09f};
: ${PKG_PKGCONF_VERSION:=0.9.12};
: ${PKG_PKGCONF_URL:=https://github.com/pkgconf/pkgconf/releases/download/pkgconf-${PKG_PKGCONF_VERSION}/pkgconf-${PKG_PKGCONF_VERSION}.tar.bz2};
@@ -186,7 +186,7 @@ RUNTIME_URL_TYPE="git";
: ${PKG_PSXSCL_INSTALL_TARGET_EXTRA:=install-lib};
: ${PKG_PSXSCL_PREFIX_EXTRA:=${PREFIX_MINIPIX}};
: ${PKG_PSXSCL_STRACE_URL:=${GITROOT_HEAD}/psxscl};
-: ${PKG_PSXSCL_STRACE_CFLAGS_CONFIGURE_EXTRA="-DPSX_INTERNAL_STRACE -O0"};
+: ${PKG_PSXSCL_STRACE_CFLAGS_CONFIGURE_EXTRA:="-DPSX_INTERNAL_STRACE -O0"};
: ${PKG_PSXSCL_STRACE_INSTALL_FILES:="/=lib/psxscl_strace lib/libpsxscl.so=lib/psxscl_strace/"};
: ${PKG_PSXSCL_STRACE_NO_MAKE_INSTALL:=1};
: ${PKG_NTCTTY_URL:=${GITROOT_HEAD}/ntctty};
@@ -205,10 +205,10 @@ LIB_PACKAGES_CONFIGURE_ARGS="-C --disable-nls --host=${TARGET} --prefix= --targe
LIB_PACKAGES_LDFLAGS_CONFIGURE="--sysroot=${PREFIX_NATIVE}";
LIB_PACKAGES_MAKEFLAGS_INSTALL="DESTDIR=${PREFIX_NATIVE}";
LIB_PACKAGES_PACKAGES="
-bzip2 curl expat libz libffi gdbm pcre glib gzip libarchive libpipeline libressl libevent libfetch
-libgpg_error libassuan libfirm libgcrypt libksba lua ncurses ncursestw ncursesw npth xz inputproto
-kbproto xcb_proto xproto libXau libpthread_stubs xcb xextproto xtrans libX11 libXext libICE
-libSM libXt libXmu renderproto Xrender libXpm libXaw libxkbfile";
+bzip2 curl expat libz libffi gdbm pcre glib gzip libarchive libpipeline libressl libevent
+libfetch libgpg_error libassuan libfirm libgcrypt libksba lua ncurses ncursestw ncursesw
+npth xz inputproto kbproto xcb_proto xproto libXau libpthread_stubs xcb xextproto xtrans libX11
+libXext libICE libSM libXt libXmu renderproto Xrender libXpm libXaw libxkbfile cmake llvm_host";
LIB_PACKAGES_PREFIX="${PREFIX_NATIVE}";
: ${PKG_BZIP2_SHA256SUM:=a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd};
: ${PKG_BZIP2_VERSION:=1.0.6};
@@ -305,7 +305,7 @@ LIB_PACKAGES_PREFIX="${PREFIX_NATIVE}";
: ${PKG_LUA_SHA256SUM:=5113c06884f7de453ce57702abaac1d618307f33f6789fa870e87a59d772aca2};
: ${PKG_LUA_VERSION:=5.3.3};
: ${PKG_LUA_URL:=https://www.lua.org/ftp/lua-${PKG_LUA_VERSION}.tar.gz};
-: ${PKG_LUA_BUILD_DIR=lua-5.3.3};
+: ${PKG_LUA_BUILD_DIR:=lua-5.3.3};
: ${PKG_LUA_MAKEFLAGS_BUILD_EXTRA:="CC=${TARGET}-gcc midipix"};
: ${PKG_LUA_MAKEFLAGS_INSTALL_EXTRA:=INSTALL_TOP=${PREFIX_NATIVE}};
: ${PKG_NCURSES_SHA256SUM:=f551c24b30ce8bfb6e96d9f59b42fbea30fa3a6123384172f9e7284bcf647260};
@@ -395,6 +395,17 @@ LIB_PACKAGES_PREFIX="${PREFIX_NATIVE}";
: ${PKG_LIBXKBFILE_VERSION:=1.0.9};
: ${PKG_LIBXKBFILE_URL:=https://www.x.org/releases/individual/lib/libxkbfile-${PKG_LIBXKBFILE_VERSION}.tar.bz2};
+: ${PKG_CMAKE_SHA256SUM:=7d73ee4fae572eb2d7cd3feb48971aea903bb30a20ea5ae8b4da826d8ccad5fe};
+: ${PKG_CMAKE_VERSION:=3.6.3};
+: ${PKG_CMAKE_URL:=https://cmake.org/files/v${PKG_CMAKE_VERSION%.*}/cmake-${PKG_CMAKE_VERSION}.tar.gz};
+: ${PKG_CMAKE_CONFIGURE_ARGS:="--parallel=${BUILD_CPUS} --prefix="};
+: ${PKG_CMAKE_MAKEFLAGS_INSTALL:=};
+: ${PKG_LLVM_HOST_SHA256SUM:=6e82ce4adb54ff3afc18053d6981b6aed1406751b8742582ed50f04b5ab475f9};
+: ${PKG_LLVM_HOST_VERSION:=3.8.1};
+: ${PKG_LLVM_HOST_URL:=http://releases.llvm.org/${PKG_LLVM_HOST_VERSION}/llvm-${PKG_LLVM_HOST_VERSION}.src.tar.xz};
+: ${PKG_LLVM_HOST_BUILD_TYPE:=host};
+: ${PKG_LLVM_HOST_MAKEFLAGS_INSTALL:=DESTDIR=${PREFIX}};
+
#
# Build target leaf_packages
#
@@ -403,10 +414,10 @@ LEAF_PACKAGES_CONFIGURE_ARGS="-C --disable-nls --host=${TARGET} --prefix= --targ
LEAF_PACKAGES_LDFLAGS_CONFIGURE="--sysroot=${PREFIX_NATIVE}";
LEAF_PACKAGES_MAKEFLAGS_INSTALL="DESTDIR=${PREFIX_NATIVE}";
LEAF_PACKAGES_PACKAGES="
-apk_tools bash bc chicken cmake coreutils cparser cron dash datamash diffutils dos2unix ed figlet file findutils
-gawk git gnupg grep hexcurse htop inetutils infounzip infozip irssi john less lynx make man_db mc mksh nano netcat
-openssh p7zip pacman patch perl procps_ng python3 rsync rxvt_unicode sed tar tcsh the_silver_searcher tmux
-util_linux vim weechat wget which whois xeyes xwd zsh";
+apk_tools bash bc chicken clang_host coreutils cparser cron dash datamash diffutils dos2unix ed figlet
+file findutils gawk git gnupg grep hexcurse htop inetutils infounzip infozip irssi john less lynx make
+man_db mc mksh nano netcat openssh p7zip pacman patch perl procps_ng python3 rsync rxvt_unicode sed tar
+tcsh the_silver_searcher tmux util_linux vim weechat wget which whois xeyes xwd zsh";
LEAF_PACKAGES_PREFIX="${PREFIX_NATIVE}";
: ${PKG_APK_TOOLS_SHA256SUM:=def2b2c23cd12fd2a9c19be49653b0d1bf9d81a26dac5a0ee79a1351d674f93b};
: ${PKG_APK_TOOLS_VERSION:=2.6.8};
@@ -431,11 +442,11 @@ LEAF_PACKAGES_PREFIX="${PREFIX_NATIVE}";
: ${PKG_CHICKEN_MAKEFLAGS_BUILD_EXTRA_RELEASE:=DEBUGBUILD=0};
: ${PKG_CHICKEN_MAKEFLAGS_INSTALL:="PLATFORM=midipix-${ARCH} PREFIX=${PREFIX_NATIVE} TARGET_PREFIX=${PREFIX_NATIVE} C_COMPILER=${TARGET}-gcc HOSTSYSTEM=${TARGET} CROSS_CHICKEN=1"};
: ${PKG_CHICKEN_NO_CLEAN:=1};
-: ${PKG_CMAKE_SHA256SUM:=7d73ee4fae572eb2d7cd3feb48971aea903bb30a20ea5ae8b4da826d8ccad5fe};
-: ${PKG_CMAKE_VERSION:=3.6.3};
-: ${PKG_CMAKE_URL:=https://cmake.org/files/v${PKG_CMAKE_VERSION%.*}/cmake-${PKG_CMAKE_VERSION}.tar.gz};
-: ${PKG_CMAKE_CONFIGURE_ARGS:="--parallel=${BUILD_CPUS} --prefix="};
-: ${PKG_CMAKE_MAKEFLAGS_INSTALL:=};
+: ${PKG_CLANG_HOST_SHA256SUM:=4cd3836dfb4b88b597e075341cae86d61c63ce3963e45c7fe6a8bf59bb382cdf};
+: ${PKG_CLANG_HOST_VERSION:=3.8.1};
+: ${PKG_CLANG_HOST_URL:=http://releases.llvm.org/${PKG_CLANG_HOST_VERSION}/cfe-${PKG_CLANG_HOST_VERSION}.src.tar.xz};
+: ${PKG_CLANG_HOST_BUILD_TYPE:=host};
+: ${PKG_CLANG_HOST_MAKEFLAGS_INSTALL:=DESTDIR=${PREFIX}};
: ${PKG_COREUTILS_SHA256SUM:=155e94d748f8e2bc327c66e0cbebdb8d6ab265d2f37c3c928f7bf6c3beba9a8e};
: ${PKG_COREUTILS_VERSION:=8.26};
: ${PKG_COREUTILS_URL:=https://ftp.gnu.org/gnu/coreutils/coreutils-${PKG_COREUTILS_VERSION}.tar.xz};
@@ -473,7 +484,7 @@ LEAF_PACKAGES_PREFIX="${PREFIX_NATIVE}";
: ${PKG_ED_SHA256SUM:=c7a98062d0597b41295f03275a2ea07342b18b86653e3b9a51746b9983db8d48};
: ${PKG_ED_VERSION:=1.13};
: ${PKG_ED_URL:=http://ftp5.gwdg.de/pub/linux/slackware/slackware64-current/source/a/ed/ed-${PKG_ED_VERSION}.tar.xz};
-: ${PKG_ED_CONFIGURE_ARGS="--prefix= CC=${TARGET}-gcc"};
+: ${PKG_ED_CONFIGURE_ARGS:="--prefix= CC=${TARGET}-gcc"};
: ${PKG_FIGLET_SHA256SUM:=bf88c40fd0f077dab2712f54f8d39ac952e4e9f2e1882f1195be9e5e4257417d};
: ${PKG_FIGLET_VERSION:=2.2.5};
: ${PKG_FIGLET_URL:=ftp://ftp.figlet.org/pub/figlet/program/unix/figlet-${PKG_FIGLET_VERSION}.tar.gz};
@@ -514,7 +525,7 @@ LEAF_PACKAGES_PREFIX="${PREFIX_NATIVE}";
: ${PKG_HTOP_URL:=http://hisham.hm/htop/releases/${PKG_HTOP_VERSION}/htop-${PKG_HTOP_VERSION}.tar.gz};
: ${PKG_HTOP_CONFIGURE_ARGS_EXTRA:=--program-prefix=};
: ${PKG_INETUTILS_SHA256SUM:=849d96f136effdef69548a940e3e0ec0624fc0c81265296987986a0dd36ded37};
-: ${PKG_INETUTILS_VERSION=1.9.4};
+: ${PKG_INETUTILS_VERSION:=1.9.4};
: ${PKG_INETUTILS_URL:=https://ftp.gnu.org/gnu/inetutils/inetutils-${PKG_INETUTILS_VERSION}.tar.xz};
: ${PKG_INETUTILS_CONFIGURE_ARGS_EXTRA:="--disable-ftpd --disable-inetd --disable-rexecd --disable-rlogind --disable-rshd --disable-syslogd --disable-talkd --disable-telnetd --disable-tftpd --disable-uucpd --disable-ftp --disable-dnsdomainname --disable-hostname --disable-ping --disable-ping6 --disable-rcp --disable-rexec --disable-rlogin --disable-rsh --disable-logger --disable-talk --enable-telnet --disable-tftp --disable-whois --disable-ifconfig --disable-traceroute"};
: ${PKG_INFOUNZIP_SHA256SUM:=036d96991646d0449ed0aa952e4fbe21b476ce994abc276e49d30e686708bd37};
@@ -534,7 +545,7 @@ LEAF_PACKAGES_PREFIX="${PREFIX_NATIVE}";
: ${PKG_INFOZIP_NO_MAKE_INSTALL:=1};
: ${PKG_INFOZIP_SUBDIR:=${PKG_INFOZIP_BUILD_DIR}};
: ${PKG_IRSSI_SHA256SUM:=f5e20f76aa8237303c463e08adb3a3e3a400a24ba95acf73e9b068d634173f66};
-: ${PKG_IRSSI_VERSION=0.8.20};
+: ${PKG_IRSSI_VERSION:=0.8.20};
: ${PKG_IRSSI_URL:=https://github.com/irssi/irssi/releases/download/${PKG_IRSSI_VERSION}/irssi-${PKG_IRSSI_VERSION}.tar.gz};
: ${PKG_IRSSI_CONFIGURE_ARGS_EXTRA:=--with-ncurses=${PREFIX_NATIVE}};
: ${PKG_JOHN_SHA256SUM:=952cf68369fb5b27f2d112ce7ca1eb16b975c85cbce8c658abb8bc5a20e1b266};
diff --git a/vars/clang_host.vars b/vars/clang_host.vars
new file mode 100644
index 00000000..54f89c37
--- /dev/null
+++ b/vars/clang_host.vars
@@ -0,0 +1,28 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+#
+
+pkg_clang_host_pre_configure() {
+ secure_rm ${WORKDIR}/Makefile;
+};
+
+pkg_clang_host_configure() {
+ secure_rm ../cfe-${PKG_VERSION}-host;
+ insecure_mkdir ../cfe-${PKG_VERSION}-host;
+ cd ../cfe-${PKG_VERSION}-host;
+ log_msg info "Bootstrapping clang_host...";
+ (${PREFIX}/bin/cmake ../cfe-${PKG_VERSION}.src \
+ -DCLANG_BUILD_EXAMPLES:BOOL=OFF \
+ -DCLANG_INCLUDE_DOCS:BOOL=OFF \
+ -DCLANG_INCLUDE_TESTS:BOOL=OFF \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX="" \
+ -DCMAKE_VERBOSE_MAKEFILE=NO \
+ -DLIBCLANG_BUILD_STATIC:BOOL=ON \
+ -DLLVM_PREFIX="${PKG_PREFIX}" \
+ -G "Unix Makefiles" \
+ -Wno-dev);
+ log_msg info "Finished bootstrapping clang_host.";
+};
+
+# vim:filetype=sh
diff --git a/vars/cmake.vars b/vars/cmake.vars
index 981ffb9d..ee60c82f 100644
--- a/vars/cmake.vars
+++ b/vars/cmake.vars
@@ -9,7 +9,7 @@ pkg_cmake_configure() {
insecure_mkdir ../cmake-${PKG_VERSION}-host;
cd ../cmake-${PKG_VERSION}-host;
log_msg info "Bootstrapping cmake...";
- (unset AR CC RANLIB;
+ (unset AR CC CXX RANLIB;
../cmake-${PKG_VERSION}/configure ${PKG_CONFIGURE_ARGS};
make ${DEFAULT_MAKEFLAGS_BUILD} DESTDIR=${PREFIX} install);
log_msg info "Finished bootstrapping cmake.";
diff --git a/vars/llvm_host.vars b/vars/llvm_host.vars
new file mode 100644
index 00000000..57b581fa
--- /dev/null
+++ b/vars/llvm_host.vars
@@ -0,0 +1,25 @@
+#
+# . ./build.vars and set -o errexit -o noglob are assumed.
+#
+
+pkg_llvm_host_configure() {
+ secure_rm ../llvm-${PKG_VERSION}-host;
+ insecure_mkdir ../llvm-${PKG_VERSION}-host;
+ cd ../llvm-${PKG_VERSION}-host;
+ log_msg info "Bootstrapping llvm_host...";
+ (${PREFIX}/bin/cmake ../llvm-${PKG_VERSION}.src \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX="" \
+ -DCMAKE_VERBOSE_MAKEFILE=NO \
+ -DLLVM_BUILD_DOCS=NO \
+ -DLLVM_BUILD_EXAMPLES=NO \
+ -DLLVM_BUILD_TESTS=NO \
+ -DLLVM_ENABLE_SPHINX=NO \
+ -DLLVM_TARGETS_TO_BUILD=X86 \
+ -DSPHINX_WARNINGS_AS_ERRORS=NO \
+ -G "Unix Makefiles" \
+ -Wno-dev);
+ log_msg info "Finished bootstrapping llvm_host.";
+};
+
+# vim:filetype=sh
diff --git a/vars/python3.vars b/vars/python3.vars
index 9cdc016f..1c0d8d71 100644
--- a/vars/python3.vars
+++ b/vars/python3.vars
@@ -4,7 +4,7 @@
pkg_python3_configure_pre() {
(cd ../${PKG_SUBDIR} && autoconf);
- (unset AR BLDSHARED CC CFLAGS CPPFLAGS LDFLAGS RANLIB;
+ (unset AR BLDSHARED CC CFLAGS CPPFLAGS CXX LDFLAGS RANLIB;
mv -- config.cache ../${PKG_SUBDIR}/config.cache;
../${PKG_SUBDIR}/configure;
make _FIP=Programs/host_freeze_importlib Programs/host_freeze_importlib \