From 998c5fe43ec03366f26f1430c6453d623f314a51 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Thu, 21 Feb 2019 15:56:44 +0000
Subject: llvm: update to 7.0.1

---
 ...GCC-compatibility-Ignore-the-fno-plt-flag.patch |  37 ---
 .../llvm/0002-Enable-SSP-and-PIE-by-default.patch  | 268 ---------------------
 abs/extra/llvm/PKGBUILD                            | 207 +++-------------
 .../llvm/add-discriminator-to-debuginfo-test.patch |  25 ++
 abs/extra/llvm/disable-llvm-symbolizer-test.patch  |  26 --
 abs/extra/llvm/rusty-discriminator-thingy.patch    |  57 +++++
 6 files changed, 117 insertions(+), 503 deletions(-)
 delete mode 100644 abs/extra/llvm/0001-GCC-compatibility-Ignore-the-fno-plt-flag.patch
 delete mode 100644 abs/extra/llvm/0002-Enable-SSP-and-PIE-by-default.patch
 create mode 100644 abs/extra/llvm/add-discriminator-to-debuginfo-test.patch
 delete mode 100644 abs/extra/llvm/disable-llvm-symbolizer-test.patch
 create mode 100644 abs/extra/llvm/rusty-discriminator-thingy.patch

diff --git a/abs/extra/llvm/0001-GCC-compatibility-Ignore-the-fno-plt-flag.patch b/abs/extra/llvm/0001-GCC-compatibility-Ignore-the-fno-plt-flag.patch
deleted file mode 100644
index 7398b50..0000000
--- a/abs/extra/llvm/0001-GCC-compatibility-Ignore-the-fno-plt-flag.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From fedcf1d9691bf669d8cd771a032e851d8247aff9 Mon Sep 17 00:00:00 2001
-From: Evangelos Foutras <evangelos@foutrelis.com>
-Date: Thu, 6 Jul 2017 18:53:05 +0300
-Subject: [PATCH 1/2] GCC compatibility: Ignore the -fno-plt flag
-
----
- include/clang/Driver/Options.td | 1 +
- test/Driver/clang_f_opts.c      | 1 +
- 2 files changed, 2 insertions(+)
-
-diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
-index 05dc9d7eb3..c93e6cc08c 100644
---- a/include/clang/Driver/Options.td
-+++ b/include/clang/Driver/Options.td
-@@ -2505,6 +2505,7 @@ defm ivopts : BooleanFFlag<"ivopts">, Group<clang_ignored_gcc_optimization_f_Gro
- defm non_call_exceptions : BooleanFFlag<"non-call-exceptions">, Group<clang_ignored_f_Group>;
- defm peel_loops : BooleanFFlag<"peel-loops">, Group<clang_ignored_gcc_optimization_f_Group>;
- defm permissive : BooleanFFlag<"permissive">, Group<clang_ignored_f_Group>;
-+defm plt : BooleanFFlag<"plt">, Group<clang_ignored_f_Group>;
- defm prefetch_loop_arrays : BooleanFFlag<"prefetch-loop-arrays">, Group<clang_ignored_gcc_optimization_f_Group>;
- defm printf : BooleanFFlag<"printf">, Group<clang_ignored_f_Group>;
- defm profile : BooleanFFlag<"profile">, Group<clang_ignored_f_Group>;
-diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c
-index c17cec6eba..d9480c915e 100644
---- a/test/Driver/clang_f_opts.c
-+++ b/test/Driver/clang_f_opts.c
-@@ -277,6 +277,7 @@
- // RUN:     -fno-caller-saves -fcaller-saves                                  \
- // RUN:     -fno-reorder-blocks -freorder-blocks                              \
- // RUN:     -fno-schedule-insns2 -fschedule-insns2                            \
-+// RUN:     -fno-plt -fplt                                                    \
- // RUN:     -fno-stack-check                                                  \
- // RUN:     -fno-check-new -fcheck-new                                        \
- // RUN:     -ffriend-injection                                                \
--- 
-2.14.1
-
diff --git a/abs/extra/llvm/0002-Enable-SSP-and-PIE-by-default.patch b/abs/extra/llvm/0002-Enable-SSP-and-PIE-by-default.patch
deleted file mode 100644
index 030146c..0000000
--- a/abs/extra/llvm/0002-Enable-SSP-and-PIE-by-default.patch
+++ /dev/null
@@ -1,268 +0,0 @@
-From 60fa751da239e592b31bde2533342dac64359e7f Mon Sep 17 00:00:00 2001
-From: Evangelos Foutras <evangelos@foutrelis.com>
-Date: Thu, 6 Jul 2017 18:15:43 +0300
-Subject: [PATCH 2/2] Enable SSP and PIE by default
-
-This is a minimal set of changes needed to make clang use SSP and PIE by
-default on Arch Linux. Tests that were easy to adjust have been changed
-accordingly; only test/Driver/linux-ld.c has been marked as "expected
-failure" due to the number of changes it would require (mostly replacing
-crtbegin.o with crtbeginS.o).
-
-Doing so is needed in order to align clang with the new default GCC
-behavior in Arch which generates PIE executables by default and also
-defaults to -fstack-protector-strong. It is not meant to be a long term
-solution, but a simple temporary fix.
-
-Hopefully these changes will be obsoleted by the introduction upstream
-of a compile-time option (https://bugs.llvm.org/show_bug.cgi?id=13410)
----
- lib/Driver/ToolChains/Gnu.cpp       |  1 +
- lib/Driver/ToolChains/Linux.cpp     | 14 +++++++++++++-
- lib/Driver/ToolChains/Linux.h       |  1 +
- test/Driver/cross-linux.c           | 16 ++++++++--------
- test/Driver/env.c                   |  2 +-
- test/Driver/fsanitize.c             | 18 ++++++++++--------
- test/Driver/gcc-toolchain.cpp       |  2 +-
- test/Driver/hexagon-toolchain-elf.c |  2 +-
- test/Driver/linux-as.c              |  4 ++--
- test/Driver/linux-ld.c              |  2 ++
- test/Driver/stack-protector.c       |  4 ++--
- 11 files changed, 42 insertions(+), 24 deletions(-)
-
-diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
-index 72a9f85ba3..4fd567b03b 100644
---- a/lib/Driver/ToolChains/Gnu.cpp
-+++ b/lib/Driver/ToolChains/Gnu.cpp
-@@ -417,6 +417,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
-   const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
-   const bool IsPIE =
-       !Args.hasArg(options::OPT_shared) && !Args.hasArg(options::OPT_static) &&
-+      !Args.hasArg(options::OPT_nopie) &&
-       (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault());
-   const bool HasCRTBeginEndFiles =
-       ToolChain.getTriple().hasEnvironment() ||
-diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp
-index 08a27fa7fe..1dd70b115d 100644
---- a/lib/Driver/ToolChains/Linux.cpp
-+++ b/lib/Driver/ToolChains/Linux.cpp
-@@ -810,7 +810,19 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
-   }
- }
- 
--bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
-+bool Linux::isPIEDefault() const {
-+  const bool IsMips = tools::isMipsArch(getTriple().getArch());
-+  const bool IsAndroid = getTriple().isAndroid();
-+
-+  if (IsMips || IsAndroid)
-+    return getSanitizerArgs().requiresPIE();
-+
-+  return true;
-+}
-+
-+unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const {
-+  return 2;
-+}
- 
- SanitizerMask Linux::getSupportedSanitizers() const {
-   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
-diff --git a/lib/Driver/ToolChains/Linux.h b/lib/Driver/ToolChains/Linux.h
-index 9778c1832c..ddd46a1d58 100644
---- a/lib/Driver/ToolChains/Linux.h
-+++ b/lib/Driver/ToolChains/Linux.h
-@@ -36,6 +36,7 @@ public:
-   void AddIAMCUIncludeArgs(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/cross-linux.c b/test/Driver/cross-linux.c
-index a5ea832e77..1949c05a60 100644
---- a/test/Driver/cross-linux.c
-+++ b/test/Driver/cross-linux.c
-@@ -42,8 +42,8 @@
- // CHECK-MULTI32-I386: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\\\}}ld"
- // CHECK-MULTI32-I386: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
- // CHECK-MULTI32-I386: "-m" "elf_i386"
--// CHECK-MULTI32-I386: "crti.o" "[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]{{/|\\\\}}crtbegin.o"
--// CHECK-MULTI32-I386: "-L[[gcc_install]]"
-+// CHECK-MULTI32-I386: "crti.o" "crtbeginS.o"
-+// CHECK-MULTI32-I386: "-L[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]"
- // CHECK-MULTI32-I386: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib/../lib32"
- // CHECK-MULTI32-I386: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib"
- // CHECK-MULTI32-I386: "-L[[sysroot]]/lib"
-@@ -59,8 +59,8 @@
- // CHECK-MULTI32-X86-64: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\\\}}ld"
- // CHECK-MULTI32-X86-64: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
- // CHECK-MULTI32-X86-64: "-m" "elf_x86_64"
--// CHECK-MULTI32-X86-64: "crti.o" "[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]/64{{/|\\\\}}crtbegin.o"
--// CHECK-MULTI32-X86-64: "-L[[gcc_install]]/64"
-+// CHECK-MULTI32-X86-64: "crti.o" "crtbeginS.o"
-+// CHECK-MULTI32-X86-64: "-L[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]/64"
- // CHECK-MULTI32-X86-64: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib/../lib64"
- // CHECK-MULTI32-X86-64: "-L[[gcc_install]]"
- // CHECK-MULTI32-X86-64: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib"
-@@ -77,8 +77,8 @@
- // CHECK-MULTI64-I386: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}ld"
- // CHECK-MULTI64-I386: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
- // CHECK-MULTI64-I386: "-m" "elf_i386"
--// CHECK-MULTI64-I386: "crti.o" "[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]/32{{/|\\\\}}crtbegin.o"
--// CHECK-MULTI64-I386: "-L[[gcc_install]]/32"
-+// CHECK-MULTI64-I386: "crti.o" "crtbeginS.o"
-+// CHECK-MULTI64-I386: "-L[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]/32"
- // CHECK-MULTI64-I386: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib/../lib32"
- // CHECK-MULTI64-I386: "-L[[gcc_install]]"
- // CHECK-MULTI64-I386: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib"
-@@ -95,8 +95,8 @@
- // CHECK-MULTI64-X86-64: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}ld"
- // CHECK-MULTI64-X86-64: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
- // CHECK-MULTI64-X86-64: "-m" "elf_x86_64"
--// CHECK-MULTI64-X86-64: "crti.o" "[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]{{/|\\\\}}crtbegin.o"
--// CHECK-MULTI64-X86-64: "-L[[gcc_install]]"
-+// CHECK-MULTI64-X86-64: "crti.o" "crtbeginS.o"
-+// CHECK-MULTI64-X86-64: "-L[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]"
- // CHECK-MULTI64-X86-64: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib/../lib64"
- // CHECK-MULTI64-X86-64: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib"
- // CHECK-MULTI64-X86-64: "-L[[sysroot]]/lib"
-diff --git a/test/Driver/env.c b/test/Driver/env.c
-index 0371bc91c4..ea89f52512 100644
---- a/test/Driver/env.c
-+++ b/test/Driver/env.c
-@@ -20,7 +20,7 @@
- //
- // CHECK-LD-32-NOT: warning:
- // CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
--// CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0{{/|\\\\}}crtbegin.o"
-+// CHECK-LD-32: "crtbeginS.o"
- // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
- // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
- // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
-diff --git a/test/Driver/fsanitize.c b/test/Driver/fsanitize.c
-index 0752ef6df0..5d1e211b24 100644
---- a/test/Driver/fsanitize.c
-+++ b/test/Driver/fsanitize.c
-@@ -192,13 +192,13 @@
- // RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-sanitize=vptr -fsanitize=undefined,address %s -### 2>&1
- // OK
- 
--// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
--// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
-+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
-+// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
- // RUN: %clang -target x86_64-unknown-freebsd -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
- // RUN: %clang -target aarch64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
- // RUN: %clang -target arm-linux-androideabi -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
--// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
--// RUN: %clang -target i386-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
-+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
-+// RUN: %clang -target i386-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
- 
- // CHECK-NO-PIE-NOT: "-pie"
- // CHECK-NO-PIE: "-mrelocation-model" "static"
-@@ -491,12 +491,12 @@
- // RUN: %clang -fno-sanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NOSP
- // NOSP-NOT: "-fsanitize=safe-stack"
- 
--// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
--// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP-ASAN
-+// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
-+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP-ASAN
- // RUN: %clang -target x86_64-linux-gnu -fstack-protector -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
- // RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=SP
--// RUN: %clang -target arm-linux-androideabi -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
--// RUN: %clang -target aarch64-linux-android -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
-+// RUN: %clang -target arm-linux-androideabi -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
-+// RUN: %clang -target aarch64-linux-android -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
- // RUN: %clang -target i386-contiki-unknown -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
- // NO-SP-NOT: stack-protector
- // NO-SP: "-fsanitize=safe-stack"
-@@ -506,6 +506,8 @@
- 
- // NO-SP-ASAN-NOT: stack-protector
- // NO-SP-ASAN: "-fsanitize=address,safe-stack"
-+// SP-ASAN: "-fsanitize=address,safe-stack"
-+// SP-ASAN: -stack-protector
- // NO-SP-ASAN-NOT: stack-protector
- 
- // RUN: %clang -target powerpc64-unknown-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-SANM
-diff --git a/test/Driver/gcc-toolchain.cpp b/test/Driver/gcc-toolchain.cpp
-index ca96757a2b..ae1c25e989 100644
---- a/test/Driver/gcc-toolchain.cpp
-+++ b/test/Driver/gcc-toolchain.cpp
-@@ -24,6 +24,6 @@
- // the same precise formatting of the path as the '-internal-system' flags
- // above, so we just blanket wildcard match the 'crtbegin.o'.
- // CHECK: "{{[^"]*}}ld{{(.exe)?}}"
--// CHECK: "{{[^"]*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5{{/|\\\\}}crtbegin.o"
-+// CHECK: "crtbeginS.o"
- // CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
- // CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
-diff --git a/test/Driver/hexagon-toolchain-elf.c b/test/Driver/hexagon-toolchain-elf.c
-index 98582450e3..b2da01eaf5 100644
---- a/test/Driver/hexagon-toolchain-elf.c
-+++ b/test/Driver/hexagon-toolchain-elf.c
-@@ -449,7 +449,7 @@
- // RUN:   %s 2>&1 \
- // RUN:   | FileCheck -check-prefix=CHECK042 %s
- // CHECK042:      "-cc1"
--// CHECK042:      "-mrelocation-model" "static"
-+// CHECK042:      "-mrelocation-model" "pic"
- // CHECK042:      "-mllvm" "-hexagon-small-data-threshold=8"
- // CHECK042-NEXT: llvm-mc
- // CHECK042:      "-gpsize=8"
-diff --git a/test/Driver/linux-as.c b/test/Driver/linux-as.c
-index c5cb1cd600..1ad86d8ead 100644
---- a/test/Driver/linux-as.c
-+++ b/test/Driver/linux-as.c
-@@ -133,7 +133,7 @@
- // CHECK-PPC-NO-MCPU-NOT: as{{.*}} "-mcpu=invalid-cpu"
- //
- // RUN: %clang -target sparc64-linux -mcpu=invalid-cpu -### \
--// RUN:   -no-integrated-as -c %s 2>&1 \
-+// RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
- // RUN:   | FileCheck -check-prefix=CHECK-SPARCV9 %s
- // CHECK-SPARCV9: as
- // CHECK-SPARCV9: -64
-@@ -142,7 +142,7 @@
- // CHECK-SPARCV9: -o
- //
- // RUN: %clang -target sparc64-linux -mcpu=invalid-cpu -### \
--// RUN:   -no-integrated-as -fpic -c %s 2>&1 \
-+// RUN:   -no-integrated-as -c %s 2>&1 \
- // RUN:   | FileCheck -check-prefix=CHECK-SPARCV9PIC %s
- // CHECK-SPARCV9PIC: as
- // CHECK-SPARCV9PIC: -64
-diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c
-index 1c5f1a4556..2885f78045 100644
---- a/test/Driver/linux-ld.c
-+++ b/test/Driver/linux-ld.c
-@@ -1,3 +1,5 @@
-+// XFAIL: linux
-+
- // General tests that ld invocations on Linux targets sane. Note that we use
- // sysroot to make these tests independent of the host system.
- //
-diff --git a/test/Driver/stack-protector.c b/test/Driver/stack-protector.c
-index 6769b65f63..180e26f3ea 100644
---- a/test/Driver/stack-protector.c
-+++ b/test/Driver/stack-protector.c
-@@ -3,11 +3,11 @@
- // NOSSP-NOT: "-stack-protector-buffer-size" 
- 
- // RUN: %clang -target i386-unknown-linux -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=SSP
--// SSP: "-stack-protector" "1"
-+// SSP: "-stack-protector" "2"
- // SSP-NOT: "-stack-protector-buffer-size" 
- 
- // RUN: %clang -target i386-unknown-linux -fstack-protector --param ssp-buffer-size=16 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-BUF
--// SSP-BUF: "-stack-protector" "1"
-+// SSP-BUF: "-stack-protector" "2"
- // SSP-BUF: "-stack-protector-buffer-size" "16" 
- 
- // RUN: %clang -target i386-pc-openbsd -### %s 2>&1 | FileCheck %s -check-prefix=OPENBSD
--- 
-2.14.1
-
diff --git a/abs/extra/llvm/PKGBUILD b/abs/extra/llvm/PKGBUILD
index 64ba5b2..d6e630c 100644
--- a/abs/extra/llvm/PKGBUILD
+++ b/abs/extra/llvm/PKGBUILD
@@ -1,80 +1,45 @@
-# $Id$
 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
-# Contributor: Sebastian Nowicki <sebnow@gmail.com>
-# Contributor: Devin Cofer <ranguvar{AT]archlinux[DOT}us>
-# Contributor: Tobias Kieslich <tobias@justdreams.de>
-# Contributor: Geoffroy Carrier <geoffroy.carrier@aur.archlinux.org>
-# Contributor: Tomas Lindquist Olsen <tomas@famolsen.dk>
-# Contributor: Roberto Alsina <ralsina@kde.org>
-# Contributor: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
 
-pkgname=('llvm' 'llvm-libs' 'llvm-ocaml' 'lld' 'lldb' 'clang' 'clang-tools-extra')
-pkgver=5.0.1
+pkgname=('llvm' 'llvm-libs' 'llvm-ocaml')
+pkgver=7.0.1
 pkgrel=2
-_ocaml_ver=4.06.0
+_ocaml_ver=4.07.1
 arch=('x86_64')
-url="http://llvm.org/"
+url="https://llvm.org/"
 license=('custom:University of Illinois/NCSA Open Source License')
-makedepends=('cmake' 'libffi' 'python2' "ocaml=$_ocaml_ver" 'python-sphinx'
-             'ocaml-ctypes' 'ocaml-findlib' 'libedit' 'swig')
-# Build 32-bit compiler-rt libraries on x86_64 (FS#41911)
-makedepends_x86_64=('lib32-gcc-libs')
+makedepends=('cmake' 'ninja' 'libffi' 'libedit' 'ncurses' 'libxml2' 'python-sphinx'
+             "ocaml=$_ocaml_ver" 'ocaml-ctypes' 'ocaml-findlib')
 options=('staticlibs')
 source=(https://releases.llvm.org/$pkgver/llvm-$pkgver.src.tar.xz{,.sig}
-        https://releases.llvm.org/$pkgver/cfe-$pkgver.src.tar.xz{,.sig}
-        https://releases.llvm.org/$pkgver/clang-tools-extra-$pkgver.src.tar.xz{,.sig}
-        https://releases.llvm.org/$pkgver/compiler-rt-$pkgver.src.tar.xz{,.sig}
-        https://releases.llvm.org/$pkgver/lld-$pkgver.src.tar.xz{,.sig}
-        https://releases.llvm.org/$pkgver/lldb-$pkgver.src.tar.xz{,.sig}
-        0001-GCC-compatibility-Ignore-the-fno-plt-flag.patch
-        0002-Enable-SSP-and-PIE-by-default.patch
-        disable-llvm-symbolizer-test.patch
+        rusty-discriminator-thingy.patch
+        add-discriminator-to-debuginfo-test.patch
         llvm-config.h)
-sha256sums=('5fa7489fc0225b11821cab0362f5813a05f2bcf2533e8a4ea9c9c860168807b0'
+sha256sums=('a38dfc4db47102ec79dcc2aa61e93722c5f6f06f0a961073bd84b78fb949419b'
             'SKIP'
-            '135f6c9b0cd2da1aff2250e065946258eb699777888df39ca5a5b4fe5e23d0ff'
-            'SKIP'
-            '9aada1f9d673226846c3399d13fab6bba4bfd38bcfe8def5ee7b0ec24f8cd225'
-            'SKIP'
-            '4edd1417f457a9b3f0eb88082530490edf3cf6a7335cdce8ecbc5d3e16a895da'
-            'SKIP'
-            'd5b36c0005824f07ab093616bdff247f3da817cae2c51371e1d1473af717d895'
-            'SKIP'
-            'b7c1c9e67975ca219089a3a6a9c77c2d102cead2dc38264f2524aa3326da376a'
-            'SKIP'
-            'a1ba7fb859ac157c4b4342435cd656e29b1e1d9bddcb8ae0158a91c0a8ba6203'
-            '186f2d10b013395f2dd6e1fd3baf4961a2e40c403f115517c9b253682934f50f'
-            '6fff47ab5ede79d45fe64bb4903b7dfc27212a38e6cd5d01e60ebd24b7557359'
+            '4abaef845abb899628deb62a3f184fb8433555620648150dc346a74ef134fd68'
+            '1d2ea3a07e94f4c826706a452e93ed8a2301b5eed5715d22eab19a5ea3f3d0a7'
             '597dc5968c695bbdbb0eac9e8eb5117fcd2773bc91edf5ec103ecffffab8bc48')
-validpgpkeys=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D'
-              '11E521D646982372EB577A1F8F0871F202119294')
+validpgpkeys+=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D') # Hans Wennborg <hans@chromium.org>
+validpgpkeys+=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar@redhat.com>
 
 prepare() {
   cd "$srcdir/llvm-$pkgver.src"
   mkdir build
 
-  mv "$srcdir/cfe-$pkgver.src" tools/clang
-  mv "$srcdir/clang-tools-extra-$pkgver.src" tools/clang/tools/extra
-  mv "$srcdir/compiler-rt-$pkgver.src" projects/compiler-rt
-  mv "$srcdir/lld-$pkgver.src" tools/lld
-  mv "$srcdir/lldb-$pkgver.src" tools/lldb
-
-  # Disable test that fails when compiled as PIE
-  # https://bugs.llvm.org/show_bug.cgi?id=31870
-  patch -Np1 <../disable-llvm-symbolizer-test.patch
-
-  # Enable SSP and PIE by default
-  patch -Np1 -d tools/clang <../0001-GCC-compatibility-Ignore-the-fno-plt-flag.patch
-  patch -Np1 -d tools/clang <../0002-Enable-SSP-and-PIE-by-default.patch
+  # Fix rust 1.32 segfaults with LTO being enabled
+  # https://github.com/rust-lang/rust/issues/54614
+  patch -Np1 -i ../rusty-discriminator-thingy.patch
+  patch -Np1 -i ../add-discriminator-to-debuginfo-test.patch
 }
 
 build() {
   cd "$srcdir/llvm-$pkgver.src/build"
 
-  cmake \
+  cmake .. -G Ninja \
     -DCMAKE_BUILD_TYPE=Release \
     -DCMAKE_INSTALL_PREFIX=/usr \
+    -DLLVM_HOST_TRIPLE=$CHOST \
     -DLLVM_BUILD_LLVM_DYLIB=ON \
     -DLLVM_LINK_LLVM_DYLIB=ON \
     -DLLVM_INSTALL_UTILS=ON \
@@ -86,30 +51,28 @@ build() {
     -DLLVM_ENABLE_DOXYGEN=OFF \
     -DSPHINX_WARNINGS_AS_ERRORS=OFF \
     -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
-    -DLLVM_BINUTILS_INCDIR=/usr/include \
-    ..
-
-  make
-  make ocaml_doc
-
-  # Disable automatic installation of components that go into subpackages
-  sed -i '/\(clang\|lld\|lldb\)\/cmake_install.cmake/d' tools/cmake_install.cmake
-  sed -i '/extra\/cmake_install.cmake/d' tools/clang/tools/cmake_install.cmake
-  sed -i '/compiler-rt\/cmake_install.cmake/d' projects/cmake_install.cmake
+    -DLLVM_BINUTILS_INCDIR=/usr/include
+  ninja all ocaml_doc
 }
 
 check() {
   cd "$srcdir/llvm-$pkgver.src/build"
-  make check-{llvm,clang,clang-tools,lld}
+  ninja check
 }
 
 package_llvm() {
-  pkgdesc="Low Level Virtual Machine"
+  pkgdesc="Collection of modular and reusable compiler and toolchain technologies"
   depends=('llvm-libs' 'perl')
+  optdepends=('python-setuptools: for using lit (LLVM Integrated Tester)')
 
-  cd "$srcdir/llvm-$pkgver.src"
+  cd "$srcdir/llvm-$pkgver.src/build"
 
-  make -C build DESTDIR="$pkgdir" install
+  DESTDIR="$pkgdir" ninja install
+
+  # Include lit for running lit-based tests in other projects
+  pushd ../utils/lit
+  python3 setup.py install --root="$pkgdir" -O1
+  popd
 
   # Remove documentation sources
   rm -r "$pkgdir"/usr/share/doc/$pkgname/html/{_sources,.buildinfo}
@@ -130,12 +93,12 @@ package_llvm() {
     cp "$srcdir/llvm-config.h" "$pkgdir/usr/include/llvm/Config/llvm-config.h"
   fi
 
-  install -Dm644 LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+  install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
 }
 
 package_llvm-libs() {
-  pkgdesc="Low Level Virtual Machine (runtime libraries)"
-  depends=('gcc-libs' 'zlib' 'libffi' 'libedit' 'ncurses')
+  pkgdesc="LLVM runtime libraries"
+  depends=('gcc-libs' 'zlib' 'libffi' 'libedit' 'ncurses' 'libxml2')
 
   install -d "$pkgdir/usr/lib"
   cp -P \
@@ -156,111 +119,11 @@ package_llvm-ocaml() {
   pkgdesc="OCaml bindings for LLVM"
   depends=('llvm' "ocaml=$_ocaml_ver" 'ocaml-ctypes')
 
-  cd "$srcdir/llvm-$pkgver.src"
-
   install -d "$pkgdir"/{usr/lib,usr/share/doc/$pkgname}
   cp -a "$srcdir/ocaml.lib" "$pkgdir/usr/lib/ocaml"
   cp -a "$srcdir/ocaml.doc" "$pkgdir/usr/share/doc/$pkgname/html"
 
-  install -Dm644 LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
-}
-
-package_lld() {
-  pkgdesc="Linker from the LLVM project"
-  url="http://lld.llvm.org/"
-  depends=('llvm-libs')
-
-  cd "$srcdir/llvm-$pkgver.src"
-
-  make -C build/tools/lld DESTDIR="$pkgdir" install
-
-  # Remove documentation sources
-  rm -r "$pkgdir"/usr/share/doc/$pkgname/html/{_sources,.buildinfo}
-
-  install -Dm644 tools/$pkgname/LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
-}
-
-package_lldb() {
-  pkgdesc="Next generation, high-performance debugger"
-  url="http://lldb.llvm.org/"
-  depends=('llvm-libs' 'libxml2' 'python2' 'python2-six')
-
-  cd "$srcdir/llvm-$pkgver.src"
-
-  make -C build/tools/lldb DESTDIR="$pkgdir" install
-
-  # https://bugs.archlinux.org/task/50759
-  sed -i "/import_module('_lldb')/s/_lldb/lldb.&/" \
-    "$pkgdir/usr/lib/python2.7/site-packages/lldb/__init__.py"
-
-  # Remove bundled six library
-  rm "$pkgdir/usr/lib/python2.7/site-packages/six.py"
-
-  # Compile Python scripts
-  python2 -m compileall "$pkgdir/usr/lib/python2.7/site-packages/lldb"
-  python2 -O -m compileall "$pkgdir/usr/lib/python2.7/site-packages/lldb"
-
-  install -Dm644 tools/$pkgname/LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
-}
-
-package_clang() {
-  pkgdesc="C language family frontend for LLVM"
-  url="http://clang.llvm.org/"
-  depends=('llvm-libs' 'gcc' 'libxml2')
-  optdepends=('openmp: OpenMP support in clang with -fopenmp'
-              'python2: for scan-view and git-clang-format')
-  provides=("clang-analyzer=$pkgver")
-  conflicts=('clang-analyzer')
-  replaces=('clang-analyzer')
-
-  cd "$srcdir/llvm-$pkgver.src"
-
-  make -C build/tools/clang DESTDIR="$pkgdir" install
-  make -C build/projects/compiler-rt DESTDIR="$pkgdir" install
-
-  # Remove documentation sources
-  rm -r "$pkgdir"/usr/share/doc/$pkgname/html/{_sources,.buildinfo}
-
-  # Move analyzer scripts out of /usr/libexec
-  mv "$pkgdir"/usr/libexec/{ccc,c++}-analyzer "$pkgdir/usr/lib/clang/"
-  rmdir "$pkgdir/usr/libexec"
-  sed -i 's|libexec|lib/clang|' "$pkgdir/usr/bin/scan-build"
-
-  # Install Python bindings
-  install -d "$pkgdir/usr/lib/python2.7/site-packages"
-  cp -a tools/clang/bindings/python/clang "$pkgdir/usr/lib/python2.7/site-packages/"
-
-  # Use Python 2
-  sed -i 's|/usr/bin/env python|&2|' \
-    "$pkgdir/usr/bin/scan-view" \
-    "$pkgdir/usr/bin/git-clang-format" \
-    "$pkgdir/usr/share/$pkgname/clang-format-diff.py"
-
-  # Compile Python scripts
-  python2 -m compileall "$pkgdir"
-  python2 -O -m compileall "$pkgdir"
-
-  install -Dm644 tools/$pkgname/LICENSE.TXT \
-    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
-}
-
-package_clang-tools-extra() {
-  pkgdesc="Extra tools built using clang's tooling APIs"
-  url="http://clang.llvm.org/"
-  depends=('clang')
-
-  cd "$srcdir/llvm-$pkgver.src"
-
-  make -C build/tools/clang/tools/extra DESTDIR="$pkgdir" install
-
-  # Remove documentation sources
-  rm -r "$pkgdir"/usr/share/doc/clang-tools/html/{_sources,.buildinfo}
-
-  # Use Python 2
-  sed -i 's|/usr/bin/env python|&2|' \
-    "$pkgdir"/usr/share/clang/{clang-tidy-diff,run-clang-tidy,run-find-all-symbols}.py
-
-  install -Dm644 tools/clang/tools/extra/LICENSE.TXT \
+  install -Dm644 "$srcdir/llvm-$pkgver.src/LICENSE.TXT" \
     "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
 }
 
diff --git a/abs/extra/llvm/add-discriminator-to-debuginfo-test.patch b/abs/extra/llvm/add-discriminator-to-debuginfo-test.patch
new file mode 100644
index 0000000..aa67d52
--- /dev/null
+++ b/abs/extra/llvm/add-discriminator-to-debuginfo-test.patch
@@ -0,0 +1,25 @@
+From cc1f2a595ead516812a6c50398f0f3480ebe031f Mon Sep 17 00:00:00 2001
+From: Jonas Devlieghere <jonas@devlieghere.com>
+Date: Fri, 21 Sep 2018 12:28:44 +0000
+Subject: [PATCH] [test] Fix Assembler/debug-info.ll
+
+Update Assembler/debug-info.ll to contain discriminator.
+
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342727 91177308-0d34-0410-b5e6-96231b3b80d8
+---
+ test/Assembler/debug-info.ll | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/test/Assembler/debug-info.ll b/test/Assembler/debug-info.ll
+index 4404b741d343..d54dba07ac1e 100644
+--- a/test/Assembler/debug-info.ll
++++ b/test/Assembler/debug-info.ll
+@@ -83,7 +83,7 @@
+ ; CHECK-NEXT: !32 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_MD5, checksum: "000102030405060708090a0b0c0d0e0f")
+ !35 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_MD5, checksum: "000102030405060708090a0b0c0d0e0f")
+ 
+-; CHECK-NEXT: !33 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !14, size: 64)
++; CHECK-NEXT: !33 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !14, size: 64, discriminator: !34)
+ ; CHECK-NEXT: !34 = !DIDerivedType(tag: DW_TAG_member, scope: !33, baseType: !35, size: 64, align: 64, flags: DIFlagArtificial)
+ ; CHECK-NEXT: !35 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned)
+ !36 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !16, size: 64, discriminator: !37)
diff --git a/abs/extra/llvm/disable-llvm-symbolizer-test.patch b/abs/extra/llvm/disable-llvm-symbolizer-test.patch
deleted file mode 100644
index f949169..0000000
--- a/abs/extra/llvm/disable-llvm-symbolizer-test.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-Description: Silent a test failing on yakkety amd64
- /tmp/buildd/llvm-toolchain-snapshot-4.0~svn279801/test/tools/llvm-symbolizer/print_context.c:16:11: error: expected string not found in input
- // CHECK: inc
-          ^
- <stdin>:1:1: note: scanning from here
- _fini
- ^
- <stdin>:1:3: note: possible intended match here
- _fini
-  ^
-Author: Sylvestre <sylvestre@debian.org>
-Last-Update: 2016-08-26
-
-Index: llvm-toolchain-3.9-3.9~+rc1/test/tools/llvm-symbolizer/print_context.c
-===================================================================
---- llvm-toolchain-3.9-3.9~+rc1.orig/test/tools/llvm-symbolizer/print_context.c
-+++ llvm-toolchain-3.9-3.9~+rc1/test/tools/llvm-symbolizer/print_context.c
-@@ -1,7 +1,7 @@
- // REQUIRES: x86_64-linux
- // RUN: %host_cc -O0 -g %s -o %t 2>&1
- // RUN: %t 2>&1 | llvm-symbolizer -print-source-context-lines=5 -obj=%t | FileCheck %s
--
-+// XFAIL: *
- #include <stdio.h>
- 
- int inc(int a) {
diff --git a/abs/extra/llvm/rusty-discriminator-thingy.patch b/abs/extra/llvm/rusty-discriminator-thingy.patch
new file mode 100644
index 0000000..fb7ef03
--- /dev/null
+++ b/abs/extra/llvm/rusty-discriminator-thingy.patch
@@ -0,0 +1,57 @@
+From da1fb72bb305d6bc1f3899d541414146934bf80f Mon Sep 17 00:00:00 2001
+From: Jonas Devlieghere <jonas@devlieghere.com>
+Date: Fri, 21 Sep 2018 12:03:14 +0000
+Subject: [PATCH] Ensure that variant part discriminator is read by
+ MetadataLoader
+
+https://reviews.llvm.org/D42082 introduced variant parts to debug info
+in LLVM. Subsequent work on the Rust compiler has found a bug in that
+patch; namely, there is a path in MetadataLoader that fails to restore
+the discriminator.
+
+This patch fixes the bug.
+
+Patch by: Tom Tromey
+
+Differential revision: https://reviews.llvm.org/D52340
+
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342725 91177308-0d34-0410-b5e6-96231b3b80d8
+---
+ lib/Bitcode/Reader/MetadataLoader.cpp         |  2 +-
+ test/Assembler/debug-variant-discriminator.ll | 14 ++++++++++++++
+ 2 files changed, 15 insertions(+), 1 deletion(-)
+ create mode 100644 test/Assembler/debug-variant-discriminator.ll
+
+diff --git a/lib/Bitcode/Reader/MetadataLoader.cpp b/lib/Bitcode/Reader/MetadataLoader.cpp
+index 3fe7d2205631..4781cfe3dea6 100644
+--- a/lib/Bitcode/Reader/MetadataLoader.cpp
++++ b/lib/Bitcode/Reader/MetadataLoader.cpp
+@@ -1313,7 +1313,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
+                            (Context, Tag, Name, File, Line, Scope, BaseType,
+                             SizeInBits, AlignInBits, OffsetInBits, Flags,
+                             Elements, RuntimeLang, VTableHolder, TemplateParams,
+-                            Identifier));
++                            Identifier, Discriminator));
+     if (!IsNotUsedInTypeRef && Identifier)
+       MetadataList.addTypeRef(*Identifier, *cast<DICompositeType>(CT));
+ 
+diff --git a/test/Assembler/debug-variant-discriminator.ll b/test/Assembler/debug-variant-discriminator.ll
+new file mode 100644
+index 000000000000..5be001cad6be
+--- /dev/null
++++ b/test/Assembler/debug-variant-discriminator.ll
+@@ -0,0 +1,14 @@
++; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
++; RUN: verify-uselistorder %s
++
++; CHECK: !named = !{!0, !1, !2}
++!named = !{!0, !1, !2}
++
++; CHECK: !0 = !DICompositeType(tag: DW_TAG_structure_type, name: "Outer", size: 64, align: 64, identifier: "Outer")
++; CHECK-NEXT: !1 = !DICompositeType(tag: DW_TAG_variant_part, scope: !0, size: 64, discriminator: !2)
++; CHECK-NEXT: !2 = !DIDerivedType(tag: DW_TAG_member, scope: !1, baseType: !3, size: 64, align: 64, flags: DIFlagArtificial)
++; CHECK-NEXT: !3 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned)
++!0 = !DICompositeType(tag: DW_TAG_structure_type, name: "Outer", size: 64, align: 64, identifier: "Outer")
++!1 = !DICompositeType(tag: DW_TAG_variant_part, scope: !0, size: 64, discriminator: !2)
++!2 = !DIDerivedType(tag: DW_TAG_member, scope: !1, baseType: !3, size: 64, align: 64, flags: DIFlagArtificial)
++!3 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned)
-- 
cgit v0.12

