diff --git a/.gitignore b/.gitignore
index d63b76e..27638db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 SOURCES/llvm-12.0.1.src.tar.xz
+SOURCES/llvm-13.0.0.src.tar.xz
 SOURCES/tstellar-gpg-key.asc
diff --git a/.llvm.metadata b/.llvm.metadata
index 763143b..68091a6 100644
--- a/.llvm.metadata
+++ b/.llvm.metadata
@@ -1,2 +1,3 @@
 619fe668e0972d11d0fa2db670a57a42d02fb8ca SOURCES/llvm-12.0.1.src.tar.xz
+0be63c8b3b44f3af49d9e57130f7b76a6040427c SOURCES/llvm-13.0.0.src.tar.xz
 b8d2648a01d36ed0186fd2c5af325fd28797f9a0 SOURCES/tstellar-gpg-key.asc
diff --git a/SOURCES/0001-PATCH-llvm-Make-source-interleave-prefix-test-case-c.patch b/SOURCES/0001-PATCH-llvm-Make-source-interleave-prefix-test-case-c.patch
deleted file mode 100644
index 526b25f..0000000
--- a/SOURCES/0001-PATCH-llvm-Make-source-interleave-prefix-test-case-c.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 60760d66030695105bcf4364f22b7f6053a25253 Mon Sep 17 00:00:00 2001
-From: serge-sans-paille <sguelton@redhat.com>
-Date: Thu, 8 Apr 2021 09:33:37 +0200
-Subject: [PATCH] [PATCH][llvm] Make source-interleave-prefix test case
- compatible with llvm-test
-
-llvm-test runs test from a directory that's not the upstream one, and that leads
-to some false positive. Workaround this by forcing the current working
-directory.
----
- llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test b/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
-index 23ce55a..d260ee2 100644
---- a/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
-+++ b/llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
-@@ -5,7 +5,7 @@
- 
- ; RUN: sed -e "s,SRC_COMPDIR,./Inputs,g" %p/Inputs/source-interleave.ll > %t-relative-path.ll
- ; RUN: llc -o %t-relative-path.o -filetype=obj -mtriple=x86_64-pc-linux %t-relative-path.ll
--; RUN: llvm-objdump --prefix myprefix --source %t-relative-path.o 2>&1 | \
-+; RUN: mkdir -p %t0 && cd %t0 && llvm-objdump --prefix myprefix --source %t-relative-path.o 2>&1 | \
- ; RUN:   FileCheck %s --check-prefix=CHECK-BROKEN-PREFIX -DFILE=%t-relative-path.o -DPREFIX=.
- ; CHECK-BROKEN-PREFIX: warning: '[[FILE]]': failed to find source [[PREFIX]]/Inputs/source-interleave-x86_64.c
- 
--- 
-1.8.3.1
-
diff --git a/SOURCES/0001-XFAIL-missing-abstract-variable.ll-test-on-ppc64le.patch b/SOURCES/0001-XFAIL-missing-abstract-variable.ll-test-on-ppc64le.patch
new file mode 100644
index 0000000..1866a66
--- /dev/null
+++ b/SOURCES/0001-XFAIL-missing-abstract-variable.ll-test-on-ppc64le.patch
@@ -0,0 +1,33 @@
+From 9320ffeda3915c8f7be744c983a3470a89107bd7 Mon Sep 17 00:00:00 2001
+From: Tom Stellard <tstellar@redhat.com>
+Date: Tue, 14 Sep 2021 20:21:20 -0700
+Subject: [PATCH] XFAIL missing-abstract-variable.ll test on ppc64le
+
+It's seems the strategy with this test is to XFAIL it on all
+architectures that it fails on.  I wonder if we should be passing
+it a specific triple?  Also, from what I can tell, this tests only
+runs when llvm is configured with LLVM_DEFAULT_TARGET_TRIPLE set
+to a non-empty value, which is why it may not fail in every build
+configuration.
+
+Differential Revision: https://reviews.llvm.org/D109806
+---
+ llvm/test/DebugInfo/Generic/missing-abstract-variable.ll | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/llvm/test/DebugInfo/Generic/missing-abstract-variable.ll b/llvm/test/DebugInfo/Generic/missing-abstract-variable.ll
+index bd0de60268b6..cc5d56b0c512 100644
+--- a/llvm/test/DebugInfo/Generic/missing-abstract-variable.ll
++++ b/llvm/test/DebugInfo/Generic/missing-abstract-variable.ll
+@@ -4,7 +4,7 @@
+ ; powerpc64 (and on x86_64 at at least -O2). Presumably this is a SelectionDAG
+ ; issue.
+ ; FIXME: arm64 is an alias for aarch64 on macs, apparently?
+-; XFAIL: powerpc64, aarch64, arm64, hexagon
++; XFAIL: powerpc64, aarch64, arm64, hexagon, ppc64le
+ 
+ ; Build from the following source with clang -O2.
+ 
+-- 
+2.31.1
+
diff --git a/SOURCES/0001-have-lit-preserve-SOURCE_DATE_EPOCH.patch b/SOURCES/0001-have-lit-preserve-SOURCE_DATE_EPOCH.patch
new file mode 100644
index 0000000..37052c7
--- /dev/null
+++ b/SOURCES/0001-have-lit-preserve-SOURCE_DATE_EPOCH.patch
@@ -0,0 +1,27 @@
+commit 46c947af7ead0a939fbd7a93c370e7ead2128d07
+Author: serge-sans-paille <sguelton@redhat.com>
+Date:   Wed Aug 18 23:48:14 2021 +0200
+
+    Have lit preserve SOURCE_DATE_EPOCH
+    
+    This environment variable has been standardized for reproducible builds. Setting
+    it can help to have reproducible tests too, so keep it as part of the testing
+    env when set.
+    
+    See https://reproducible-builds.org/docs/source-date-epoch/
+    
+    Differential Revision: https://reviews.llvm.org/D108332
+
+diff --git a/llvm/utils/lit/lit/TestingConfig.py b/llvm/utils/lit/lit/TestingConfig.py
+index d534d895e4ba..37558bd5059c 100644
+--- a/llvm/utils/lit/lit/TestingConfig.py
++++ b/llvm/utils/lit/lit/TestingConfig.py
+@@ -28,7 +28,7 @@ class TestingConfig(object):
+                      'TMPDIR', 'TMP', 'TEMP', 'TEMPDIR', 'AVRLIT_BOARD',
+                      'AVRLIT_PORT', 'FILECHECK_OPTS', 'VCINSTALLDIR',
+                      'VCToolsinstallDir', 'VSINSTALLDIR', 'WindowsSdkDir',
+-                     'WindowsSDKLibVersion']
++                     'WindowsSDKLibVersion', 'SOURCE_DATE_EPOCH']
+ 
+         if sys.platform == 'win32':
+             pass_vars.append('INCLUDE')
diff --git a/SOURCES/0001-llvm-jitlink-Replace-use-of-deprecated-gethostbyname.patch b/SOURCES/0001-llvm-jitlink-Replace-use-of-deprecated-gethostbyname.patch
deleted file mode 100644
index f2c512b..0000000
--- a/SOURCES/0001-llvm-jitlink-Replace-use-of-deprecated-gethostbyname.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From 9df652778fc92db9eb371c78bc7d1691417f3a60 Mon Sep 17 00:00:00 2001
-From: Rafik Zurob <rzurob@ca.ibm.com>
-Date: Fri, 22 Jan 2021 06:51:19 -0600
-Subject: [PATCH] [llvm-jitlink] Replace use of deprecated gethostbyname by
- getaddrinfo.
-
-This patch replaces use of deprecated gethostbyname by getaddrinfo.
-
-Author: Rafik Zurob
-
-Reviewed By: lhames
-
-Differential Revision: https://reviews.llvm.org/D95477
----
- llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 28 ++++++++++++++++++++++++----
- 1 file changed, 24 insertions(+), 4 deletions(-)
-
-diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
-index da4a164..108dd61 100644
---- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
-+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
-@@ -690,15 +690,35 @@ LLVMJITLinkRemoteTargetProcessControl::ConnectToExecutor() {
-                                        " is not a valid integer",
-                                    inconvertibleErrorCode());
- 
-+  addrinfo *AI;
-+  addrinfo Hints{};
-+  Hints.ai_family = AF_INET;
-+  Hints.ai_socktype = SOCK_STREAM;
-+  Hints.ai_protocol = PF_INET;
-+  Hints.ai_flags = AI_NUMERICSERV;
-+  if (getaddrinfo(HostName.c_str(), PortStr.str().c_str(), &Hints, &AI) != 0)
-+    return make_error<StringError>("Failed to resolve " + HostName + ":" +
-+                                       Twine(Port),
-+                                   inconvertibleErrorCode());
-+
-   int SockFD = socket(PF_INET, SOCK_STREAM, 0);
--  hostent *Server = gethostbyname(HostName.c_str());
-   sockaddr_in ServAddr;
-   memset(&ServAddr, 0, sizeof(ServAddr));
-   ServAddr.sin_family = PF_INET;
--  memmove(&Server->h_addr, &ServAddr.sin_addr.s_addr, Server->h_length);
-   ServAddr.sin_port = htons(Port);
--  if (connect(SockFD, reinterpret_cast<sockaddr *>(&ServAddr),
--              sizeof(ServAddr)) < 0)
-+
-+  // getaddrinfo returns a list of address structures.  Go through the list
-+  // to find one we can connect to.
-+  int ConnectRC = -1;
-+  for (addrinfo *Server = AI; Server; Server = Server->ai_next) {
-+    memmove(&Server->ai_addr, &ServAddr.sin_addr.s_addr, Server->ai_addrlen);
-+    ConnectRC = connect(SockFD, reinterpret_cast<sockaddr *>(&ServAddr),
-+                        sizeof(ServAddr));
-+    if (ConnectRC == 0)
-+      break;
-+  }
-+  freeaddrinfo(AI);
-+  if (ConnectRC == -1)
-     return make_error<StringError>("Failed to connect to " + HostName + ":" +
-                                        Twine(Port),
-                                    inconvertibleErrorCode());
--- 
-1.8.3.1
-
diff --git a/SOURCES/llvm-12.0.1.src.tar.xz.sig b/SOURCES/llvm-12.0.1.src.tar.xz.sig
deleted file mode 100644
index efeaeb8..0000000
Binary files a/SOURCES/llvm-12.0.1.src.tar.xz.sig and /dev/null differ
diff --git a/SOURCES/llvm-13.0.0.src.tar.xz.sig b/SOURCES/llvm-13.0.0.src.tar.xz.sig
new file mode 100644
index 0000000..3fa23be
Binary files /dev/null and b/SOURCES/llvm-13.0.0.src.tar.xz.sig differ
diff --git a/SPECS/llvm.spec b/SPECS/llvm.spec
index 49ef67d..69e1b77 100644
--- a/SPECS/llvm.spec
+++ b/SPECS/llvm.spec
@@ -7,21 +7,24 @@
 %endif
 
 %bcond_with compat_build
-
-%bcond_with bundle_compat_lib
+%bcond_without bundle_compat_lib
+%bcond_without check
 
 %if %{with bundle_compat_lib}
-%global compat_maj_ver 11
-%global compat_ver %{compat_maj_ver}.1.0rc2
+%global compat_maj_ver 12
+%global compat_ver %{compat_maj_ver}.0.1
 %endif
 
 %global llvm_libdir %{_libdir}/%{name}
 %global build_llvm_libdir %{buildroot}%{llvm_libdir}
 #%%global rc_ver 5
-%global llvm_srcdir llvm-%{version}%{?rc_ver:rc%{rc_ver}}.src
-%global maj_ver 12
+%global maj_ver 13
 %global min_ver 0
-%global patch_ver 1
+%global patch_ver 0
+%if !%{maj_ver} && 0%{?rc_ver}
+%global abi_revision 2
+%endif
+%global llvm_srcdir llvm-%{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:rc%{rc_ver}}.src
 
 %if %{with compat_build}
 %global pkg_name llvm%{maj_ver}
@@ -38,7 +41,9 @@
 %global pkg_name llvm
 %global install_prefix /usr
 %global install_libdir %{_libdir}
+%global pkg_bindir %{_bindir}
 %global pkg_libdir %{install_libdir}
+%global exec_suffix %{nil}
 %endif
 
 %if 0%{?rhel}
@@ -51,15 +56,19 @@
 
 %global build_install_prefix %{buildroot}%{install_prefix}
 
+# Lower memory usage of dwz on s390x
+%global _dwz_low_mem_die_limit_s390x 1
+%global _dwz_max_die_limit_s390x 1000000
+
 Name:		%{pkg_name}
 Version:	%{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}}
-Release:	3%{?dist}
+Release:	1%{?dist}
 Summary:	The Low Level Virtual Machine
 
 License:	NCSA
 URL:		http://llvm.org
-Source0:	https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{llvm_srcdir}.tar.xz
-Source1:	https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{llvm_srcdir}.tar.xz.sig
+Source0:	https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:-rc%{rc_ver}}/%{llvm_srcdir}.tar.xz
+Source1:	https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:-rc%{rc_ver}}/%{llvm_srcdir}.tar.xz.sig
 Source2:	tstellar-gpg-key.asc
 
 %if %{without compat_build}
@@ -70,11 +79,15 @@ Source4:	lit.fedora.cfg.py
 Source5:	https://github.com/llvm/llvm-project/releases/download/llvmorg-%{compat_ver}/llvm-%{compat_ver}.src.tar.xz
 %endif
 
-Patch0:     0001-PATCH-llvm-Make-source-interleave-prefix-test-case-c.patch
-Patch1:     0001-llvm-jitlink-Replace-use-of-deprecated-gethostbyname.patch
+%if 0%{?abi_revision}
+Patch0:		0001-cmake-Allow-shared-libraries-to-customize-the-soname.patch
+%endif
+Patch2:		0001-XFAIL-missing-abstract-variable.ll-test-on-ppc64le.patch
 
 # RHEL-specific patches
-Patch101: 0001-Deactivate-markdown-doc.patch
+Patch101:	0001-Deactivate-markdown-doc.patch
+# Fixes the compress-debug-sections-zlib-gnu test failing on s390x
+Patch102:	0001-have-lit-preserve-SOURCE_DATE_EPOCH.patch
 
 BuildRequires:	gcc
 BuildRequires:	gcc-c++
@@ -83,6 +96,7 @@ BuildRequires:	ninja-build
 BuildRequires:	zlib-devel
 BuildRequires:	libffi-devel
 BuildRequires:	ncurses-devel
+BuildRequires:	python3-psutil
 BuildRequires:	python3-sphinx
 %if !0%{?rhel}
 BuildRequires:	python3-recommonmark
@@ -97,7 +111,7 @@ BuildRequires:	valgrind-devel
 %endif
 # LLVM's LineEditor library will use libedit if it is available.
 BuildRequires:	libedit-devel
-# We need python3-devel for pathfix.py.
+# We need python3-devel for %%py3_shebang_fix
 BuildRequires:	python3-devel
 BuildRequires:	python3-setuptools
 
@@ -172,14 +186,6 @@ Static libraries for the LLVM compiler infrastructure.
 Summary:	LLVM regression tests
 Requires:	%{name}%{?_isa} = %{version}-%{release}
 Requires:	%{name}-libs%{?_isa} = %{version}-%{release}
-Requires:	python3-lit
-# The regression tests need gold.
-Requires:	binutils
-# This is for llvm-config
-Requires:	%{name}-devel%{?_isa} = %{version}-%{release}
-# Bugpoint tests require gcc
-Requires:	gcc
-Requires:	findutils
 
 Provides:	llvm-test(major) = %{maj_ver}
 
@@ -203,7 +209,7 @@ LLVM's modified googletest sources.
 
 %autosetup -n %{llvm_srcdir} -p2
 
-pathfix.py -i %{__python3} -pn \
+%py3_shebang_fix \
 	test/BugPoint/compile-custom.ll.py \
 	tools/opt-viewer/*.py \
 	utils/update_cc_test_checks.py
@@ -220,7 +226,7 @@ pathfix.py -i %{__python3} -pn \
 # Because of these failures, lto is disabled for now.
 %global _lto_cflags %{nil}
 
-%ifarch s390 %{arm} %ix86
+%ifarch s390 s390x %{arm} %ix86
 # Decrease debuginfo verbosity to reduce memory consumption during final library linking
 %global optflags %(echo %{optflags} | sed 's/-g /-g1 /')
 %endif
@@ -261,6 +267,7 @@ pathfix.py -i %{__python3} -pn \
 	\
 	-DLLVM_INCLUDE_TESTS:BOOL=ON \
 	-DLLVM_BUILD_TESTS:BOOL=ON \
+	-DLLVM_LIT_EXTRA_ARGS=-v \
 	\
 	-DLLVM_INCLUDE_EXAMPLES:BOOL=ON \
 	-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
@@ -283,10 +290,10 @@ pathfix.py -i %{__python3} -pn \
 	-DLLVM_VERSION_SUFFIX='' \
 %endif
 	-DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \
-	-DLLVM_DYLIB_EXPORT_ALL:BOOL=ON \
 	-DLLVM_LINK_LLVM_DYLIB:BOOL=ON \
 	-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \
 	-DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=OFF \
+	%{?abi_revision:-DLLVM_ABI_REVISION=%{abi_revision}} \
 	\
 	-DSPHINX_WARNINGS_AS_ERRORS=OFF \
 	-DCMAKE_INSTALL_PREFIX=%{install_prefix} \
@@ -303,6 +310,7 @@ pathfix.py -i %{__python3} -pn \
 
 %cmake -S ../llvm-%{compat_ver}.src -B ../llvm-compat-libs -G Ninja \
 	-DCMAKE_INSTALL_PREFIX=%{buildroot}%{_libdir}/llvm%{compat_maj_ver}/ \
+	-DCMAKE_SKIP_RPATH:BOOL=ON \
 	-DCMAKE_BUILD_TYPE=Release \
 	-DBUILD_SHARED_LIBS:BOOL=OFF \
 	-DLLVM_BUILD_LLVM_DYLIB=ON \
@@ -311,7 +319,6 @@ pathfix.py -i %{__python3} -pn \
 
 %ninja_build -C ../llvm-compat-libs LLVM
 
-
 %endif
 
 %install
@@ -324,16 +331,12 @@ install -m 0755 ../llvm-compat-libs/lib/libLLVM-%{compat_maj_ver}.so %{buildroot
 rm -Rf ../llvm-compat-libs
 %endif
 
-%if %{without compat_build}
 mkdir -p %{buildroot}/%{_bindir}
-mv %{buildroot}/%{_bindir}/llvm-config %{buildroot}/%{_bindir}/llvm-config-%{__isa_bits}
 
-# ghost presence
-touch %{buildroot}%{_bindir}/llvm-config
+%if %{without compat_build}
 
 # Fix some man pages
-ln -s llvm-config.1 %{buildroot}%{_mandir}/man1/llvm-config-%{__isa_bits}.1
-mv %{buildroot}%{_mandir}/man1/*tblgen.1 %{buildroot}%{_mandir}/man1/llvm-tblgen.1
+ln -s llvm-config.1 %{buildroot}%{_mandir}/man1/llvm-config%{exec_suffix}-%{__isa_bits}.1
 
 # Install binaries needed for lit tests
 %global test_binaries llvm-isel-fuzzer llvm-opt-fuzzer
@@ -371,50 +374,6 @@ cp -R utils/unittest %{install_srcdir}/utils/
 cp utils/update_cc_test_checks.py %{install_srcdir}/utils/
 cp -R utils/UpdateTestChecks %{install_srcdir}/utils/
 
-# One of the lit tests references this file
-install -d %{install_srcdir}/docs/CommandGuide/
-install -m 0644 docs/CommandGuide/dsymutil.rst %{install_srcdir}/docs/CommandGuide/
-
-# Generate lit config files.  Strip off the last lines that initiates the
-# test run, so we can customize the configuration.
-head -n -2 %{_vpath_builddir}/test/lit.site.cfg.py >> %{lit_cfg}
-head -n -2 %{_vpath_builddir}/test/Unit/lit.site.cfg.py >> %{lit_unit_cfg}
-
-# Install custom fedora config file
-cp %{SOURCE4} %{buildroot}%{lit_fedora_cfg}
-
-# Patch lit config files to load custom fedora config:
-for f in %{lit_cfg} %{lit_unit_cfg}; do
-  echo "lit_config.load_config(config, '%{lit_fedora_cfg}')" >> $f
-done
-
-install -d %{buildroot}%{_libexecdir}/tests/llvm
-install -m 0755 %{SOURCE3} %{buildroot}%{_libexecdir}/tests/llvm
-
-# Install lit tests.  We need to put these in a tarball otherwise rpm will complain
-# about some of the test inputs having the wrong object file format.
-install -d %{buildroot}%{_datadir}/llvm/
-
-# The various tar options are there to make sur the archive is the same on 32 and 64 bit arch, i.e.
-# the archive creation is reproducible. Move arch-specific content out of the tarball
-mv %{lit_cfg} %{install_srcdir}/%{_arch}.site.cfg.py
-mv %{lit_unit_cfg} %{install_srcdir}/%{_arch}.Unit.site.cfg.py
-tar --sort=name --mtime='UTC 2020-01-01' -c test/ | gzip -n > %{install_srcdir}/test.tar.gz
-
-# Install the unit test binaries
-mkdir -p %{build_llvm_libdir}
-cp -R %{_vpath_builddir}/unittests %{build_llvm_libdir}/
-rm -rf `find %{build_llvm_libdir} -iname 'cmake*'`
-
-# Install libraries used for testing
-install -m 0755 %{build_libdir}/BugpointPasses.so %{buildroot}%{_libdir}
-install -m 0755 %{build_libdir}/LLVMHello.so %{buildroot}%{_libdir}
-
-# Install test inputs for PDB tests
-echo "%{_datadir}/llvm/src/unittests/DebugInfo/PDB" > %{build_llvm_libdir}/unittests/DebugInfo/PDB/llvm.srcdir.txt
-mkdir -p %{buildroot}%{_datadir}/llvm/src/unittests/DebugInfo/PDB/
-cp -R unittests/DebugInfo/PDB/Inputs %{buildroot}%{_datadir}/llvm/src/unittests/DebugInfo/PDB/
-
 %if %{with gold}
 # Add symlink to lto plugin in the binutils plugin directory.
 %{__mkdir_p} %{buildroot}%{_libdir}/bfd-plugins/
@@ -424,7 +383,6 @@ ln -s %{_libdir}/LLVMgold.so %{buildroot}%{_libdir}/bfd-plugins/
 %else
 
 # Add version suffix to binaries
-mkdir -p %{buildroot}/%{_bindir}
 for f in %{buildroot}/%{install_bindir}/*; do
   filename=`basename $f`
   ln -s ../../../%{install_bindir}/$filename %{buildroot}/%{_bindir}/$filename%{exec_suffix}
@@ -436,7 +394,6 @@ ln -s ../../../%{install_includedir}/llvm %{buildroot}/%{pkg_includedir}/llvm
 ln -s ../../../%{install_includedir}/llvm-c %{buildroot}/%{pkg_includedir}/llvm-c
 
 # Fix multi-lib
-mv %{buildroot}%{_bindir}/llvm-config{%{exec_suffix},%{exec_suffix}-%{__isa_bits}}
 %multilib_fix_c_header --file %{install_includedir}/llvm/Config/llvm-config.h
 
 # Create ld.so.conf.d entry
@@ -457,8 +414,39 @@ rm -Rf %{build_install_prefix}/share/opt-viewer
 
 %endif
 
+# llvm-config special casing. llvm-config is managed by update-alternatives.
+# the original file must remain available for compatibility with the CMake
+# infrastructure. Without compat, cmake points to the symlink, with compat it
+# points to the original file.
+
+%if %{without compat_build}
+
+mv %{buildroot}/%{pkg_bindir}/llvm-config %{buildroot}/%{pkg_bindir}/llvm-config%{exec_suffix}-%{__isa_bits}
+# We still maintain a versionned symlink for consistency across llvm versions.
+# This is specific to the non-compat build and matches the exec prefix for
+# compat builds. An isa-agnostic versionned symlink is also maintained in the (un)install
+# steps.
+(cd %{buildroot}/%{pkg_bindir} ; ln -s llvm-config%{exec_suffix}-%{__isa_bits} llvm-config-%{maj_ver}-%{__isa_bits} )
+# ghost presence
+touch %{buildroot}%{_bindir}/llvm-config-%{maj_ver}
+
+%else
+
+rm %{buildroot}%{_bindir}/llvm-config%{exec_suffix}
+(cd %{buildroot}/%{pkg_bindir} ; ln -s llvm-config llvm-config%{exec_suffix}-%{__isa_bits} )
+
+%endif
+
+# ghost presence
+touch %{buildroot}%{_bindir}/llvm-config%{exec_suffix}
+
+
 
 %check
+# Disable check section on arm due to some kind of memory related failure.
+# Possibly related to https://bugzilla.redhat.com/show_bug.cgi?id=1920183
+%ifnarch %{arm}
+
 # TODO: Fix the failures below
 %ifarch %{arm}
 rm test/tools/llvm-readobj/ELF/dependent-libraries.test
@@ -467,25 +455,28 @@ rm test/tools/llvm-readobj/ELF/dependent-libraries.test
 # non reproducible errors
 rm test/tools/dsymutil/X86/swift-interface.test
 
-# see rhbz#1988288
-sed -i -e "s/'ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'/'ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH', 'DFLTCC'/" test/lit.cfg.py
-
+%if %{with check}
 # FIXME: use %%cmake_build instead of %%__ninja
-DFLTCC=0 LD_LIBRARY_PATH=%{buildroot}/%{pkg_libdir}  %{__ninja} check-all -C %{_vpath_builddir}
+LD_LIBRARY_PATH=%{buildroot}/%{pkg_libdir}  %{__ninja} check-all -C %{_vpath_builddir}
+%endif
 
-%ldconfig_scriptlets libs
+%endif
 
-%if %{without compat_build}
+%ldconfig_scriptlets libs
 
 %post devel
-%{_sbindir}/update-alternatives --install %{_bindir}/llvm-config llvm-config %{_bindir}/llvm-config-%{__isa_bits} %{__isa_bits}
+%{_sbindir}/update-alternatives --install %{_bindir}/llvm-config%{exec_suffix} llvm-config%{exec_suffix} %{pkg_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} %{__isa_bits}
+%if %{without compat_build}
+%{_sbindir}/update-alternatives --install %{_bindir}/llvm-config-%{maj_ver} llvm-config-%{maj_ver} %{pkg_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} %{__isa_bits}
+%endif
 
 %postun devel
 if [ $1 -eq 0 ]; then
-  %{_sbindir}/update-alternatives --remove llvm-config %{_bindir}/llvm-config-%{__isa_bits}
-fi
-
+  %{_sbindir}/update-alternatives --remove llvm-config%{exec_suffix} %{pkg_bindir}/llvm-config%{exec_suffix}-%{__isa_bits}
+%if %{without compat_build}
+  %{_sbindir}/update-alternatives --remove llvm-config-%{maj_ver} %{pkg_bindir}/llvm-config%{exec_suffix}-%{__isa_bits}
 %endif
+fi
 
 %files
 %license LICENSE.TXT
@@ -493,9 +484,12 @@ fi
 %{_mandir}/man1/*
 %{_bindir}/*
 
+%exclude %{_bindir}/llvm-config%{exec_suffix}
+%exclude %{pkg_bindir}/llvm-config%{exec_suffix}-%{__isa_bits}
+
 %if %{without compat_build}
-%exclude %{_bindir}/llvm-config
-%exclude %{_bindir}/llvm-config-%{__isa_bits}
+%exclude %{_bindir}/llvm-config-%{maj_ver}
+%exclude %{pkg_bindir}/llvm-config-%{maj_ver}-%{__isa_bits}
 %exclude %{_bindir}/not
 %exclude %{_bindir}/count
 %exclude %{_bindir}/yaml-bench
@@ -504,7 +498,6 @@ fi
 %exclude %{_bindir}/llvm-opt-fuzzer
 %{_datadir}/opt-viewer
 %else
-%exclude %{pkg_bindir}/llvm-config
 %{pkg_bindir}
 %endif
 
@@ -517,6 +510,7 @@ fi
 %{_libdir}/bfd-plugins/LLVMgold.so
 %endif
 %{_libdir}/libLLVM-%{maj_ver}.%{min_ver}*.so
+%{_libdir}/libLLVM-%{maj_ver}.so%{?abi_revision:.%{abi_revision}}
 %{_libdir}/libLTO.so*
 %else
 %config(noreplace) %{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf
@@ -534,18 +528,19 @@ fi
 
 %files devel
 %license LICENSE.TXT
-%if %{without compat_build}
-%ghost %{_bindir}/llvm-config
-%{_bindir}/llvm-config-%{__isa_bits}
+
+%ghost %{_bindir}/llvm-config%{exec_suffix}
+%{pkg_bindir}/llvm-config%{exec_suffix}-%{__isa_bits}
 %{_mandir}/man1/llvm-config*
+
+%if %{without compat_build}
 %{_includedir}/llvm
 %{_includedir}/llvm-c
 %{_libdir}/libLLVM.so
 %{_libdir}/cmake/llvm
+%{pkg_bindir}/llvm-config-%{maj_ver}-%{__isa_bits}
+%ghost %{_bindir}/llvm-config-%{maj_ver}
 %else
-%{_bindir}/llvm-config%{exec_suffix}-%{__isa_bits}
-%{pkg_bindir}/llvm-config
-%{_mandir}/man1/llvm-config%{exec_suffix}.1.gz
 %{install_includedir}/llvm
 %{install_includedir}/llvm-c
 %{pkg_includedir}/llvm
@@ -575,22 +570,12 @@ fi
 
 %files test
 %license LICENSE.TXT
-%{_libexecdir}/tests/llvm/
-%{llvm_libdir}/unittests/
-%{_datadir}/llvm/src/unittests
-%{_datadir}/llvm/src/test.tar.gz
-%{_datadir}/llvm/src/%{_arch}.site.cfg.py
-%{_datadir}/llvm/src/%{_arch}.Unit.site.cfg.py
-%{_datadir}/llvm/lit.fedora.cfg.py
-%{_datadir}/llvm/src/docs/CommandGuide/dsymutil.rst
 %{_bindir}/not
 %{_bindir}/count
 %{_bindir}/yaml-bench
 %{_bindir}/lli-child-target
 %{_bindir}/llvm-isel-fuzzer
 %{_bindir}/llvm-opt-fuzzer
-%{_libdir}/BugpointPasses.so
-%{_libdir}/LLVMHello.so
 
 %files googletest
 %license LICENSE.TXT
@@ -600,6 +585,9 @@ fi
 %endif
 
 %changelog
+* Wed Oct 06 2021 Timm Bäder <tbaeder@redhat.com> - 13.0.0-1
+- 13.0.0 Release
+
 * Wed Aug 18 2021 DJ Delorie <dj@redhat.com> - 12.0.1-3
 - Rebuilt for libffi 3.4.2 SONAME transition.
   Related: rhbz#1891914