* [PR PATCH] new package: llvm13-13.0.1
@ 2022-03-22 14:15 subnut
2022-03-22 14:28 ` [PR PATCH] [Updated] " subnut
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: subnut @ 2022-03-22 14:15 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]
There is a new pull request by subnut against master on the void-packages repository
https://github.com/subnut/void-packages llvm13
https://github.com/void-linux/void-packages/pull/36280
new package: llvm13-13.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**
<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-glibc)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/36280.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-llvm13-36280.patch --]
[-- Type: text/x-diff, Size: 41460 bytes --]
From 4e11d03199110fab645817b9c1b539646b6098c4 Mon Sep 17 00:00:00 2001
From: Subhaditya Nath <sn03.general@gmail.com>
Date: Tue, 22 Mar 2022 18:29:24 +0530
Subject: [PATCH] new package: llvm13-13.0.1
---
srcpkgs/clang | 2 +-
srcpkgs/clang-analyzer | 2 +-
| 2 +-
srcpkgs/libclang | 2 +-
srcpkgs/libclang-cpp | 2 +-
srcpkgs/libcxx | 2 +-
srcpkgs/libcxx-devel | 2 +-
srcpkgs/libcxxabi | 2 +-
srcpkgs/libcxxabi-devel | 2 +-
srcpkgs/libllvm13 | 1 +
srcpkgs/libomp | 2 +-
srcpkgs/libomp-devel | 2 +-
srcpkgs/lld | 2 +-
srcpkgs/lld-devel | 2 +-
srcpkgs/lldb | 2 +-
srcpkgs/lldb-devel | 2 +-
srcpkgs/llvm-libunwind | 2 +-
srcpkgs/llvm-libunwind-devel | 2 +-
.../llvm13/files/llvm-Config-llvm-config.h | 9 +
.../patches/compiler-rt-xray-ppc64-musl.patch | 62 +++
srcpkgs/llvm13/patches/libcxx-musl.patch | 26 ++
srcpkgs/llvm13/patches/libcxx-ppc.patch | 22 +
.../llvm13/patches/libcxx-ssp-nonshared.patch | 11 +
srcpkgs/llvm13/patches/libcxxabi-dl.patch | 25 ++
srcpkgs/llvm13/patches/libunwind-ppc32.patch | 63 +++
srcpkgs/llvm13/patches/lldb-musl.patch | 31 ++
srcpkgs/llvm13/patches/llvm-001-musl.patch | 57 +++
.../patches/llvm-002-musl-ppc64-elfv2.patch | 30 ++
.../patches/llvm-003-ppc-secureplt.patch | 11 +
.../patches/llvm-004-override-opt.patch | 18 +
.../llvm13/patches/llvm-005-ppc-bigpic.patch | 36 ++
.../patches/llvm-006-aarch64-mf_exec.patch | 25 ++
.../llvm13/patches/ppc32-compiler-rt.patch | 21 +
srcpkgs/llvm13/template | 424 ++++++++++++++++++
srcpkgs/llvm13/update | 3 +
35 files changed, 892 insertions(+), 17 deletions(-)
create mode 120000 srcpkgs/libllvm13
create mode 100644 srcpkgs/llvm13/files/llvm-Config-llvm-config.h
create mode 100644 srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-musl.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-ppc.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
create mode 100644 srcpkgs/llvm13/patches/libcxxabi-dl.patch
create mode 100644 srcpkgs/llvm13/patches/libunwind-ppc32.patch
create mode 100644 srcpkgs/llvm13/patches/lldb-musl.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-001-musl.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-004-override-opt.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
create mode 100644 srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
create mode 100644 srcpkgs/llvm13/template
create mode 100644 srcpkgs/llvm13/update
diff --git a/srcpkgs/clang b/srcpkgs/clang
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang
+++ b/srcpkgs/clang
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/clang-analyzer b/srcpkgs/clang-analyzer
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang-analyzer
+++ b/srcpkgs/clang-analyzer
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
--git a/srcpkgs/clang-tools-extra b/srcpkgs/clang-tools-extra
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang-tools-extra
+++ b/srcpkgs/clang-tools-extra
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libclang b/srcpkgs/libclang
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libclang
+++ b/srcpkgs/libclang
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libclang-cpp b/srcpkgs/libclang-cpp
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libclang-cpp
+++ b/srcpkgs/libclang-cpp
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxx b/srcpkgs/libcxx
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxx
+++ b/srcpkgs/libcxx
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxx-devel b/srcpkgs/libcxx-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxx-devel
+++ b/srcpkgs/libcxx-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxxabi b/srcpkgs/libcxxabi
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxxabi
+++ b/srcpkgs/libcxxabi
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxxabi-devel b/srcpkgs/libcxxabi-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxxabi-devel
+++ b/srcpkgs/libcxxabi-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libllvm13 b/srcpkgs/libllvm13
new file mode 120000
index 000000000000..d6366d7d3b95
--- /dev/null
+++ b/srcpkgs/libllvm13
@@ -0,0 +1 @@
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libomp b/srcpkgs/libomp
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libomp
+++ b/srcpkgs/libomp
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libomp-devel b/srcpkgs/libomp-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libomp-devel
+++ b/srcpkgs/libomp-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lld b/srcpkgs/lld
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lld
+++ b/srcpkgs/lld
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lld-devel b/srcpkgs/lld-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lld-devel
+++ b/srcpkgs/lld-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lldb b/srcpkgs/lldb
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lldb
+++ b/srcpkgs/lldb
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lldb-devel b/srcpkgs/lldb-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lldb-devel
+++ b/srcpkgs/lldb-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind b/srcpkgs/llvm-libunwind
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/llvm-libunwind
+++ b/srcpkgs/llvm-libunwind
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind-devel b/srcpkgs/llvm-libunwind-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/llvm-libunwind-devel
+++ b/srcpkgs/llvm-libunwind-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm13/files/llvm-Config-llvm-config.h b/srcpkgs/llvm13/files/llvm-Config-llvm-config.h
new file mode 100644
index 000000000000..2fa08c9be696
--- /dev/null
+++ b/srcpkgs/llvm13/files/llvm-Config-llvm-config.h
@@ -0,0 +1,9 @@
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 32
+#include "llvm-config-32.h"
+#elif __WORDSIZE == 64
+#include "llvm-config-64.h"
+#else
+#error "Unknown word size"
+#endif
diff --git a/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch b/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
new file mode 100644
index 000000000000..d0b61c80c897
--- /dev/null
+++ b/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
@@ -0,0 +1,62 @@
+--- a/compiler-rt/lib/xray/xray_powerpc64.inc
++++ b/compiler-rt/lib/xray/xray_powerpc64.inc
+@@ -12,7 +12,13 @@
+
+ #include <cstdint>
+ #include <mutex>
++#ifdef __GLIBC__
+ #include <sys/platform/ppc.h>
++#else
++#include <cctype>
++#include <cstring>
++#include <cstdlib>
++#endif
+
+ #include "xray_defs.h"
+
+@@ -20,13 +26,45 @@ namespace __xray {
+
+ ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT {
+ CPU = 0;
++#ifdef __GLIBC__
+ return __ppc_get_timebase();
++#else
++ return __builtin_ppc_get_timebase();
++#endif
+ }
+
+ inline uint64_t getTSCFrequency() XRAY_NEVER_INSTRUMENT {
+ static std::mutex M;
+ std::lock_guard<std::mutex> Guard(M);
++#ifdef __GLIBC__
+ return __ppc_get_timebase_freq();
++#else
++ /* FIXME: a less dirty implementation? */
++ static uint64_t base;
++ if (!base) {
++ FILE *f = fopen("/proc/cpuinfo", "rb");
++ if (f) {
++ ssize_t nr;
++ /* virtually always big enough to hold the line */
++ char buf[512];
++ while (fgets(buf, sizeof(buf), f)) {
++ char *ret = strstr(buf, "timebase");
++ if (!ret) {
++ continue;
++ }
++ ret += sizeof("timebase") - 1;
++ ret = strchr(ret, ':');
++ if (!ret) {
++ continue;
++ }
++ base = strtoul(ret + 1, nullptr, 10);
++ break;
++ }
++ fclose(f);
++ }
++ }
++ return base;
++#endif
+ }
+
+ inline bool probeRequiredCPUFeatures() XRAY_NEVER_INSTRUMENT {
diff --git a/srcpkgs/llvm13/patches/libcxx-musl.patch b/srcpkgs/llvm13/patches/libcxx-musl.patch
new file mode 100644
index 000000000000..ef60a16c54bb
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-musl.patch
@@ -0,0 +1,26 @@
+--- a/libcxx/include/locale
++++ b/libcxx/include/locale
+@@ -747,7 +747,11 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
++#if defined(__linux__) && !defined(__GLIBC__)
++ long long __ll = strtoll(__a, &__p2, __base);
++#else
+ long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++#endif
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
+@@ -787,7 +791,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
++#if defined(__linux__) && !defined(__GLIBC__)
++ unsigned long long __ll = strtoull(__a, &__p2, __base);
++#else
+ unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++#endif
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
diff --git a/srcpkgs/llvm13/patches/libcxx-ppc.patch b/srcpkgs/llvm13/patches/libcxx-ppc.patch
new file mode 100644
index 000000000000..7a92f8004e1c
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-ppc.patch
@@ -0,0 +1,22 @@
+This ensures `is_iec559` is defined correctly under all long double ABIs,
+including musl and its 64-bit long double. Also, `__ppc__` or `__ppc64__`
+is not defined on gcc.
+
+--- a/libcxx/include/limits
++++ b/libcxx/include/limits
+@@ -426,8 +426,14 @@ protected:
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
+
+-#if (defined(__ppc__) || defined(__ppc64__))
++#if defined(__powerpc__) || defined(__powerpc64__)
++#if (__LDBL_MAX_EXP__ > __DBL_MAX_EXP__) || (__LDBL_MANT_DIG__ == __DBL_MANT_DIG__)
++ /* IEEE 754 quadruple or double precision */
++ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
++#else
++ /* 128-bit IBM double-double */
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
++#endif
+ #else
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
+ #endif
diff --git a/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch b/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
new file mode 100644
index 000000000000..55ece79f7f3a
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
@@ -0,0 +1,11 @@
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -800,6 +800,8 @@ function(cxx_link_system_libraries target)
+ target_link_libraries(${target} PRIVATE atomic)
+ endif()
+
++#ssp target_link_libraries(${target} PRIVATE ssp_nonshared)
++
+ if (MINGW)
+ target_link_libraries(${target} PRIVATE "${MINGW_LIBRARIES}")
+ endif()
diff --git a/srcpkgs/llvm13/patches/libcxxabi-dl.patch b/srcpkgs/llvm13/patches/libcxxabi-dl.patch
new file mode 100644
index 000000000000..fa84fe6fd94d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxxabi-dl.patch
@@ -0,0 +1,25 @@
+Also link to -ldl to prevent undefined references.
+
+--- a/libcxxabi/src/CMakeLists.txt.orig
++++ b/libcxxabi/src/CMakeLists.txt
+@@ -75,6 +75,7 @@ else()
+ endif()
+
+ add_library_flags_if(LIBCXXABI_HAS_C_LIB c)
++ add_library_flags_if(LIBCXXABI_HAS_C_LIB dl)
+ endif()
+
+ if (LIBCXXABI_USE_COMPILER_RT)
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -781,6 +781,10 @@
+ target_link_libraries(${target} PRIVATE m)
+ endif()
+
++ if (LIBCXX_HAS_C_LIB)
++ target_link_libraries(${target} PRIVATE dl)
++ endif()
++
+ if (LIBCXX_HAS_RT_LIB)
+ target_link_libraries(${target} PRIVATE rt)
+ endif()
diff --git a/srcpkgs/llvm13/patches/libunwind-ppc32.patch b/srcpkgs/llvm13/patches/libunwind-ppc32.patch
new file mode 100644
index 000000000000..2dd7c681637d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libunwind-ppc32.patch
@@ -0,0 +1,63 @@
+This fixes build at least with gcc9 which does not define `__ppc__`.
+
+--- a/libunwind/include/__libunwind_config.h
++++ b/libunwind/include/__libunwind_config.h
+@@ -55,7 +55,7 @@
+ # define _LIBUNWIND_CONTEXT_SIZE 167
+ # define _LIBUNWIND_CURSOR_SIZE 179
+ # define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64
+-# elif defined(__ppc__)
++# elif defined(__powerpc__)
+ # define _LIBUNWIND_TARGET_PPC 1
+ # define _LIBUNWIND_CONTEXT_SIZE 117
+ # define _LIBUNWIND_CURSOR_SIZE 124
+--- a/libunwind/src/UnwindRegistersRestore.S
++++ b/libunwind/src/UnwindRegistersRestore.S
+@@ -389,7 +389,7 @@ Lnovec:
+ PPC64_LR(3)
+ bctr
+
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+
+ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
+ //
+--- a/libunwind/src/UnwindRegistersSave.S
++++ b/libunwind/src/UnwindRegistersSave.S
+@@ -556,7 +556,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
+ blr
+
+
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+
+ //
+ // extern int unw_getcontext(unw_context_t* thread_state)
+--- a/libunwind/src/config.h
++++ b/libunwind/src/config.h
+@@ -105,12 +105,12 @@
+ #define _LIBUNWIND_BUILD_SJLJ_APIS
+ #endif
+
+-#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__)
++#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__powerpc64__)
+ #define _LIBUNWIND_SUPPORT_FRAME_APIS
+ #endif
+
+ #if defined(__i386__) || defined(__x86_64__) || \
+- defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) || \
++ defined(__powerpc__) || defined(__powerpc64__) || \
+ (!defined(__APPLE__) && defined(__arm__)) || \
+ defined(__aarch64__) || \
+ defined(__mips__) || \
+--- a/libunwind/src/libunwind.cpp
++++ b/libunwind/src/libunwind.cpp
+@@ -51,7 +51,7 @@ _LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor,
+ # define REGISTER_KIND Registers_x86_64
+ #elif defined(__powerpc64__)
+ # define REGISTER_KIND Registers_ppc64
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+ # define REGISTER_KIND Registers_ppc
+ #elif defined(__aarch64__)
+ # define REGISTER_KIND Registers_arm64
diff --git a/srcpkgs/llvm13/patches/lldb-musl.patch b/srcpkgs/llvm13/patches/lldb-musl.patch
new file mode 100644
index 000000000000..601c0d138523
--- /dev/null
+++ b/srcpkgs/llvm13/patches/lldb-musl.patch
@@ -0,0 +1,31 @@
+--- a/lldb/source/Plugins/Process/Linux/Procfs.h
++++ b/lldb/source/Plugins/Process/Linux/Procfs.h
+@@ -10,21 +10,12 @@
+ // sys/procfs.h on Android/Linux for all supported architectures.
+
+ #include <sys/ptrace.h>
++#include <asm/ptrace.h>
+
+-#ifdef __ANDROID__
+-#if defined(__arm64__) || defined(__aarch64__)
+-typedef unsigned long elf_greg_t;
+-typedef elf_greg_t
+- elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))];
+-typedef struct user_fpsimd_state elf_fpregset_t;
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#elif defined(__mips__)
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#endif
+-#else // __ANDROID__
++#if !defined(__GLIBC__) && defined(__powerpc__)
++#define pt_regs musl_pt_regs
++#include <sys/procfs.h>
++#undef pt_regs
++#else
+ #include <sys/procfs.h>
+-#endif // __ANDROID__
++#endif
diff --git a/srcpkgs/llvm13/patches/llvm-001-musl.patch b/srcpkgs/llvm13/patches/llvm-001-musl.patch
new file mode 100644
index 000000000000..2580a1a518ca
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-001-musl.patch
@@ -0,0 +1,57 @@
+From faca3fbd15d0c3108493c3c54cd93138e049ac43 Mon Sep 17 00:00:00 2001
+From: Andrea Brancaleoni <miwaxe@gmail.com>
+Date: Tue, 8 Sep 2015 22:03:02 +0200
+Subject: [PATCH 3/3] musl
+
+---
+ include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
+ lib/Support/DynamicLibrary.cpp | 2 +-
+ lib/Support/Unix/Signals.inc | 6 +++---
+ utils/unittest/googletest/src/gtest.cc | 1 +
+ 5 files changed, 17 insertions(+), 6 deletions(-)
+
+diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
+index 34a8a1e3..1214ece5 100644
+--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
++++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+@@ -18,6 +18,15 @@
+ #include "llvm/IR/PassManager.h"
+ #include "llvm/Pass.h"
+
++#undef fopen64
++#undef fseeko64
++#undef fstat64
++#undef fstatvfs64
++#undef ftello64
++#undef lstat64
++#undef stat64
++#undef tmpfile64
++
+ namespace llvm {
+ template <typename T> class ArrayRef;
+ class Triple;
+diff --git a/lib/Support/Unix/DynamicLibrary.inc b/lib/Support/Unix/DynamicLibrary.inc
+index a2a37996..2f86c470 100644
+--- a/llvm/lib/Support/Unix/DynamicLibrary.inc
++++ b/llvm/lib/Support/Unix/DynamicLibrary.inc
+@@ -102,7 +102,7 @@ static void *DoSearch(const char* SymbolName) {
+
+ // This macro returns the address of a well-known, explicit symbol
+ #define EXPLICIT_SYMBOL(SYM) \
+- if (!strcmp(SymbolName, #SYM)) return &SYM
++ if (!strcmp(SymbolName, #SYM)) return (void *)&SYM
+
+ // Under glibc we have a weird situation. The stderr/out/in symbols are both
+ // macros and global variables because of standards requirements. So, we
+diff --git a/utils/unittest/googletest/src/gtest.cc b/utils/unittest/googletest/src/gtest.cc
+index d882ab2e..f1fb12d0 100644
+--- a/llvm/utils/unittest/googletest/src/gtest.cc
++++ b/llvm/utils/unittest/googletest/src/gtest.cc
+@@ -114,6 +114,7 @@
+
+ #if GTEST_CAN_STREAM_RESULTS_
+ # include <arpa/inet.h> // NOLINT
++# include <sys/socket.h> // NOLINT
+ # include <netdb.h> // NOLINT
+ # include <sys/socket.h> // NOLINT
+ # include <sys/types.h> // NOLINT
diff --git a/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch b/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
new file mode 100644
index 000000000000..68bd57ecbade
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
@@ -0,0 +1,30 @@
+This patches LLVM to use ELFv2 on ppc64 unconditionally unless overridden. We
+need this because unlike most distros we use ELFv2 for both glibc and musl
+on big endian ppc64.
+
+diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
+index 0634833e..b7cbc2e7 100644
+--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
++++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+@@ -226,9 +226,8 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
+
+ switch (TT.getArch()) {
+ case Triple::ppc64le:
+- return PPCTargetMachine::PPC_ABI_ELFv2;
+ case Triple::ppc64:
+- return PPCTargetMachine::PPC_ABI_ELFv1;
++ return PPCTargetMachine::PPC_ABI_ELFv2;
+ default:
+ return PPCTargetMachine::PPC_ABI_UNKNOWN;
+ }
+diff --git a/test/CodeGen/PowerPC/ppc64-elf-abi.ll b/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+index 8b1cf6b5..296a2afa 100644
+--- a/llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
++++ b/llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+@@ -1,4 +1,5 @@
+-; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv1
++; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2
++; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-musl < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2
diff --git a/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch b/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
new file mode 100644
index 000000000000..32bd57a25b1d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
@@ -0,0 +1,11 @@
+--- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
++++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+@@ -169,7 +169,7 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
+
+ if ((TargetTriple.isOSFreeBSD() && TargetTriple.getOSMajorVersion() >= 13) ||
+ TargetTriple.isOSNetBSD() || TargetTriple.isOSOpenBSD() ||
+- TargetTriple.isMusl())
++ isTargetLinux())
+ SecurePlt = true;
+
+ if (HasSPE && IsPPC64)
diff --git a/srcpkgs/llvm13/patches/llvm-004-override-opt.patch b/srcpkgs/llvm13/patches/llvm-004-override-opt.patch
new file mode 100644
index 000000000000..8226f0704053
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-004-override-opt.patch
@@ -0,0 +1,18 @@
+This allows us to override the optimization level as not all platforms can
+deal with -O3.
+
+--- a/llvm/CMakeLists.txt
++++ b/llvm/CMakeLists.txt
+@@ -960,6 +960,12 @@ if( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
+ llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
+ endif()
+
++set(VOID_CXX_OPT_FLAGS "" CACHE STRING "Optimization level to use")
++
++if (NOT VOID_CXX_OPT_FLAGS STREQUAL "")
++ llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "${VOID_CXX_OPT_FLAGS}")
++endif()
++
+ # Put this before tblgen. Else we have a circular dependence.
+ add_subdirectory(lib/Demangle)
+ add_subdirectory(lib/Support)
diff --git a/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch b/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
new file mode 100644
index 000000000000..cb4eee59c340
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
@@ -0,0 +1,36 @@
+From f3dbdd49c06bfafc1d6138094cf42889c14d38b6 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 3 Nov 2019 10:57:27 -0600
+Subject: [PATCH] [LLVM][PowerPC] Assume BigPIC if no PIC level is specified
+
+---
+ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 2 +-
+ llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
+index cce21f32..87ca5f9b 100644
+--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
++++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+@@ -599,7 +599,7 @@ void PPCAsmPrinter::EmitTlsCall(const MachineInstr *MI,
+
+ // Add 32768 offset to the symbol so we follow up the latest GOT/PLT ABI.
+ if (Kind == MCSymbolRefExpr::VK_PLT && Subtarget->isSecurePlt() &&
+- M->getPICLevel() == PICLevel::BigPIC)
++ M->getPICLevel() != PICLevel::SmallPIC)
+ TlsRef = MCBinaryExpr::createAdd(
+ TlsRef, MCConstantExpr::create(32768, OutContext), OutContext);
+ const MachineOperand &MO = MI->getOperand(2);
+diff --git a/lib/Target/PowerPC/PPCMCInstLower.cpp b/lib/Target/PowerPC/PPCMCInstLower.cpp
+index 5cc180d7..a5b02565 100644
+--- a/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
++++ b/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
+@@ -117,7 +117,7 @@ static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol,
+ const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, RefKind, Ctx);
+ // If -msecure-plt -fPIC, add 32768 to symbol.
+ if (Subtarget->isSecurePlt() && TM.isPositionIndependent() &&
+- M->getPICLevel() == PICLevel::BigPIC &&
++ M->getPICLevel() != PICLevel::SmallPIC &&
+ MO.getTargetFlags() == PPCII::MO_PLT)
+ Expr =
+ MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(32768, Ctx), Ctx);
diff --git a/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch b/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
new file mode 100644
index 000000000000..6cca600d6603
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
@@ -0,0 +1,25 @@
+Fix failures in AllocationTests/MappedMemoryTest.* on aarch64:
+
+ Failing Tests (8):
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3
+
+Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10
+
+--- a/llvm/lib/Support/Unix/Memory.inc
++++ b/llvm/lib/Support/Unix/Memory.inc
+@@ -50,7 +50,7 @@ static int getPosixProtectionFlags(unsigned Flags) {
+ return PROT_READ | PROT_WRITE | PROT_EXEC;
+ case llvm::sys::Memory::MF_EXEC:
+ #if (defined(__FreeBSD__) || defined(__POWERPC__) || defined (__ppc__) || \
+- defined(_POWER) || defined(_ARCH_PPC))
++ defined(_POWER) || defined(_ARCH_PPC) || (defined(__linux__) && defined(__aarch64__)))
+ // On PowerPC, having an executable page that has no read permission
+ // can have unintended consequences. The function InvalidateInstruction-
+ // Cache uses instructions dcbf and icbi, both of which are treated by
diff --git a/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch b/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
new file mode 100644
index 000000000000..f92efb6aade1
--- /dev/null
+++ b/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
@@ -0,0 +1,21 @@
+commit ba4ede595ff9599232f5dd2b4384c243137b53fc
+Author: Daniel Kolesa <daniel@octaforge.org>
+Date: Tue Jun 22 23:40:54 2021 +0200
+
+ enable compiler-rt support for ppc32
+
+diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake
+index 1edab43..5c0c8a2 100644
+--- a/compiler-rt/cmake/base-config-ix.cmake
++++ b/compiler-rt/cmake/base-config-ix.cmake
+@@ -207,9 +207,7 @@ macro(test_targets)
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc64le|ppc64le")
+ test_target_arch(powerpc64le "" "-m64")
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
+- if(CMAKE_SYSTEM_NAME MATCHES "AIX")
+- test_target_arch(powerpc "" "-m32")
+- endif()
++ test_target_arch(powerpc "" "-m32")
+ test_target_arch(powerpc64 "" "-m64")
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "s390x")
+ test_target_arch(s390x "" "")
diff --git a/srcpkgs/llvm13/template b/srcpkgs/llvm13/template
new file mode 100644
index 000000000000..e6b519e08652
--- /dev/null
+++ b/srcpkgs/llvm13/template
@@ -0,0 +1,424 @@
+# Template file for 'llvm13'
+pkgname=llvm13
+version=13.0.1
+revision=1
+wrksrc="llvm-project-${version}.src"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLDB_USE_SYSTEM_SIX=YES
+ -DLIBCXX_CXX_ABI=libcxxabi
+ -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=YES
+ -DLIBCXXABI_USE_LLVM_UNWINDER=YES
+ -DLIBCXXABI_ENABLE_STATIC_UNWINDER=YES
+ -DLIBOMP_ENABLE_SHARED=YES
+ -DLIBOMP_INSTALL_ALIASES=NO
+ -DLLVM_INCLUDE_DOCS=YES
+ -DLLVM_BUILD_DOCS=YES
+ -DLLVM_ENABLE_SPHINX=YES
+ -DSPHINX_WARNINGS_AS_ERRORS=NO
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BUILD_LLVM_DYLIB=YES
+ -DLLVM_LINK_LLVM_DYLIB=YES
+ -DLLVM_ENABLE_RTTI=YES
+ -DLLVM_ENABLE_FFI=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include"
+hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
+ python3-recommonmark python3-sphinx-automodapi"
+makedepends="python3-devel zlib-devel elfutils-devel libffi-devel libedit-devel
+ libxml2-devel binutils-devel libatomic-devel"
+depends="libllvm13>=${version}_${revision}"
+short_desc="Low Level Virtual Machine"
+maintainer="q66 <daniel@octaforge.org>"
+license="Apache-2.0"
+homepage="https://www.llvm.org"
+distfiles="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz"
+checksum=326335a830f2e32d06d0a36393b5455d17dc73e0bd1211065227ee014f92cbf8
+lib32disabled=yes
+python_version=3
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+ configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES"
+ makedepends+=" libexecinfo-devel"
+ depends+=" libexecinfo-devel"
+fi
+
+# "operand out of range" assembler failures
+case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ ppc*) configure_args+=" -DCLANG_ENABLE_CLANGD=OFF" ;;
+esac
+
+_enabled_projects="clang;clang-tools-extra;compiler-rt;libcxx;libcxxabi;libunwind;lld"
+
+_lldb_enable=yes
+_libomp_enable=no
+
+case "$XBPS_TARGET_MACHINE" in
+ ppc64le*) ;;
+ ppc*|i686*) _lldb_enable=no ;;
+esac
+
+case "$XBPS_TARGET_MACHINE" in
+ x86_64*|aarch64*|ppc64*) _libomp_enable=yes;;
+esac
+
+subpackages="clang-tools-extra"
+
+# must go before clang
+if [ "$_libomp_enable" = "yes" ]; then
+ _enabled_projects+=";openmp"
+ subpackages+=" libomp libomp-devel"
+ # because of cmake nonsense referencing libomptarget.so.*
+ depends+=" libomp>=${version}_${revision}"
+fi
+
+subpackages+=" clang clang-analyzer libclang libclang-cpp
+ llvm-libunwind llvm-libunwind-devel libcxx libcxx-devel
+ libcxxabi libcxxabi-devel libllvm13"
+
+if [ "$_lldb_enable" = "yes" ]; then
+ # XXX fails to cross compile due to python
+ _enabled_projects+=";lldb"
+ subpackages+=" lldb lldb-devel"
+fi
+
+subpackages+=" lld lld-devel"
+
+configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
+
+post_patch() {
+ if [ "$_lldb_enable" = "yes" ]; then
+ if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+ vsed -i 's|__ptrace_request|int|g' \
+ ${wrksrc}/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+ fi
+ # disable docs for lldb as they fail to generate
+ vsed -i '/add_subdirectory(docs)/d' \
+ ${wrksrc}/lldb/CMakeLists.txt
+ fi
+
+ # update config.guess for better platform detection
+ cp $XBPS_COMMONDIR/environment/configure/automake/config.guess \
+ ${wrksrc}/llvm/cmake
+
+ # fix linker failures on some archs
+ vsed -i 's,check_library_exists(gcc_s .*,set(LIBCXXABI_HAS_GCC_S_LIB ON),' \
+ ${wrksrc}/libcxxabi/cmake/config-ix.cmake
+ vsed -i 's,check_library_exists(gcc .*,set(LIBCXXABI_HAS_GCC_LIB ON),' \
+ ${wrksrc}/libcxxabi/cmake/config-ix.cmake
+
+ # need libssp_nonshared on some musl platforms (because of nodefaultlibs)
+ case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ ppc*-musl|i686-musl|mips*-musl)
+ vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+ ${wrksrc}/libunwind/src/CMakeLists.txt
+ vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+ ${wrksrc}/libcxxabi/src/CMakeLists.txt
+ vsed -i 's,#ssp,,' ${wrksrc}/libcxx/CMakeLists.txt
+ ;;
+ esac
+
+ case "$XBPS_TARGET_MACHINE" in
+ x86_64-musl) # some sanitizer currently only on x86_64 stuff needs backtrace
+ vsed -i 's,# Set common link flags.,list(APPEND SANITIZER_COMMON_LINK_LIBS execinfo),' \
+ ${wrksrc}/compiler-rt/CMakeLists.txt
+ ;;
+ arm*-musl|i686-musl) # sanitizer code is broken since it duplicates some libc bits
+ vsed -i 's/set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)/set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE)/' \
+ ${wrksrc}/compiler-rt/cmake/config-ix.cmake
+ ;;
+ esac
+}
+
+pre_configure() {
+ local triplet
+
+ # Vastly reduce size of debugging symbols:
+ CFLAGS=${CFLAGS/ -g/ -g1}
+ CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+
+ # since gcc9, the build likes to blow up for ppc32 apparently because
+ # of clang being too large for a 24-bit relative call to the PLT, so
+ # optimize for size instead
+ case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ mips*-musl|ppc*) configure_args+=" -DVOID_CXX_OPT_FLAGS=-Os" ;;
+ esac
+
+ if [ "$CROSS_BUILD" ]; then
+ msg_normal "Building host tblgen\n"
+ mkdir -p build/HOST
+ cd build/HOST
+ CC="$BUILD_CC" CXX="$BUILD_CXX" CFLAGS="$BUILD_CFLAGS" \
+ CXXFLAGS="$BUILD_CXXFLAGS" LDFLAGS="$BUILD_LDFLAGS" \
+ cmake ../.. -DCMAKE_BUILD_TYPE=Release \
+ -DLLVM_ENABLE_PROJECTS=${_enabled_projects}
+ make ${makejobs} -C utils/TableGen
+ make ${makejobs} -C tools/clang/utils/TableGen
+ [ "$_lldb_enable" = "yes" ] && make ${makejobs} -C tools/lldb/utils/TableGen
+ configure_args+=" -DLLVM_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/llvm-tblgen"
+ configure_args+=" -DCLANG_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/clang-tblgen"
+ [ "$_lldb_enable" = "yes" ] && configure_args+=" -DLLDB_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/lldb-tblgen"
+ cd ../..
+ fi
+
+ case "$XBPS_TARGET_MACHINE" in
+ i686*) _arch="X86";;
+ x86_64*) _arch="X86";;
+ armv5*) _arch="Armv5te";;
+ armv6*) _arch="Armv6";;
+ armv7*) _arch="Armv7";;
+ aarch64*) _arch="AArch64";;
+ mips*) _arch="Mips";;
+ ppc*) _arch="PowerPC";;
+ riscv64*) _arch="RISCV64";;
+ esac
+
+ triplet=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}
+
+ configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+ configure_args+=" -DLLVM_HOST_TRIPLE=${triplet}"
+ configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${triplet}"
+}
+
+do_install() {
+ cd build
+ cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr -P cmake_install.cmake
+
+ # Required for multilib.
+ if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
+ for _header in llvm-config; do
+ mv ${DESTDIR}/usr/include/llvm/Config/${_header}{,-64}.h
+ vinstall ${FILESDIR}/llvm-Config-${_header}.h 644 \
+ usr/include/llvm/Config ${_header}.h
+ done
+ fi
+
+ # Remove llvm-config-host in cross builds.
+ if [ "$CROSS_BUILD" ]; then
+ rm -f ${DESTDIR}/usr/bin/llvm-config-host
+ fi
+
+ # Install libcxxabi headers
+ vinstall ${wrksrc}/libcxxabi/include/__cxxabi_config.h 644 usr/include
+ vinstall ${wrksrc}/libcxxabi/include/cxxabi.h 644 usr/include
+
+ # Install libunwind headers
+ vinstall ${wrksrc}/libunwind/include/__libunwind_config.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/libunwind.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/unwind.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/mach-o/compact_unwind_encoding.h \
+ 644 usr/include/mach-o
+}
+
+clang-analyzer_package() {
+ pycompile_dirs="usr/share/scan-view"
+ depends="clang-${version}_${revision} python3 perl"
+ short_desc+=" - A source code analysis framework"
+ homepage="https://clang-analyzer.llvm.org/"
+ pkg_install() {
+ vmove usr/share/man/man1/scan-build.1
+ vmove "/usr/bin/scan-*"
+ vmove "/usr/share/scan-*"
+ vmove "/usr/libexec/*analyzer"
+ }
+}
+
+clang-tools-extra_package() {
+ lib32disabled=yes
+ depends="clang-${version}_${revision} python3"
+ short_desc+=" - Extra Clang tools"
+ homepage="https://clang.llvm.org/extra/"
+ pkg_install() {
+ vmove usr/include/clang-tidy
+ vmove usr/bin/clang-apply-replacements
+ vmove usr/bin/clang-query
+ vmove usr/bin/clang-rename
+ vmove usr/bin/clang-tidy
+ vmove usr/bin/diagtool
+ vmove usr/bin/find-all-symbols
+ vmove usr/bin/hmaptool
+ vmove usr/bin/modularize
+ vmove usr/bin/pp-trace
+ vmove usr/bin/sancov
+ vmove "usr/lib/libclangApplyReplacements*"
+ vmove "usr/lib/libclangQuery*"
+ vmove "usr/lib/libclangTidy*"
+ vmove "usr/share/clang/*tidy*"
+ vmove usr/share/doc/clang-tools
+ vmove usr/share/man/man1/extraclangtools.1
+ vmove usr/share/man/man1/diagtool.1
+ }
+}
+
+clang_package() {
+ lib32disabled=yes
+ depends="libstdc++-devel libgcc-devel binutils ${XBPS_TARGET_LIBC}-devel
+ libclang-${version}_${revision}"
+ short_desc+=" - C language family frontend"
+ homepage="https://clang.llvm.org/"
+ pkg_install() {
+ vmove usr/include/clang
+ vmove usr/include/clang-c
+ vmove "usr/bin/*clang*"
+ vmove usr/bin/c-index-test
+ vmove usr/lib/clang
+ vmove usr/lib/cmake/clang
+ vmove "usr/lib/libclang*.a"
+ vmove "usr/lib/libclang*.so"
+ vmove usr/share/clang
+ vmove usr/share/doc/clang
+ vmove usr/share/man/man1/clang.1
+ }
+}
+
+libclang_package() {
+ short_desc+=" - C frontend runtime library"
+ pkg_install() {
+ vmove "usr/lib/libclang.so.*"
+ }
+}
+
+libclang-cpp_package() {
+ short_desc+=" - C frontend runtime library (C++ interface)"
+ pkg_install() {
+ vmove "usr/lib/libclang-cpp.so.*"
+ }
+}
+
+lld_package() {
+ lib32disabled=yes
+ short_desc+=" - linker"
+ homepage="https://lld.llvm.org"
+ pkg_install() {
+ vmove usr/bin/lld*
+ vmove usr/bin/wasm-ld
+ vmove usr/bin/ld.lld*
+ vmove usr/bin/ld64.lld*
+ vmove usr/share/doc/lld
+ }
+}
+
+lld-devel_package() {
+ lib32disabled=yes
+ short_desc+=" - linker - development files"
+ homepage="https://lld.llvm.org"
+ depends="lld>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/include/lld
+ vmove usr/lib/cmake/lld
+ vmove "usr/lib/liblld*a"
+ }
+}
+
+lldb_package() {
+ lib32disabled=yes
+ depends+=" python3-six"
+ short_desc+=" - LLDB debugger"
+ homepage="https://lldb.llvm.org/"
+ pkg_install() {
+ vmove usr/bin/*lldb*
+ vmove usr/lib/liblldb*so.*
+ vmove /usr/lib/python*
+ }
+}
+
+lldb-devel_package() {
+ lib32disabled=yes
+ depends="lldb>=${version}_${revision}"
+ short_desc+=" - LLDB debugger - development files"
+ pkg_install() {
+ vmove usr/include/lldb
+ vmove "usr/lib/liblldb*.so"
+ }
+}
+
+llvm-libunwind_package() {
+ short_desc+=" - libunwind"
+ pkg_install() {
+ vmove "usr/lib/libunwind.so.*"
+ }
+}
+
+llvm-libunwind-devel_package() {
+ short_desc+=" - libunwind - development files"
+ depends="llvm-libunwind>=${version}_${revision}"
+ conflicts="libunwind-devel>=0"
+ pkg_install() {
+ vmove usr/lib/libunwind.so
+ vmove usr/lib/libunwind.a
+ vmove "usr/include/*unwind*"
+ vmove usr/include/mach-o
+ vmove usr/share/doc/libunwind
+ }
+}
+
+libcxxabi_package() {
+ short_desc+=" - low level support for libc++"
+ pkg_install() {
+ vmove "usr/lib/libc++abi.so.*"
+ }
+}
+
+libcxxabi-devel_package() {
+ short_desc+=" - low level support for libc++ - development files"
+ depends="libcxxabi>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/lib/libc++abi.so
+ vmove usr/lib/libc++abi.a
+ vmove "usr/include/*cxxabi*"
+ }
+}
+
+libcxx_package() {
+ short_desc+=" - C++ standard library"
+ pkg_install() {
+ vmove "usr/lib/libc++.so.*"
+ }
+}
+
+libcxx-devel_package() {
+ short_desc+=" - C++ standard library - development files"
+ depends="libcxx>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/lib/libc++.so
+ vmove usr/lib/libc++.a
+ vmove usr/lib/libc++experimental.a
+ vmove usr/include/c++
+ vmove usr/share/doc/libcxx
+ }
+}
+
+libomp_package() {
+ short_desc+=" - Clang OpenMP support library"
+ pkg_install() {
+ vmove usr/lib/libomp.so
+ vmove "usr/lib/libomptarget.rtl.*.so"
+ vmove usr/lib/libarcher.so
+ vmove "usr/lib/libomp*.so.*"
+ }
+}
+
+libomp-devel_package() {
+ short_desc+=" - Clang OpenMP support library - development files"
+ depends="libomp>=${version}_${revision}"
+ pkg_install() {
+ vmove "usr/lib/libomp*.so"
+ vmove "usr/lib/libarcher*"
+ vmove "usr/include/omp*.h"
+ vmove "usr/lib/clang/${version}/include/omp*.h"
+ vmove usr/share/man/man1/llvmopenmp.1
+ vmove usr/share/doc/openmp
+ }
+}
+
+libllvm13_package() {
+ short_desc+=" - runtime library"
+ pkg_install() {
+ vmove "usr/lib/libLLVM-*.so*"
+ }
+}
diff --git a/srcpkgs/llvm13/update b/srcpkgs/llvm13/update
new file mode 100644
index 000000000000..e95cf26b3586
--- /dev/null
+++ b/srcpkgs/llvm13/update
@@ -0,0 +1,3 @@
+site="https://github.com/llvm/llvm-project/releases"
+pattern="llvmorg-\K(\d+.){2}\d+(-rc\d+)?"
+ignore="*-rc*"
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR PATCH] [Updated] new package: llvm13-13.0.1
2022-03-22 14:15 [PR PATCH] new package: llvm13-13.0.1 subnut
@ 2022-03-22 14:28 ` subnut
2022-03-22 14:31 ` subnut
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: subnut @ 2022-03-22 14:28 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]
There is an updated pull request by subnut against master on the void-packages repository
https://github.com/subnut/void-packages llvm13
https://github.com/void-linux/void-packages/pull/36280
new package: llvm13-13.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**
<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-glibc)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/36280.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-llvm13-36280.patch --]
[-- Type: text/x-diff, Size: 41545 bytes --]
From c3f0a9bd7b5f1c3611f0878c2fa57665d9bd7205 Mon Sep 17 00:00:00 2001
From: Subhaditya Nath <sn03.general@gmail.com>
Date: Tue, 22 Mar 2022 18:29:24 +0530
Subject: [PATCH] new package: llvm13-13.0.1
---
srcpkgs/clang | 2 +-
srcpkgs/clang-analyzer | 2 +-
| 2 +-
srcpkgs/libclang | 2 +-
srcpkgs/libclang-cpp | 2 +-
srcpkgs/libcxx | 2 +-
srcpkgs/libcxx-devel | 2 +-
srcpkgs/libcxxabi | 2 +-
srcpkgs/libcxxabi-devel | 2 +-
srcpkgs/libllvm13 | 1 +
srcpkgs/libomp | 2 +-
srcpkgs/libomp-devel | 2 +-
srcpkgs/lld | 2 +-
srcpkgs/lld-devel | 2 +-
srcpkgs/lldb | 2 +-
srcpkgs/lldb-devel | 2 +-
srcpkgs/llvm-libunwind | 2 +-
srcpkgs/llvm-libunwind-devel | 2 +-
.../llvm13/files/llvm-Config-llvm-config.h | 9 +
.../patches/compiler-rt-xray-ppc64-musl.patch | 62 +++
srcpkgs/llvm13/patches/libcxx-musl.patch | 26 ++
srcpkgs/llvm13/patches/libcxx-ppc.patch | 22 +
.../llvm13/patches/libcxx-ssp-nonshared.patch | 11 +
srcpkgs/llvm13/patches/libcxxabi-dl.patch | 25 +
srcpkgs/llvm13/patches/libunwind-ppc32.patch | 63 +++
srcpkgs/llvm13/patches/lldb-musl.patch | 31 ++
srcpkgs/llvm13/patches/llvm-001-musl.patch | 57 +++
.../patches/llvm-002-musl-ppc64-elfv2.patch | 30 ++
.../patches/llvm-003-ppc-secureplt.patch | 11 +
.../patches/llvm-004-override-opt.patch | 18 +
.../llvm13/patches/llvm-005-ppc-bigpic.patch | 36 ++
.../patches/llvm-006-aarch64-mf_exec.patch | 25 +
.../llvm13/patches/ppc32-compiler-rt.patch | 21 +
srcpkgs/llvm13/template | 427 ++++++++++++++++++
srcpkgs/llvm13/update | 3 +
35 files changed, 895 insertions(+), 17 deletions(-)
create mode 120000 srcpkgs/libllvm13
create mode 100644 srcpkgs/llvm13/files/llvm-Config-llvm-config.h
create mode 100644 srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-musl.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-ppc.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
create mode 100644 srcpkgs/llvm13/patches/libcxxabi-dl.patch
create mode 100644 srcpkgs/llvm13/patches/libunwind-ppc32.patch
create mode 100644 srcpkgs/llvm13/patches/lldb-musl.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-001-musl.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-004-override-opt.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
create mode 100644 srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
create mode 100644 srcpkgs/llvm13/template
create mode 100644 srcpkgs/llvm13/update
diff --git a/srcpkgs/clang b/srcpkgs/clang
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang
+++ b/srcpkgs/clang
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/clang-analyzer b/srcpkgs/clang-analyzer
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang-analyzer
+++ b/srcpkgs/clang-analyzer
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
--git a/srcpkgs/clang-tools-extra b/srcpkgs/clang-tools-extra
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang-tools-extra
+++ b/srcpkgs/clang-tools-extra
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libclang b/srcpkgs/libclang
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libclang
+++ b/srcpkgs/libclang
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libclang-cpp b/srcpkgs/libclang-cpp
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libclang-cpp
+++ b/srcpkgs/libclang-cpp
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxx b/srcpkgs/libcxx
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxx
+++ b/srcpkgs/libcxx
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxx-devel b/srcpkgs/libcxx-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxx-devel
+++ b/srcpkgs/libcxx-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxxabi b/srcpkgs/libcxxabi
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxxabi
+++ b/srcpkgs/libcxxabi
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxxabi-devel b/srcpkgs/libcxxabi-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxxabi-devel
+++ b/srcpkgs/libcxxabi-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libllvm13 b/srcpkgs/libllvm13
new file mode 120000
index 000000000000..d6366d7d3b95
--- /dev/null
+++ b/srcpkgs/libllvm13
@@ -0,0 +1 @@
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libomp b/srcpkgs/libomp
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libomp
+++ b/srcpkgs/libomp
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libomp-devel b/srcpkgs/libomp-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libomp-devel
+++ b/srcpkgs/libomp-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lld b/srcpkgs/lld
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lld
+++ b/srcpkgs/lld
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lld-devel b/srcpkgs/lld-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lld-devel
+++ b/srcpkgs/lld-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lldb b/srcpkgs/lldb
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lldb
+++ b/srcpkgs/lldb
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lldb-devel b/srcpkgs/lldb-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lldb-devel
+++ b/srcpkgs/lldb-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind b/srcpkgs/llvm-libunwind
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/llvm-libunwind
+++ b/srcpkgs/llvm-libunwind
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind-devel b/srcpkgs/llvm-libunwind-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/llvm-libunwind-devel
+++ b/srcpkgs/llvm-libunwind-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm13/files/llvm-Config-llvm-config.h b/srcpkgs/llvm13/files/llvm-Config-llvm-config.h
new file mode 100644
index 000000000000..2fa08c9be696
--- /dev/null
+++ b/srcpkgs/llvm13/files/llvm-Config-llvm-config.h
@@ -0,0 +1,9 @@
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 32
+#include "llvm-config-32.h"
+#elif __WORDSIZE == 64
+#include "llvm-config-64.h"
+#else
+#error "Unknown word size"
+#endif
diff --git a/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch b/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
new file mode 100644
index 000000000000..d0b61c80c897
--- /dev/null
+++ b/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
@@ -0,0 +1,62 @@
+--- a/compiler-rt/lib/xray/xray_powerpc64.inc
++++ b/compiler-rt/lib/xray/xray_powerpc64.inc
+@@ -12,7 +12,13 @@
+
+ #include <cstdint>
+ #include <mutex>
++#ifdef __GLIBC__
+ #include <sys/platform/ppc.h>
++#else
++#include <cctype>
++#include <cstring>
++#include <cstdlib>
++#endif
+
+ #include "xray_defs.h"
+
+@@ -20,13 +26,45 @@ namespace __xray {
+
+ ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT {
+ CPU = 0;
++#ifdef __GLIBC__
+ return __ppc_get_timebase();
++#else
++ return __builtin_ppc_get_timebase();
++#endif
+ }
+
+ inline uint64_t getTSCFrequency() XRAY_NEVER_INSTRUMENT {
+ static std::mutex M;
+ std::lock_guard<std::mutex> Guard(M);
++#ifdef __GLIBC__
+ return __ppc_get_timebase_freq();
++#else
++ /* FIXME: a less dirty implementation? */
++ static uint64_t base;
++ if (!base) {
++ FILE *f = fopen("/proc/cpuinfo", "rb");
++ if (f) {
++ ssize_t nr;
++ /* virtually always big enough to hold the line */
++ char buf[512];
++ while (fgets(buf, sizeof(buf), f)) {
++ char *ret = strstr(buf, "timebase");
++ if (!ret) {
++ continue;
++ }
++ ret += sizeof("timebase") - 1;
++ ret = strchr(ret, ':');
++ if (!ret) {
++ continue;
++ }
++ base = strtoul(ret + 1, nullptr, 10);
++ break;
++ }
++ fclose(f);
++ }
++ }
++ return base;
++#endif
+ }
+
+ inline bool probeRequiredCPUFeatures() XRAY_NEVER_INSTRUMENT {
diff --git a/srcpkgs/llvm13/patches/libcxx-musl.patch b/srcpkgs/llvm13/patches/libcxx-musl.patch
new file mode 100644
index 000000000000..ef60a16c54bb
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-musl.patch
@@ -0,0 +1,26 @@
+--- a/libcxx/include/locale
++++ b/libcxx/include/locale
+@@ -747,7 +747,11 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
++#if defined(__linux__) && !defined(__GLIBC__)
++ long long __ll = strtoll(__a, &__p2, __base);
++#else
+ long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++#endif
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
+@@ -787,7 +791,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
++#if defined(__linux__) && !defined(__GLIBC__)
++ unsigned long long __ll = strtoull(__a, &__p2, __base);
++#else
+ unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++#endif
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
diff --git a/srcpkgs/llvm13/patches/libcxx-ppc.patch b/srcpkgs/llvm13/patches/libcxx-ppc.patch
new file mode 100644
index 000000000000..7a92f8004e1c
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-ppc.patch
@@ -0,0 +1,22 @@
+This ensures `is_iec559` is defined correctly under all long double ABIs,
+including musl and its 64-bit long double. Also, `__ppc__` or `__ppc64__`
+is not defined on gcc.
+
+--- a/libcxx/include/limits
++++ b/libcxx/include/limits
+@@ -426,8 +426,14 @@ protected:
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
+
+-#if (defined(__ppc__) || defined(__ppc64__))
++#if defined(__powerpc__) || defined(__powerpc64__)
++#if (__LDBL_MAX_EXP__ > __DBL_MAX_EXP__) || (__LDBL_MANT_DIG__ == __DBL_MANT_DIG__)
++ /* IEEE 754 quadruple or double precision */
++ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
++#else
++ /* 128-bit IBM double-double */
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
++#endif
+ #else
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
+ #endif
diff --git a/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch b/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
new file mode 100644
index 000000000000..55ece79f7f3a
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
@@ -0,0 +1,11 @@
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -800,6 +800,8 @@ function(cxx_link_system_libraries target)
+ target_link_libraries(${target} PRIVATE atomic)
+ endif()
+
++#ssp target_link_libraries(${target} PRIVATE ssp_nonshared)
++
+ if (MINGW)
+ target_link_libraries(${target} PRIVATE "${MINGW_LIBRARIES}")
+ endif()
diff --git a/srcpkgs/llvm13/patches/libcxxabi-dl.patch b/srcpkgs/llvm13/patches/libcxxabi-dl.patch
new file mode 100644
index 000000000000..fa84fe6fd94d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxxabi-dl.patch
@@ -0,0 +1,25 @@
+Also link to -ldl to prevent undefined references.
+
+--- a/libcxxabi/src/CMakeLists.txt.orig
++++ b/libcxxabi/src/CMakeLists.txt
+@@ -75,6 +75,7 @@ else()
+ endif()
+
+ add_library_flags_if(LIBCXXABI_HAS_C_LIB c)
++ add_library_flags_if(LIBCXXABI_HAS_C_LIB dl)
+ endif()
+
+ if (LIBCXXABI_USE_COMPILER_RT)
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -781,6 +781,10 @@
+ target_link_libraries(${target} PRIVATE m)
+ endif()
+
++ if (LIBCXX_HAS_C_LIB)
++ target_link_libraries(${target} PRIVATE dl)
++ endif()
++
+ if (LIBCXX_HAS_RT_LIB)
+ target_link_libraries(${target} PRIVATE rt)
+ endif()
diff --git a/srcpkgs/llvm13/patches/libunwind-ppc32.patch b/srcpkgs/llvm13/patches/libunwind-ppc32.patch
new file mode 100644
index 000000000000..2dd7c681637d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libunwind-ppc32.patch
@@ -0,0 +1,63 @@
+This fixes build at least with gcc9 which does not define `__ppc__`.
+
+--- a/libunwind/include/__libunwind_config.h
++++ b/libunwind/include/__libunwind_config.h
+@@ -55,7 +55,7 @@
+ # define _LIBUNWIND_CONTEXT_SIZE 167
+ # define _LIBUNWIND_CURSOR_SIZE 179
+ # define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64
+-# elif defined(__ppc__)
++# elif defined(__powerpc__)
+ # define _LIBUNWIND_TARGET_PPC 1
+ # define _LIBUNWIND_CONTEXT_SIZE 117
+ # define _LIBUNWIND_CURSOR_SIZE 124
+--- a/libunwind/src/UnwindRegistersRestore.S
++++ b/libunwind/src/UnwindRegistersRestore.S
+@@ -389,7 +389,7 @@ Lnovec:
+ PPC64_LR(3)
+ bctr
+
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+
+ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
+ //
+--- a/libunwind/src/UnwindRegistersSave.S
++++ b/libunwind/src/UnwindRegistersSave.S
+@@ -556,7 +556,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
+ blr
+
+
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+
+ //
+ // extern int unw_getcontext(unw_context_t* thread_state)
+--- a/libunwind/src/config.h
++++ b/libunwind/src/config.h
+@@ -105,12 +105,12 @@
+ #define _LIBUNWIND_BUILD_SJLJ_APIS
+ #endif
+
+-#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__)
++#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__powerpc64__)
+ #define _LIBUNWIND_SUPPORT_FRAME_APIS
+ #endif
+
+ #if defined(__i386__) || defined(__x86_64__) || \
+- defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) || \
++ defined(__powerpc__) || defined(__powerpc64__) || \
+ (!defined(__APPLE__) && defined(__arm__)) || \
+ defined(__aarch64__) || \
+ defined(__mips__) || \
+--- a/libunwind/src/libunwind.cpp
++++ b/libunwind/src/libunwind.cpp
+@@ -51,7 +51,7 @@ _LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor,
+ # define REGISTER_KIND Registers_x86_64
+ #elif defined(__powerpc64__)
+ # define REGISTER_KIND Registers_ppc64
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+ # define REGISTER_KIND Registers_ppc
+ #elif defined(__aarch64__)
+ # define REGISTER_KIND Registers_arm64
diff --git a/srcpkgs/llvm13/patches/lldb-musl.patch b/srcpkgs/llvm13/patches/lldb-musl.patch
new file mode 100644
index 000000000000..601c0d138523
--- /dev/null
+++ b/srcpkgs/llvm13/patches/lldb-musl.patch
@@ -0,0 +1,31 @@
+--- a/lldb/source/Plugins/Process/Linux/Procfs.h
++++ b/lldb/source/Plugins/Process/Linux/Procfs.h
+@@ -10,21 +10,12 @@
+ // sys/procfs.h on Android/Linux for all supported architectures.
+
+ #include <sys/ptrace.h>
++#include <asm/ptrace.h>
+
+-#ifdef __ANDROID__
+-#if defined(__arm64__) || defined(__aarch64__)
+-typedef unsigned long elf_greg_t;
+-typedef elf_greg_t
+- elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))];
+-typedef struct user_fpsimd_state elf_fpregset_t;
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#elif defined(__mips__)
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#endif
+-#else // __ANDROID__
++#if !defined(__GLIBC__) && defined(__powerpc__)
++#define pt_regs musl_pt_regs
++#include <sys/procfs.h>
++#undef pt_regs
++#else
+ #include <sys/procfs.h>
+-#endif // __ANDROID__
++#endif
diff --git a/srcpkgs/llvm13/patches/llvm-001-musl.patch b/srcpkgs/llvm13/patches/llvm-001-musl.patch
new file mode 100644
index 000000000000..2580a1a518ca
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-001-musl.patch
@@ -0,0 +1,57 @@
+From faca3fbd15d0c3108493c3c54cd93138e049ac43 Mon Sep 17 00:00:00 2001
+From: Andrea Brancaleoni <miwaxe@gmail.com>
+Date: Tue, 8 Sep 2015 22:03:02 +0200
+Subject: [PATCH 3/3] musl
+
+---
+ include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
+ lib/Support/DynamicLibrary.cpp | 2 +-
+ lib/Support/Unix/Signals.inc | 6 +++---
+ utils/unittest/googletest/src/gtest.cc | 1 +
+ 5 files changed, 17 insertions(+), 6 deletions(-)
+
+diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
+index 34a8a1e3..1214ece5 100644
+--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
++++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+@@ -18,6 +18,15 @@
+ #include "llvm/IR/PassManager.h"
+ #include "llvm/Pass.h"
+
++#undef fopen64
++#undef fseeko64
++#undef fstat64
++#undef fstatvfs64
++#undef ftello64
++#undef lstat64
++#undef stat64
++#undef tmpfile64
++
+ namespace llvm {
+ template <typename T> class ArrayRef;
+ class Triple;
+diff --git a/lib/Support/Unix/DynamicLibrary.inc b/lib/Support/Unix/DynamicLibrary.inc
+index a2a37996..2f86c470 100644
+--- a/llvm/lib/Support/Unix/DynamicLibrary.inc
++++ b/llvm/lib/Support/Unix/DynamicLibrary.inc
+@@ -102,7 +102,7 @@ static void *DoSearch(const char* SymbolName) {
+
+ // This macro returns the address of a well-known, explicit symbol
+ #define EXPLICIT_SYMBOL(SYM) \
+- if (!strcmp(SymbolName, #SYM)) return &SYM
++ if (!strcmp(SymbolName, #SYM)) return (void *)&SYM
+
+ // Under glibc we have a weird situation. The stderr/out/in symbols are both
+ // macros and global variables because of standards requirements. So, we
+diff --git a/utils/unittest/googletest/src/gtest.cc b/utils/unittest/googletest/src/gtest.cc
+index d882ab2e..f1fb12d0 100644
+--- a/llvm/utils/unittest/googletest/src/gtest.cc
++++ b/llvm/utils/unittest/googletest/src/gtest.cc
+@@ -114,6 +114,7 @@
+
+ #if GTEST_CAN_STREAM_RESULTS_
+ # include <arpa/inet.h> // NOLINT
++# include <sys/socket.h> // NOLINT
+ # include <netdb.h> // NOLINT
+ # include <sys/socket.h> // NOLINT
+ # include <sys/types.h> // NOLINT
diff --git a/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch b/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
new file mode 100644
index 000000000000..68bd57ecbade
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
@@ -0,0 +1,30 @@
+This patches LLVM to use ELFv2 on ppc64 unconditionally unless overridden. We
+need this because unlike most distros we use ELFv2 for both glibc and musl
+on big endian ppc64.
+
+diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
+index 0634833e..b7cbc2e7 100644
+--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
++++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+@@ -226,9 +226,8 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
+
+ switch (TT.getArch()) {
+ case Triple::ppc64le:
+- return PPCTargetMachine::PPC_ABI_ELFv2;
+ case Triple::ppc64:
+- return PPCTargetMachine::PPC_ABI_ELFv1;
++ return PPCTargetMachine::PPC_ABI_ELFv2;
+ default:
+ return PPCTargetMachine::PPC_ABI_UNKNOWN;
+ }
+diff --git a/test/CodeGen/PowerPC/ppc64-elf-abi.ll b/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+index 8b1cf6b5..296a2afa 100644
+--- a/llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
++++ b/llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+@@ -1,4 +1,5 @@
+-; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv1
++; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2
++; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-musl < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2
diff --git a/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch b/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
new file mode 100644
index 000000000000..32bd57a25b1d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
@@ -0,0 +1,11 @@
+--- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
++++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+@@ -169,7 +169,7 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
+
+ if ((TargetTriple.isOSFreeBSD() && TargetTriple.getOSMajorVersion() >= 13) ||
+ TargetTriple.isOSNetBSD() || TargetTriple.isOSOpenBSD() ||
+- TargetTriple.isMusl())
++ isTargetLinux())
+ SecurePlt = true;
+
+ if (HasSPE && IsPPC64)
diff --git a/srcpkgs/llvm13/patches/llvm-004-override-opt.patch b/srcpkgs/llvm13/patches/llvm-004-override-opt.patch
new file mode 100644
index 000000000000..8226f0704053
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-004-override-opt.patch
@@ -0,0 +1,18 @@
+This allows us to override the optimization level as not all platforms can
+deal with -O3.
+
+--- a/llvm/CMakeLists.txt
++++ b/llvm/CMakeLists.txt
+@@ -960,6 +960,12 @@ if( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
+ llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
+ endif()
+
++set(VOID_CXX_OPT_FLAGS "" CACHE STRING "Optimization level to use")
++
++if (NOT VOID_CXX_OPT_FLAGS STREQUAL "")
++ llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "${VOID_CXX_OPT_FLAGS}")
++endif()
++
+ # Put this before tblgen. Else we have a circular dependence.
+ add_subdirectory(lib/Demangle)
+ add_subdirectory(lib/Support)
diff --git a/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch b/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
new file mode 100644
index 000000000000..cb4eee59c340
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
@@ -0,0 +1,36 @@
+From f3dbdd49c06bfafc1d6138094cf42889c14d38b6 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 3 Nov 2019 10:57:27 -0600
+Subject: [PATCH] [LLVM][PowerPC] Assume BigPIC if no PIC level is specified
+
+---
+ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 2 +-
+ llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
+index cce21f32..87ca5f9b 100644
+--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
++++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+@@ -599,7 +599,7 @@ void PPCAsmPrinter::EmitTlsCall(const MachineInstr *MI,
+
+ // Add 32768 offset to the symbol so we follow up the latest GOT/PLT ABI.
+ if (Kind == MCSymbolRefExpr::VK_PLT && Subtarget->isSecurePlt() &&
+- M->getPICLevel() == PICLevel::BigPIC)
++ M->getPICLevel() != PICLevel::SmallPIC)
+ TlsRef = MCBinaryExpr::createAdd(
+ TlsRef, MCConstantExpr::create(32768, OutContext), OutContext);
+ const MachineOperand &MO = MI->getOperand(2);
+diff --git a/lib/Target/PowerPC/PPCMCInstLower.cpp b/lib/Target/PowerPC/PPCMCInstLower.cpp
+index 5cc180d7..a5b02565 100644
+--- a/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
++++ b/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
+@@ -117,7 +117,7 @@ static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol,
+ const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, RefKind, Ctx);
+ // If -msecure-plt -fPIC, add 32768 to symbol.
+ if (Subtarget->isSecurePlt() && TM.isPositionIndependent() &&
+- M->getPICLevel() == PICLevel::BigPIC &&
++ M->getPICLevel() != PICLevel::SmallPIC &&
+ MO.getTargetFlags() == PPCII::MO_PLT)
+ Expr =
+ MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(32768, Ctx), Ctx);
diff --git a/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch b/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
new file mode 100644
index 000000000000..6cca600d6603
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
@@ -0,0 +1,25 @@
+Fix failures in AllocationTests/MappedMemoryTest.* on aarch64:
+
+ Failing Tests (8):
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3
+
+Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10
+
+--- a/llvm/lib/Support/Unix/Memory.inc
++++ b/llvm/lib/Support/Unix/Memory.inc
+@@ -50,7 +50,7 @@ static int getPosixProtectionFlags(unsigned Flags) {
+ return PROT_READ | PROT_WRITE | PROT_EXEC;
+ case llvm::sys::Memory::MF_EXEC:
+ #if (defined(__FreeBSD__) || defined(__POWERPC__) || defined (__ppc__) || \
+- defined(_POWER) || defined(_ARCH_PPC))
++ defined(_POWER) || defined(_ARCH_PPC) || (defined(__linux__) && defined(__aarch64__)))
+ // On PowerPC, having an executable page that has no read permission
+ // can have unintended consequences. The function InvalidateInstruction-
+ // Cache uses instructions dcbf and icbi, both of which are treated by
diff --git a/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch b/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
new file mode 100644
index 000000000000..f92efb6aade1
--- /dev/null
+++ b/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
@@ -0,0 +1,21 @@
+commit ba4ede595ff9599232f5dd2b4384c243137b53fc
+Author: Daniel Kolesa <daniel@octaforge.org>
+Date: Tue Jun 22 23:40:54 2021 +0200
+
+ enable compiler-rt support for ppc32
+
+diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake
+index 1edab43..5c0c8a2 100644
+--- a/compiler-rt/cmake/base-config-ix.cmake
++++ b/compiler-rt/cmake/base-config-ix.cmake
+@@ -207,9 +207,7 @@ macro(test_targets)
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc64le|ppc64le")
+ test_target_arch(powerpc64le "" "-m64")
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
+- if(CMAKE_SYSTEM_NAME MATCHES "AIX")
+- test_target_arch(powerpc "" "-m32")
+- endif()
++ test_target_arch(powerpc "" "-m32")
+ test_target_arch(powerpc64 "" "-m64")
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "s390x")
+ test_target_arch(s390x "" "")
diff --git a/srcpkgs/llvm13/template b/srcpkgs/llvm13/template
new file mode 100644
index 000000000000..243ed4072bd1
--- /dev/null
+++ b/srcpkgs/llvm13/template
@@ -0,0 +1,427 @@
+# Template file for 'llvm13'
+pkgname=llvm13
+version=13.0.1
+revision=1
+wrksrc="llvm-project-${version}.src"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLDB_USE_SYSTEM_SIX=YES
+ -DLIBCXX_CXX_ABI=libcxxabi
+ -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=YES
+ -DLIBCXXABI_USE_LLVM_UNWINDER=YES
+ -DLIBCXXABI_ENABLE_STATIC_UNWINDER=YES
+ -DLIBOMP_ENABLE_SHARED=YES
+ -DLIBOMP_INSTALL_ALIASES=NO
+ -DLLVM_INCLUDE_DOCS=YES
+ -DLLVM_BUILD_DOCS=YES
+ -DLLVM_ENABLE_SPHINX=YES
+ -DSPHINX_WARNINGS_AS_ERRORS=NO
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BUILD_LLVM_DYLIB=YES
+ -DLLVM_LINK_LLVM_DYLIB=YES
+ -DLLVM_ENABLE_RTTI=YES
+ -DLLVM_ENABLE_FFI=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include"
+hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
+ python3-recommonmark python3-sphinx-automodapi"
+makedepends="python3-devel zlib-devel elfutils-devel libffi-devel libedit-devel
+ libxml2-devel binutils-devel libatomic-devel"
+depends="libllvm13>=${version}_${revision}"
+short_desc="Low Level Virtual Machine"
+maintainer="q66 <daniel@octaforge.org>"
+license="Apache-2.0"
+homepage="https://www.llvm.org"
+distfiles="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz"
+checksum=326335a830f2e32d06d0a36393b5455d17dc73e0bd1211065227ee014f92cbf8
+lib32disabled=yes
+python_version=3
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+ configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES"
+ makedepends+=" libexecinfo-devel"
+ depends+=" libexecinfo-devel"
+fi
+
+# "operand out of range" assembler failures
+case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ ppc*) configure_args+=" -DCLANG_ENABLE_CLANGD=OFF" ;;
+esac
+
+_enabled_projects="clang;clang-tools-extra;compiler-rt;libcxx;libcxxabi;libunwind;lld"
+
+_lldb_enable=yes
+_libomp_enable=no
+
+case "$XBPS_TARGET_MACHINE" in
+ ppc64le*) ;;
+ ppc*|i686*) _lldb_enable=no ;;
+esac
+
+case "$XBPS_TARGET_MACHINE" in
+ x86_64*|aarch64*|ppc64*) _libomp_enable=yes;;
+esac
+
+subpackages="clang-tools-extra"
+
+# must go before clang
+if [ "$_libomp_enable" = "yes" ]; then
+ _enabled_projects+=";openmp"
+ subpackages+=" libomp libomp-devel"
+ # because of cmake nonsense referencing libomptarget.so.*
+ depends+=" libomp>=${version}_${revision}"
+fi
+
+subpackages+=" clang clang-analyzer libclang libclang-cpp
+ llvm-libunwind llvm-libunwind-devel libcxx libcxx-devel
+ libcxxabi libcxxabi-devel libllvm13"
+
+if [ "$_lldb_enable" = "yes" ]; then
+ # XXX fails to cross compile due to python
+ _enabled_projects+=";lldb"
+ subpackages+=" lldb lldb-devel"
+fi
+
+subpackages+=" lld lld-devel"
+
+configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
+
+post_patch() {
+ if [ "$_lldb_enable" = "yes" ]; then
+ if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+ vsed -i 's|__ptrace_request|int|g' \
+ ${wrksrc}/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+ fi
+ # disable docs for lldb as they fail to generate
+ vsed -i '/add_subdirectory(docs)/d' \
+ ${wrksrc}/lldb/CMakeLists.txt
+ fi
+
+ # update config.guess for better platform detection
+ cp $XBPS_COMMONDIR/environment/configure/automake/config.guess \
+ ${wrksrc}/llvm/cmake
+
+ # fix linker failures on some archs
+ vsed -i 's,check_library_exists(gcc_s .*,set(LIBCXXABI_HAS_GCC_S_LIB ON),' \
+ ${wrksrc}/libcxxabi/cmake/config-ix.cmake
+ vsed -i 's,check_library_exists(gcc .*,set(LIBCXXABI_HAS_GCC_LIB ON),' \
+ ${wrksrc}/libcxxabi/cmake/config-ix.cmake
+
+ # need libssp_nonshared on some musl platforms (because of nodefaultlibs)
+ case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ ppc*-musl|i686-musl|mips*-musl)
+ vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+ ${wrksrc}/libunwind/src/CMakeLists.txt
+ vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+ ${wrksrc}/libcxxabi/src/CMakeLists.txt
+ vsed -i 's,#ssp,,' ${wrksrc}/libcxx/CMakeLists.txt
+ ;;
+ esac
+
+ case "$XBPS_TARGET_MACHINE" in
+ x86_64-musl) # some sanitizer currently only on x86_64 stuff needs backtrace
+ vsed -i 's,# Set common link flags.,list(APPEND SANITIZER_COMMON_LINK_LIBS execinfo),' \
+ ${wrksrc}/compiler-rt/CMakeLists.txt
+ ;;
+ arm*-musl|i686-musl) # sanitizer code is broken since it duplicates some libc bits
+ vsed -i 's/set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)/set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE)/' \
+ ${wrksrc}/compiler-rt/cmake/config-ix.cmake
+ ;;
+ esac
+}
+
+pre_configure() {
+ local triplet
+
+ # Vastly reduce size of debugging symbols:
+ CFLAGS=${CFLAGS/ -g/ -g1}
+ CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+
+ # since gcc9, the build likes to blow up for ppc32 apparently because
+ # of clang being too large for a 24-bit relative call to the PLT, so
+ # optimize for size instead
+ case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ mips*-musl|ppc*) configure_args+=" -DVOID_CXX_OPT_FLAGS=-Os" ;;
+ esac
+
+ if [ "$CROSS_BUILD" ]; then
+ msg_normal "Building host tblgen\n"
+ mkdir -p build/HOST
+ cd build/HOST
+ CC="$BUILD_CC" CXX="$BUILD_CXX" CFLAGS="$BUILD_CFLAGS" \
+ CXXFLAGS="$BUILD_CXXFLAGS" LDFLAGS="$BUILD_LDFLAGS" \
+ cmake ../.. -DCMAKE_BUILD_TYPE=Release \
+ -DLLVM_ENABLE_PROJECTS=${_enabled_projects}
+ make ${makejobs} -C utils/TableGen
+ make ${makejobs} -C tools/clang/utils/TableGen
+ [ "$_lldb_enable" = "yes" ] && make ${makejobs} -C tools/lldb/utils/TableGen
+ configure_args+=" -DLLVM_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/llvm-tblgen"
+ configure_args+=" -DCLANG_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/clang-tblgen"
+ [ "$_lldb_enable" = "yes" ] && configure_args+=" -DLLDB_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/lldb-tblgen"
+ cd ../..
+ fi
+
+ case "$XBPS_TARGET_MACHINE" in
+ i686*) _arch="X86";;
+ x86_64*) _arch="X86";;
+ armv5*) _arch="Armv5te";;
+ armv6*) _arch="Armv6";;
+ armv7*) _arch="Armv7";;
+ aarch64*) _arch="AArch64";;
+ mips*) _arch="Mips";;
+ ppc*) _arch="PowerPC";;
+ riscv64*) _arch="RISCV64";;
+ esac
+
+ triplet=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}
+
+ configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+ configure_args+=" -DLLVM_HOST_TRIPLE=${triplet}"
+ configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${triplet}"
+}
+
+do_install() {
+ cd build
+ cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr -P cmake_install.cmake
+
+ # Required for multilib.
+ if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
+ for _header in llvm-config; do
+ mv ${DESTDIR}/usr/include/llvm/Config/${_header}{,-64}.h
+ vinstall ${FILESDIR}/llvm-Config-${_header}.h 644 \
+ usr/include/llvm/Config ${_header}.h
+ done
+ fi
+
+ # Remove llvm-config-host in cross builds.
+ if [ "$CROSS_BUILD" ]; then
+ rm -f ${DESTDIR}/usr/bin/llvm-config-host
+ fi
+
+ # Fix libomptarget.so name
+ mv usr/lib/libomptarget.so usr/lib/libomptarget.so.13
+
+ # Install libcxxabi headers
+ vinstall ${wrksrc}/libcxxabi/include/__cxxabi_config.h 644 usr/include
+ vinstall ${wrksrc}/libcxxabi/include/cxxabi.h 644 usr/include
+
+ # Install libunwind headers
+ vinstall ${wrksrc}/libunwind/include/__libunwind_config.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/libunwind.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/unwind.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/mach-o/compact_unwind_encoding.h \
+ 644 usr/include/mach-o
+}
+
+clang-analyzer_package() {
+ pycompile_dirs="usr/share/scan-view"
+ depends="clang-${version}_${revision} python3 perl"
+ short_desc+=" - A source code analysis framework"
+ homepage="https://clang-analyzer.llvm.org/"
+ pkg_install() {
+ vmove usr/share/man/man1/scan-build.1
+ vmove "/usr/bin/scan-*"
+ vmove "/usr/share/scan-*"
+ vmove "/usr/libexec/*analyzer"
+ }
+}
+
+clang-tools-extra_package() {
+ lib32disabled=yes
+ depends="clang-${version}_${revision} python3"
+ short_desc+=" - Extra Clang tools"
+ homepage="https://clang.llvm.org/extra/"
+ pkg_install() {
+ vmove usr/include/clang-tidy
+ vmove usr/bin/clang-apply-replacements
+ vmove usr/bin/clang-query
+ vmove usr/bin/clang-rename
+ vmove usr/bin/clang-tidy
+ vmove usr/bin/diagtool
+ vmove usr/bin/find-all-symbols
+ vmove usr/bin/hmaptool
+ vmove usr/bin/modularize
+ vmove usr/bin/pp-trace
+ vmove usr/bin/sancov
+ vmove "usr/lib/libclangApplyReplacements*"
+ vmove "usr/lib/libclangQuery*"
+ vmove "usr/lib/libclangTidy*"
+ vmove "usr/share/clang/*tidy*"
+ vmove usr/share/doc/clang-tools
+ vmove usr/share/man/man1/extraclangtools.1
+ vmove usr/share/man/man1/diagtool.1
+ }
+}
+
+clang_package() {
+ lib32disabled=yes
+ depends="libstdc++-devel libgcc-devel binutils ${XBPS_TARGET_LIBC}-devel
+ libclang-${version}_${revision}"
+ short_desc+=" - C language family frontend"
+ homepage="https://clang.llvm.org/"
+ pkg_install() {
+ vmove usr/include/clang
+ vmove usr/include/clang-c
+ vmove "usr/bin/*clang*"
+ vmove usr/bin/c-index-test
+ vmove usr/lib/clang
+ vmove usr/lib/cmake/clang
+ vmove "usr/lib/libclang*.a"
+ vmove "usr/lib/libclang*.so"
+ vmove usr/share/clang
+ vmove usr/share/doc/clang
+ vmove usr/share/man/man1/clang.1
+ }
+}
+
+libclang_package() {
+ short_desc+=" - C frontend runtime library"
+ pkg_install() {
+ vmove "usr/lib/libclang.so.*"
+ }
+}
+
+libclang-cpp_package() {
+ short_desc+=" - C frontend runtime library (C++ interface)"
+ pkg_install() {
+ vmove "usr/lib/libclang-cpp.so.*"
+ }
+}
+
+lld_package() {
+ lib32disabled=yes
+ short_desc+=" - linker"
+ homepage="https://lld.llvm.org"
+ pkg_install() {
+ vmove usr/bin/lld*
+ vmove usr/bin/wasm-ld
+ vmove usr/bin/ld.lld*
+ vmove usr/bin/ld64.lld*
+ vmove usr/share/doc/lld
+ }
+}
+
+lld-devel_package() {
+ lib32disabled=yes
+ short_desc+=" - linker - development files"
+ homepage="https://lld.llvm.org"
+ depends="lld>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/include/lld
+ vmove usr/lib/cmake/lld
+ vmove "usr/lib/liblld*a"
+ }
+}
+
+lldb_package() {
+ lib32disabled=yes
+ depends+=" python3-six"
+ short_desc+=" - LLDB debugger"
+ homepage="https://lldb.llvm.org/"
+ pkg_install() {
+ vmove usr/bin/*lldb*
+ vmove usr/lib/liblldb*so.*
+ vmove /usr/lib/python*
+ }
+}
+
+lldb-devel_package() {
+ lib32disabled=yes
+ depends="lldb>=${version}_${revision}"
+ short_desc+=" - LLDB debugger - development files"
+ pkg_install() {
+ vmove usr/include/lldb
+ vmove "usr/lib/liblldb*.so"
+ }
+}
+
+llvm-libunwind_package() {
+ short_desc+=" - libunwind"
+ pkg_install() {
+ vmove "usr/lib/libunwind.so.*"
+ }
+}
+
+llvm-libunwind-devel_package() {
+ short_desc+=" - libunwind - development files"
+ depends="llvm-libunwind>=${version}_${revision}"
+ conflicts="libunwind-devel>=0"
+ pkg_install() {
+ vmove usr/lib/libunwind.so
+ vmove usr/lib/libunwind.a
+ vmove "usr/include/*unwind*"
+ vmove usr/include/mach-o
+ vmove usr/share/doc/libunwind
+ }
+}
+
+libcxxabi_package() {
+ short_desc+=" - low level support for libc++"
+ pkg_install() {
+ vmove "usr/lib/libc++abi.so.*"
+ }
+}
+
+libcxxabi-devel_package() {
+ short_desc+=" - low level support for libc++ - development files"
+ depends="libcxxabi>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/lib/libc++abi.so
+ vmove usr/lib/libc++abi.a
+ vmove "usr/include/*cxxabi*"
+ }
+}
+
+libcxx_package() {
+ short_desc+=" - C++ standard library"
+ pkg_install() {
+ vmove "usr/lib/libc++.so.*"
+ }
+}
+
+libcxx-devel_package() {
+ short_desc+=" - C++ standard library - development files"
+ depends="libcxx>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/lib/libc++.so
+ vmove usr/lib/libc++.a
+ vmove usr/lib/libc++experimental.a
+ vmove usr/include/c++
+ vmove usr/share/doc/libcxx
+ }
+}
+
+libomp_package() {
+ short_desc+=" - Clang OpenMP support library"
+ pkg_install() {
+ vmove usr/lib/libomp.so
+ vmove "usr/lib/libomptarget.rtl.*.so"
+ vmove usr/lib/libarcher.so
+ vmove "usr/lib/libomp*.so.*"
+ }
+}
+
+libomp-devel_package() {
+ short_desc+=" - Clang OpenMP support library - development files"
+ depends="libomp>=${version}_${revision}"
+ pkg_install() {
+ vmove "usr/lib/libomp*.so"
+ vmove "usr/lib/libarcher*"
+ vmove "usr/include/omp*.h"
+ vmove "usr/lib/clang/${version}/include/omp*.h"
+ vmove usr/share/man/man1/llvmopenmp.1
+ vmove usr/share/doc/openmp
+ }
+}
+
+libllvm13_package() {
+ short_desc+=" - runtime library"
+ pkg_install() {
+ vmove "usr/lib/libLLVM-*.so*"
+ }
+}
diff --git a/srcpkgs/llvm13/update b/srcpkgs/llvm13/update
new file mode 100644
index 000000000000..e95cf26b3586
--- /dev/null
+++ b/srcpkgs/llvm13/update
@@ -0,0 +1,3 @@
+site="https://github.com/llvm/llvm-project/releases"
+pattern="llvmorg-\K(\d+.){2}\d+(-rc\d+)?"
+ignore="*-rc*"
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR PATCH] [Updated] new package: llvm13-13.0.1
2022-03-22 14:15 [PR PATCH] new package: llvm13-13.0.1 subnut
2022-03-22 14:28 ` [PR PATCH] [Updated] " subnut
@ 2022-03-22 14:31 ` subnut
2022-03-22 14:40 ` subnut
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: subnut @ 2022-03-22 14:31 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]
There is an updated pull request by subnut against master on the void-packages repository
https://github.com/subnut/void-packages llvm13
https://github.com/void-linux/void-packages/pull/36280
new package: llvm13-13.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**
<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-glibc)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/36280.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-llvm13-36280.patch --]
[-- Type: text/x-diff, Size: 41543 bytes --]
From f8597871e86b80e00c8d10661d226688da1b6e64 Mon Sep 17 00:00:00 2001
From: Subhaditya Nath <sn03.general@gmail.com>
Date: Tue, 22 Mar 2022 18:29:24 +0530
Subject: [PATCH] new package: llvm13-13.0.1
---
srcpkgs/clang | 2 +-
srcpkgs/clang-analyzer | 2 +-
| 2 +-
srcpkgs/libclang | 2 +-
srcpkgs/libclang-cpp | 2 +-
srcpkgs/libcxx | 2 +-
srcpkgs/libcxx-devel | 2 +-
srcpkgs/libcxxabi | 2 +-
srcpkgs/libcxxabi-devel | 2 +-
srcpkgs/libllvm13 | 1 +
srcpkgs/libomp | 2 +-
srcpkgs/libomp-devel | 2 +-
srcpkgs/lld | 2 +-
srcpkgs/lld-devel | 2 +-
srcpkgs/lldb | 2 +-
srcpkgs/lldb-devel | 2 +-
srcpkgs/llvm-libunwind | 2 +-
srcpkgs/llvm-libunwind-devel | 2 +-
.../llvm13/files/llvm-Config-llvm-config.h | 9 +
.../patches/compiler-rt-xray-ppc64-musl.patch | 62 +++
srcpkgs/llvm13/patches/libcxx-musl.patch | 26 ++
srcpkgs/llvm13/patches/libcxx-ppc.patch | 22 +
.../llvm13/patches/libcxx-ssp-nonshared.patch | 11 +
srcpkgs/llvm13/patches/libcxxabi-dl.patch | 25 +
srcpkgs/llvm13/patches/libunwind-ppc32.patch | 63 +++
srcpkgs/llvm13/patches/lldb-musl.patch | 31 ++
srcpkgs/llvm13/patches/llvm-001-musl.patch | 57 +++
.../patches/llvm-002-musl-ppc64-elfv2.patch | 30 ++
.../patches/llvm-003-ppc-secureplt.patch | 11 +
.../patches/llvm-004-override-opt.patch | 18 +
.../llvm13/patches/llvm-005-ppc-bigpic.patch | 36 ++
.../patches/llvm-006-aarch64-mf_exec.patch | 25 +
.../llvm13/patches/ppc32-compiler-rt.patch | 21 +
srcpkgs/llvm13/template | 426 ++++++++++++++++++
srcpkgs/llvm13/update | 3 +
35 files changed, 894 insertions(+), 17 deletions(-)
create mode 120000 srcpkgs/libllvm13
create mode 100644 srcpkgs/llvm13/files/llvm-Config-llvm-config.h
create mode 100644 srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-musl.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-ppc.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
create mode 100644 srcpkgs/llvm13/patches/libcxxabi-dl.patch
create mode 100644 srcpkgs/llvm13/patches/libunwind-ppc32.patch
create mode 100644 srcpkgs/llvm13/patches/lldb-musl.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-001-musl.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-004-override-opt.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
create mode 100644 srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
create mode 100644 srcpkgs/llvm13/template
create mode 100644 srcpkgs/llvm13/update
diff --git a/srcpkgs/clang b/srcpkgs/clang
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang
+++ b/srcpkgs/clang
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/clang-analyzer b/srcpkgs/clang-analyzer
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang-analyzer
+++ b/srcpkgs/clang-analyzer
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
--git a/srcpkgs/clang-tools-extra b/srcpkgs/clang-tools-extra
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang-tools-extra
+++ b/srcpkgs/clang-tools-extra
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libclang b/srcpkgs/libclang
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libclang
+++ b/srcpkgs/libclang
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libclang-cpp b/srcpkgs/libclang-cpp
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libclang-cpp
+++ b/srcpkgs/libclang-cpp
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxx b/srcpkgs/libcxx
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxx
+++ b/srcpkgs/libcxx
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxx-devel b/srcpkgs/libcxx-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxx-devel
+++ b/srcpkgs/libcxx-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxxabi b/srcpkgs/libcxxabi
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxxabi
+++ b/srcpkgs/libcxxabi
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxxabi-devel b/srcpkgs/libcxxabi-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxxabi-devel
+++ b/srcpkgs/libcxxabi-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libllvm13 b/srcpkgs/libllvm13
new file mode 120000
index 000000000000..d6366d7d3b95
--- /dev/null
+++ b/srcpkgs/libllvm13
@@ -0,0 +1 @@
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libomp b/srcpkgs/libomp
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libomp
+++ b/srcpkgs/libomp
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libomp-devel b/srcpkgs/libomp-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libomp-devel
+++ b/srcpkgs/libomp-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lld b/srcpkgs/lld
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lld
+++ b/srcpkgs/lld
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lld-devel b/srcpkgs/lld-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lld-devel
+++ b/srcpkgs/lld-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lldb b/srcpkgs/lldb
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lldb
+++ b/srcpkgs/lldb
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lldb-devel b/srcpkgs/lldb-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lldb-devel
+++ b/srcpkgs/lldb-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind b/srcpkgs/llvm-libunwind
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/llvm-libunwind
+++ b/srcpkgs/llvm-libunwind
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind-devel b/srcpkgs/llvm-libunwind-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/llvm-libunwind-devel
+++ b/srcpkgs/llvm-libunwind-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm13/files/llvm-Config-llvm-config.h b/srcpkgs/llvm13/files/llvm-Config-llvm-config.h
new file mode 100644
index 000000000000..2fa08c9be696
--- /dev/null
+++ b/srcpkgs/llvm13/files/llvm-Config-llvm-config.h
@@ -0,0 +1,9 @@
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 32
+#include "llvm-config-32.h"
+#elif __WORDSIZE == 64
+#include "llvm-config-64.h"
+#else
+#error "Unknown word size"
+#endif
diff --git a/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch b/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
new file mode 100644
index 000000000000..d0b61c80c897
--- /dev/null
+++ b/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
@@ -0,0 +1,62 @@
+--- a/compiler-rt/lib/xray/xray_powerpc64.inc
++++ b/compiler-rt/lib/xray/xray_powerpc64.inc
+@@ -12,7 +12,13 @@
+
+ #include <cstdint>
+ #include <mutex>
++#ifdef __GLIBC__
+ #include <sys/platform/ppc.h>
++#else
++#include <cctype>
++#include <cstring>
++#include <cstdlib>
++#endif
+
+ #include "xray_defs.h"
+
+@@ -20,13 +26,45 @@ namespace __xray {
+
+ ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT {
+ CPU = 0;
++#ifdef __GLIBC__
+ return __ppc_get_timebase();
++#else
++ return __builtin_ppc_get_timebase();
++#endif
+ }
+
+ inline uint64_t getTSCFrequency() XRAY_NEVER_INSTRUMENT {
+ static std::mutex M;
+ std::lock_guard<std::mutex> Guard(M);
++#ifdef __GLIBC__
+ return __ppc_get_timebase_freq();
++#else
++ /* FIXME: a less dirty implementation? */
++ static uint64_t base;
++ if (!base) {
++ FILE *f = fopen("/proc/cpuinfo", "rb");
++ if (f) {
++ ssize_t nr;
++ /* virtually always big enough to hold the line */
++ char buf[512];
++ while (fgets(buf, sizeof(buf), f)) {
++ char *ret = strstr(buf, "timebase");
++ if (!ret) {
++ continue;
++ }
++ ret += sizeof("timebase") - 1;
++ ret = strchr(ret, ':');
++ if (!ret) {
++ continue;
++ }
++ base = strtoul(ret + 1, nullptr, 10);
++ break;
++ }
++ fclose(f);
++ }
++ }
++ return base;
++#endif
+ }
+
+ inline bool probeRequiredCPUFeatures() XRAY_NEVER_INSTRUMENT {
diff --git a/srcpkgs/llvm13/patches/libcxx-musl.patch b/srcpkgs/llvm13/patches/libcxx-musl.patch
new file mode 100644
index 000000000000..ef60a16c54bb
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-musl.patch
@@ -0,0 +1,26 @@
+--- a/libcxx/include/locale
++++ b/libcxx/include/locale
+@@ -747,7 +747,11 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
++#if defined(__linux__) && !defined(__GLIBC__)
++ long long __ll = strtoll(__a, &__p2, __base);
++#else
+ long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++#endif
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
+@@ -787,7 +791,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
++#if defined(__linux__) && !defined(__GLIBC__)
++ unsigned long long __ll = strtoull(__a, &__p2, __base);
++#else
+ unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++#endif
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
diff --git a/srcpkgs/llvm13/patches/libcxx-ppc.patch b/srcpkgs/llvm13/patches/libcxx-ppc.patch
new file mode 100644
index 000000000000..7a92f8004e1c
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-ppc.patch
@@ -0,0 +1,22 @@
+This ensures `is_iec559` is defined correctly under all long double ABIs,
+including musl and its 64-bit long double. Also, `__ppc__` or `__ppc64__`
+is not defined on gcc.
+
+--- a/libcxx/include/limits
++++ b/libcxx/include/limits
+@@ -426,8 +426,14 @@ protected:
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
+
+-#if (defined(__ppc__) || defined(__ppc64__))
++#if defined(__powerpc__) || defined(__powerpc64__)
++#if (__LDBL_MAX_EXP__ > __DBL_MAX_EXP__) || (__LDBL_MANT_DIG__ == __DBL_MANT_DIG__)
++ /* IEEE 754 quadruple or double precision */
++ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
++#else
++ /* 128-bit IBM double-double */
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
++#endif
+ #else
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
+ #endif
diff --git a/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch b/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
new file mode 100644
index 000000000000..55ece79f7f3a
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
@@ -0,0 +1,11 @@
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -800,6 +800,8 @@ function(cxx_link_system_libraries target)
+ target_link_libraries(${target} PRIVATE atomic)
+ endif()
+
++#ssp target_link_libraries(${target} PRIVATE ssp_nonshared)
++
+ if (MINGW)
+ target_link_libraries(${target} PRIVATE "${MINGW_LIBRARIES}")
+ endif()
diff --git a/srcpkgs/llvm13/patches/libcxxabi-dl.patch b/srcpkgs/llvm13/patches/libcxxabi-dl.patch
new file mode 100644
index 000000000000..fa84fe6fd94d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxxabi-dl.patch
@@ -0,0 +1,25 @@
+Also link to -ldl to prevent undefined references.
+
+--- a/libcxxabi/src/CMakeLists.txt.orig
++++ b/libcxxabi/src/CMakeLists.txt
+@@ -75,6 +75,7 @@ else()
+ endif()
+
+ add_library_flags_if(LIBCXXABI_HAS_C_LIB c)
++ add_library_flags_if(LIBCXXABI_HAS_C_LIB dl)
+ endif()
+
+ if (LIBCXXABI_USE_COMPILER_RT)
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -781,6 +781,10 @@
+ target_link_libraries(${target} PRIVATE m)
+ endif()
+
++ if (LIBCXX_HAS_C_LIB)
++ target_link_libraries(${target} PRIVATE dl)
++ endif()
++
+ if (LIBCXX_HAS_RT_LIB)
+ target_link_libraries(${target} PRIVATE rt)
+ endif()
diff --git a/srcpkgs/llvm13/patches/libunwind-ppc32.patch b/srcpkgs/llvm13/patches/libunwind-ppc32.patch
new file mode 100644
index 000000000000..2dd7c681637d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libunwind-ppc32.patch
@@ -0,0 +1,63 @@
+This fixes build at least with gcc9 which does not define `__ppc__`.
+
+--- a/libunwind/include/__libunwind_config.h
++++ b/libunwind/include/__libunwind_config.h
+@@ -55,7 +55,7 @@
+ # define _LIBUNWIND_CONTEXT_SIZE 167
+ # define _LIBUNWIND_CURSOR_SIZE 179
+ # define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64
+-# elif defined(__ppc__)
++# elif defined(__powerpc__)
+ # define _LIBUNWIND_TARGET_PPC 1
+ # define _LIBUNWIND_CONTEXT_SIZE 117
+ # define _LIBUNWIND_CURSOR_SIZE 124
+--- a/libunwind/src/UnwindRegistersRestore.S
++++ b/libunwind/src/UnwindRegistersRestore.S
+@@ -389,7 +389,7 @@ Lnovec:
+ PPC64_LR(3)
+ bctr
+
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+
+ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
+ //
+--- a/libunwind/src/UnwindRegistersSave.S
++++ b/libunwind/src/UnwindRegistersSave.S
+@@ -556,7 +556,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
+ blr
+
+
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+
+ //
+ // extern int unw_getcontext(unw_context_t* thread_state)
+--- a/libunwind/src/config.h
++++ b/libunwind/src/config.h
+@@ -105,12 +105,12 @@
+ #define _LIBUNWIND_BUILD_SJLJ_APIS
+ #endif
+
+-#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__)
++#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__powerpc64__)
+ #define _LIBUNWIND_SUPPORT_FRAME_APIS
+ #endif
+
+ #if defined(__i386__) || defined(__x86_64__) || \
+- defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) || \
++ defined(__powerpc__) || defined(__powerpc64__) || \
+ (!defined(__APPLE__) && defined(__arm__)) || \
+ defined(__aarch64__) || \
+ defined(__mips__) || \
+--- a/libunwind/src/libunwind.cpp
++++ b/libunwind/src/libunwind.cpp
+@@ -51,7 +51,7 @@ _LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor,
+ # define REGISTER_KIND Registers_x86_64
+ #elif defined(__powerpc64__)
+ # define REGISTER_KIND Registers_ppc64
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+ # define REGISTER_KIND Registers_ppc
+ #elif defined(__aarch64__)
+ # define REGISTER_KIND Registers_arm64
diff --git a/srcpkgs/llvm13/patches/lldb-musl.patch b/srcpkgs/llvm13/patches/lldb-musl.patch
new file mode 100644
index 000000000000..601c0d138523
--- /dev/null
+++ b/srcpkgs/llvm13/patches/lldb-musl.patch
@@ -0,0 +1,31 @@
+--- a/lldb/source/Plugins/Process/Linux/Procfs.h
++++ b/lldb/source/Plugins/Process/Linux/Procfs.h
+@@ -10,21 +10,12 @@
+ // sys/procfs.h on Android/Linux for all supported architectures.
+
+ #include <sys/ptrace.h>
++#include <asm/ptrace.h>
+
+-#ifdef __ANDROID__
+-#if defined(__arm64__) || defined(__aarch64__)
+-typedef unsigned long elf_greg_t;
+-typedef elf_greg_t
+- elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))];
+-typedef struct user_fpsimd_state elf_fpregset_t;
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#elif defined(__mips__)
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#endif
+-#else // __ANDROID__
++#if !defined(__GLIBC__) && defined(__powerpc__)
++#define pt_regs musl_pt_regs
++#include <sys/procfs.h>
++#undef pt_regs
++#else
+ #include <sys/procfs.h>
+-#endif // __ANDROID__
++#endif
diff --git a/srcpkgs/llvm13/patches/llvm-001-musl.patch b/srcpkgs/llvm13/patches/llvm-001-musl.patch
new file mode 100644
index 000000000000..2580a1a518ca
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-001-musl.patch
@@ -0,0 +1,57 @@
+From faca3fbd15d0c3108493c3c54cd93138e049ac43 Mon Sep 17 00:00:00 2001
+From: Andrea Brancaleoni <miwaxe@gmail.com>
+Date: Tue, 8 Sep 2015 22:03:02 +0200
+Subject: [PATCH 3/3] musl
+
+---
+ include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
+ lib/Support/DynamicLibrary.cpp | 2 +-
+ lib/Support/Unix/Signals.inc | 6 +++---
+ utils/unittest/googletest/src/gtest.cc | 1 +
+ 5 files changed, 17 insertions(+), 6 deletions(-)
+
+diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
+index 34a8a1e3..1214ece5 100644
+--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
++++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+@@ -18,6 +18,15 @@
+ #include "llvm/IR/PassManager.h"
+ #include "llvm/Pass.h"
+
++#undef fopen64
++#undef fseeko64
++#undef fstat64
++#undef fstatvfs64
++#undef ftello64
++#undef lstat64
++#undef stat64
++#undef tmpfile64
++
+ namespace llvm {
+ template <typename T> class ArrayRef;
+ class Triple;
+diff --git a/lib/Support/Unix/DynamicLibrary.inc b/lib/Support/Unix/DynamicLibrary.inc
+index a2a37996..2f86c470 100644
+--- a/llvm/lib/Support/Unix/DynamicLibrary.inc
++++ b/llvm/lib/Support/Unix/DynamicLibrary.inc
+@@ -102,7 +102,7 @@ static void *DoSearch(const char* SymbolName) {
+
+ // This macro returns the address of a well-known, explicit symbol
+ #define EXPLICIT_SYMBOL(SYM) \
+- if (!strcmp(SymbolName, #SYM)) return &SYM
++ if (!strcmp(SymbolName, #SYM)) return (void *)&SYM
+
+ // Under glibc we have a weird situation. The stderr/out/in symbols are both
+ // macros and global variables because of standards requirements. So, we
+diff --git a/utils/unittest/googletest/src/gtest.cc b/utils/unittest/googletest/src/gtest.cc
+index d882ab2e..f1fb12d0 100644
+--- a/llvm/utils/unittest/googletest/src/gtest.cc
++++ b/llvm/utils/unittest/googletest/src/gtest.cc
+@@ -114,6 +114,7 @@
+
+ #if GTEST_CAN_STREAM_RESULTS_
+ # include <arpa/inet.h> // NOLINT
++# include <sys/socket.h> // NOLINT
+ # include <netdb.h> // NOLINT
+ # include <sys/socket.h> // NOLINT
+ # include <sys/types.h> // NOLINT
diff --git a/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch b/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
new file mode 100644
index 000000000000..68bd57ecbade
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
@@ -0,0 +1,30 @@
+This patches LLVM to use ELFv2 on ppc64 unconditionally unless overridden. We
+need this because unlike most distros we use ELFv2 for both glibc and musl
+on big endian ppc64.
+
+diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
+index 0634833e..b7cbc2e7 100644
+--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
++++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+@@ -226,9 +226,8 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
+
+ switch (TT.getArch()) {
+ case Triple::ppc64le:
+- return PPCTargetMachine::PPC_ABI_ELFv2;
+ case Triple::ppc64:
+- return PPCTargetMachine::PPC_ABI_ELFv1;
++ return PPCTargetMachine::PPC_ABI_ELFv2;
+ default:
+ return PPCTargetMachine::PPC_ABI_UNKNOWN;
+ }
+diff --git a/test/CodeGen/PowerPC/ppc64-elf-abi.ll b/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+index 8b1cf6b5..296a2afa 100644
+--- a/llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
++++ b/llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+@@ -1,4 +1,5 @@
+-; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv1
++; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2
++; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-musl < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2
diff --git a/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch b/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
new file mode 100644
index 000000000000..32bd57a25b1d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
@@ -0,0 +1,11 @@
+--- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
++++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+@@ -169,7 +169,7 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
+
+ if ((TargetTriple.isOSFreeBSD() && TargetTriple.getOSMajorVersion() >= 13) ||
+ TargetTriple.isOSNetBSD() || TargetTriple.isOSOpenBSD() ||
+- TargetTriple.isMusl())
++ isTargetLinux())
+ SecurePlt = true;
+
+ if (HasSPE && IsPPC64)
diff --git a/srcpkgs/llvm13/patches/llvm-004-override-opt.patch b/srcpkgs/llvm13/patches/llvm-004-override-opt.patch
new file mode 100644
index 000000000000..8226f0704053
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-004-override-opt.patch
@@ -0,0 +1,18 @@
+This allows us to override the optimization level as not all platforms can
+deal with -O3.
+
+--- a/llvm/CMakeLists.txt
++++ b/llvm/CMakeLists.txt
+@@ -960,6 +960,12 @@ if( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
+ llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
+ endif()
+
++set(VOID_CXX_OPT_FLAGS "" CACHE STRING "Optimization level to use")
++
++if (NOT VOID_CXX_OPT_FLAGS STREQUAL "")
++ llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "${VOID_CXX_OPT_FLAGS}")
++endif()
++
+ # Put this before tblgen. Else we have a circular dependence.
+ add_subdirectory(lib/Demangle)
+ add_subdirectory(lib/Support)
diff --git a/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch b/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
new file mode 100644
index 000000000000..cb4eee59c340
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
@@ -0,0 +1,36 @@
+From f3dbdd49c06bfafc1d6138094cf42889c14d38b6 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 3 Nov 2019 10:57:27 -0600
+Subject: [PATCH] [LLVM][PowerPC] Assume BigPIC if no PIC level is specified
+
+---
+ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 2 +-
+ llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
+index cce21f32..87ca5f9b 100644
+--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
++++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+@@ -599,7 +599,7 @@ void PPCAsmPrinter::EmitTlsCall(const MachineInstr *MI,
+
+ // Add 32768 offset to the symbol so we follow up the latest GOT/PLT ABI.
+ if (Kind == MCSymbolRefExpr::VK_PLT && Subtarget->isSecurePlt() &&
+- M->getPICLevel() == PICLevel::BigPIC)
++ M->getPICLevel() != PICLevel::SmallPIC)
+ TlsRef = MCBinaryExpr::createAdd(
+ TlsRef, MCConstantExpr::create(32768, OutContext), OutContext);
+ const MachineOperand &MO = MI->getOperand(2);
+diff --git a/lib/Target/PowerPC/PPCMCInstLower.cpp b/lib/Target/PowerPC/PPCMCInstLower.cpp
+index 5cc180d7..a5b02565 100644
+--- a/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
++++ b/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
+@@ -117,7 +117,7 @@ static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol,
+ const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, RefKind, Ctx);
+ // If -msecure-plt -fPIC, add 32768 to symbol.
+ if (Subtarget->isSecurePlt() && TM.isPositionIndependent() &&
+- M->getPICLevel() == PICLevel::BigPIC &&
++ M->getPICLevel() != PICLevel::SmallPIC &&
+ MO.getTargetFlags() == PPCII::MO_PLT)
+ Expr =
+ MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(32768, Ctx), Ctx);
diff --git a/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch b/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
new file mode 100644
index 000000000000..6cca600d6603
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
@@ -0,0 +1,25 @@
+Fix failures in AllocationTests/MappedMemoryTest.* on aarch64:
+
+ Failing Tests (8):
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3
+
+Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10
+
+--- a/llvm/lib/Support/Unix/Memory.inc
++++ b/llvm/lib/Support/Unix/Memory.inc
+@@ -50,7 +50,7 @@ static int getPosixProtectionFlags(unsigned Flags) {
+ return PROT_READ | PROT_WRITE | PROT_EXEC;
+ case llvm::sys::Memory::MF_EXEC:
+ #if (defined(__FreeBSD__) || defined(__POWERPC__) || defined (__ppc__) || \
+- defined(_POWER) || defined(_ARCH_PPC))
++ defined(_POWER) || defined(_ARCH_PPC) || (defined(__linux__) && defined(__aarch64__)))
+ // On PowerPC, having an executable page that has no read permission
+ // can have unintended consequences. The function InvalidateInstruction-
+ // Cache uses instructions dcbf and icbi, both of which are treated by
diff --git a/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch b/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
new file mode 100644
index 000000000000..f92efb6aade1
--- /dev/null
+++ b/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
@@ -0,0 +1,21 @@
+commit ba4ede595ff9599232f5dd2b4384c243137b53fc
+Author: Daniel Kolesa <daniel@octaforge.org>
+Date: Tue Jun 22 23:40:54 2021 +0200
+
+ enable compiler-rt support for ppc32
+
+diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake
+index 1edab43..5c0c8a2 100644
+--- a/compiler-rt/cmake/base-config-ix.cmake
++++ b/compiler-rt/cmake/base-config-ix.cmake
+@@ -207,9 +207,7 @@ macro(test_targets)
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc64le|ppc64le")
+ test_target_arch(powerpc64le "" "-m64")
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
+- if(CMAKE_SYSTEM_NAME MATCHES "AIX")
+- test_target_arch(powerpc "" "-m32")
+- endif()
++ test_target_arch(powerpc "" "-m32")
+ test_target_arch(powerpc64 "" "-m64")
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "s390x")
+ test_target_arch(s390x "" "")
diff --git a/srcpkgs/llvm13/template b/srcpkgs/llvm13/template
new file mode 100644
index 000000000000..f60a54dc789e
--- /dev/null
+++ b/srcpkgs/llvm13/template
@@ -0,0 +1,426 @@
+# Template file for 'llvm13'
+pkgname=llvm13
+version=13.0.1
+revision=1
+wrksrc="llvm-project-${version}.src"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLDB_USE_SYSTEM_SIX=YES
+ -DLIBCXX_CXX_ABI=libcxxabi
+ -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=YES
+ -DLIBCXXABI_USE_LLVM_UNWINDER=YES
+ -DLIBCXXABI_ENABLE_STATIC_UNWINDER=YES
+ -DLIBOMP_ENABLE_SHARED=YES
+ -DLIBOMP_INSTALL_ALIASES=NO
+ -DLLVM_INCLUDE_DOCS=YES
+ -DLLVM_BUILD_DOCS=YES
+ -DLLVM_ENABLE_SPHINX=YES
+ -DSPHINX_WARNINGS_AS_ERRORS=NO
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BUILD_LLVM_DYLIB=YES
+ -DLLVM_LINK_LLVM_DYLIB=YES
+ -DLLVM_ENABLE_RTTI=YES
+ -DLLVM_ENABLE_FFI=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include"
+hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
+ python3-recommonmark python3-sphinx-automodapi"
+makedepends="python3-devel zlib-devel elfutils-devel libffi-devel libedit-devel
+ libxml2-devel binutils-devel libatomic-devel"
+depends="libllvm13>=${version}_${revision}"
+short_desc="Low Level Virtual Machine"
+maintainer="q66 <daniel@octaforge.org>"
+license="Apache-2.0"
+homepage="https://www.llvm.org"
+distfiles="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz"
+checksum=326335a830f2e32d06d0a36393b5455d17dc73e0bd1211065227ee014f92cbf8
+lib32disabled=yes
+python_version=3
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+ configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES"
+ makedepends+=" libexecinfo-devel"
+ depends+=" libexecinfo-devel"
+fi
+
+# "operand out of range" assembler failures
+case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ ppc*) configure_args+=" -DCLANG_ENABLE_CLANGD=OFF" ;;
+esac
+
+_enabled_projects="clang;clang-tools-extra;compiler-rt;libcxx;libcxxabi;libunwind;lld"
+
+_lldb_enable=yes
+_libomp_enable=no
+
+case "$XBPS_TARGET_MACHINE" in
+ ppc64le*) ;;
+ ppc*|i686*) _lldb_enable=no ;;
+esac
+
+case "$XBPS_TARGET_MACHINE" in
+ x86_64*|aarch64*|ppc64*) _libomp_enable=yes;;
+esac
+
+subpackages="clang-tools-extra"
+
+# must go before clang
+if [ "$_libomp_enable" = "yes" ]; then
+ _enabled_projects+=";openmp"
+ subpackages+=" libomp libomp-devel"
+ # because of cmake nonsense referencing libomptarget.so.*
+ depends+=" libomp>=${version}_${revision}"
+fi
+
+subpackages+=" clang clang-analyzer libclang libclang-cpp
+ llvm-libunwind llvm-libunwind-devel libcxx libcxx-devel
+ libcxxabi libcxxabi-devel libllvm13"
+
+if [ "$_lldb_enable" = "yes" ]; then
+ # XXX fails to cross compile due to python
+ _enabled_projects+=";lldb"
+ subpackages+=" lldb lldb-devel"
+fi
+
+subpackages+=" lld lld-devel"
+
+configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
+
+post_patch() {
+ if [ "$_lldb_enable" = "yes" ]; then
+ if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+ vsed -i 's|__ptrace_request|int|g' \
+ ${wrksrc}/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+ fi
+ # disable docs for lldb as they fail to generate
+ vsed -i '/add_subdirectory(docs)/d' \
+ ${wrksrc}/lldb/CMakeLists.txt
+ fi
+
+ # update config.guess for better platform detection
+ cp $XBPS_COMMONDIR/environment/configure/automake/config.guess \
+ ${wrksrc}/llvm/cmake
+
+ # fix linker failures on some archs
+ vsed -i 's,check_library_exists(gcc_s .*,set(LIBCXXABI_HAS_GCC_S_LIB ON),' \
+ ${wrksrc}/libcxxabi/cmake/config-ix.cmake
+ vsed -i 's,check_library_exists(gcc .*,set(LIBCXXABI_HAS_GCC_LIB ON),' \
+ ${wrksrc}/libcxxabi/cmake/config-ix.cmake
+
+ # need libssp_nonshared on some musl platforms (because of nodefaultlibs)
+ case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ ppc*-musl|i686-musl|mips*-musl)
+ vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+ ${wrksrc}/libunwind/src/CMakeLists.txt
+ vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+ ${wrksrc}/libcxxabi/src/CMakeLists.txt
+ vsed -i 's,#ssp,,' ${wrksrc}/libcxx/CMakeLists.txt
+ ;;
+ esac
+
+ case "$XBPS_TARGET_MACHINE" in
+ x86_64-musl) # some sanitizer currently only on x86_64 stuff needs backtrace
+ vsed -i 's,# Set common link flags.,list(APPEND SANITIZER_COMMON_LINK_LIBS execinfo),' \
+ ${wrksrc}/compiler-rt/CMakeLists.txt
+ ;;
+ arm*-musl|i686-musl) # sanitizer code is broken since it duplicates some libc bits
+ vsed -i 's/set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)/set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE)/' \
+ ${wrksrc}/compiler-rt/cmake/config-ix.cmake
+ ;;
+ esac
+}
+
+pre_configure() {
+ local triplet
+
+ # Vastly reduce size of debugging symbols:
+ CFLAGS=${CFLAGS/ -g/ -g1}
+ CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+
+ # since gcc9, the build likes to blow up for ppc32 apparently because
+ # of clang being too large for a 24-bit relative call to the PLT, so
+ # optimize for size instead
+ case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ mips*-musl|ppc*) configure_args+=" -DVOID_CXX_OPT_FLAGS=-Os" ;;
+ esac
+
+ if [ "$CROSS_BUILD" ]; then
+ msg_normal "Building host tblgen\n"
+ mkdir -p build/HOST
+ cd build/HOST
+ CC="$BUILD_CC" CXX="$BUILD_CXX" CFLAGS="$BUILD_CFLAGS" \
+ CXXFLAGS="$BUILD_CXXFLAGS" LDFLAGS="$BUILD_LDFLAGS" \
+ cmake ../.. -DCMAKE_BUILD_TYPE=Release \
+ -DLLVM_ENABLE_PROJECTS=${_enabled_projects}
+ make ${makejobs} -C utils/TableGen
+ make ${makejobs} -C tools/clang/utils/TableGen
+ [ "$_lldb_enable" = "yes" ] && make ${makejobs} -C tools/lldb/utils/TableGen
+ configure_args+=" -DLLVM_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/llvm-tblgen"
+ configure_args+=" -DCLANG_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/clang-tblgen"
+ [ "$_lldb_enable" = "yes" ] && configure_args+=" -DLLDB_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/lldb-tblgen"
+ cd ../..
+ fi
+
+ case "$XBPS_TARGET_MACHINE" in
+ i686*) _arch="X86";;
+ x86_64*) _arch="X86";;
+ armv5*) _arch="Armv5te";;
+ armv6*) _arch="Armv6";;
+ armv7*) _arch="Armv7";;
+ aarch64*) _arch="AArch64";;
+ mips*) _arch="Mips";;
+ ppc*) _arch="PowerPC";;
+ riscv64*) _arch="RISCV64";;
+ esac
+
+ triplet=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}
+
+ configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+ configure_args+=" -DLLVM_HOST_TRIPLE=${triplet}"
+ configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${triplet}"
+}
+
+do_install() {
+ cd build
+ cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr -P cmake_install.cmake
+
+ # Required for multilib.
+ if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
+ for _header in llvm-config; do
+ mv ${DESTDIR}/usr/include/llvm/Config/${_header}{,-64}.h
+ vinstall ${FILESDIR}/llvm-Config-${_header}.h 644 \
+ usr/include/llvm/Config ${_header}.h
+ done
+ fi
+
+ # Remove llvm-config-host in cross builds.
+ if [ "$CROSS_BUILD" ]; then
+ rm -f ${DESTDIR}/usr/bin/llvm-config-host
+ fi
+
+ # Install libcxxabi headers
+ vinstall ${wrksrc}/libcxxabi/include/__cxxabi_config.h 644 usr/include
+ vinstall ${wrksrc}/libcxxabi/include/cxxabi.h 644 usr/include
+
+ # Install libunwind headers
+ vinstall ${wrksrc}/libunwind/include/__libunwind_config.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/libunwind.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/unwind.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/mach-o/compact_unwind_encoding.h \
+ 644 usr/include/mach-o
+}
+
+clang-analyzer_package() {
+ pycompile_dirs="usr/share/scan-view"
+ depends="clang-${version}_${revision} python3 perl"
+ short_desc+=" - A source code analysis framework"
+ homepage="https://clang-analyzer.llvm.org/"
+ pkg_install() {
+ vmove usr/share/man/man1/scan-build.1
+ vmove "/usr/bin/scan-*"
+ vmove "/usr/share/scan-*"
+ vmove "/usr/libexec/*analyzer"
+ }
+}
+
+clang-tools-extra_package() {
+ lib32disabled=yes
+ depends="clang-${version}_${revision} python3"
+ short_desc+=" - Extra Clang tools"
+ homepage="https://clang.llvm.org/extra/"
+ pkg_install() {
+ vmove usr/include/clang-tidy
+ vmove usr/bin/clang-apply-replacements
+ vmove usr/bin/clang-query
+ vmove usr/bin/clang-rename
+ vmove usr/bin/clang-tidy
+ vmove usr/bin/diagtool
+ vmove usr/bin/find-all-symbols
+ vmove usr/bin/hmaptool
+ vmove usr/bin/modularize
+ vmove usr/bin/pp-trace
+ vmove usr/bin/sancov
+ vmove "usr/lib/libclangApplyReplacements*"
+ vmove "usr/lib/libclangQuery*"
+ vmove "usr/lib/libclangTidy*"
+ vmove "usr/share/clang/*tidy*"
+ vmove usr/share/doc/clang-tools
+ vmove usr/share/man/man1/extraclangtools.1
+ vmove usr/share/man/man1/diagtool.1
+ }
+}
+
+clang_package() {
+ lib32disabled=yes
+ depends="libstdc++-devel libgcc-devel binutils ${XBPS_TARGET_LIBC}-devel
+ libclang-${version}_${revision}"
+ short_desc+=" - C language family frontend"
+ homepage="https://clang.llvm.org/"
+ pkg_install() {
+ vmove usr/include/clang
+ vmove usr/include/clang-c
+ vmove "usr/bin/*clang*"
+ vmove usr/bin/c-index-test
+ vmove usr/lib/clang
+ vmove usr/lib/cmake/clang
+ vmove "usr/lib/libclang*.a"
+ vmove "usr/lib/libclang*.so"
+ vmove usr/share/clang
+ vmove usr/share/doc/clang
+ vmove usr/share/man/man1/clang.1
+ }
+}
+
+libclang_package() {
+ short_desc+=" - C frontend runtime library"
+ pkg_install() {
+ vmove "usr/lib/libclang.so.*"
+ }
+}
+
+libclang-cpp_package() {
+ short_desc+=" - C frontend runtime library (C++ interface)"
+ pkg_install() {
+ vmove "usr/lib/libclang-cpp.so.*"
+ }
+}
+
+lld_package() {
+ lib32disabled=yes
+ short_desc+=" - linker"
+ homepage="https://lld.llvm.org"
+ pkg_install() {
+ vmove usr/bin/lld*
+ vmove usr/bin/wasm-ld
+ vmove usr/bin/ld.lld*
+ vmove usr/bin/ld64.lld*
+ vmove usr/share/doc/lld
+ }
+}
+
+lld-devel_package() {
+ lib32disabled=yes
+ short_desc+=" - linker - development files"
+ homepage="https://lld.llvm.org"
+ depends="lld>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/include/lld
+ vmove usr/lib/cmake/lld
+ vmove "usr/lib/liblld*a"
+ }
+}
+
+lldb_package() {
+ lib32disabled=yes
+ depends+=" python3-six"
+ short_desc+=" - LLDB debugger"
+ homepage="https://lldb.llvm.org/"
+ pkg_install() {
+ vmove usr/bin/*lldb*
+ vmove usr/lib/liblldb*so.*
+ vmove /usr/lib/python*
+ }
+}
+
+lldb-devel_package() {
+ lib32disabled=yes
+ depends="lldb>=${version}_${revision}"
+ short_desc+=" - LLDB debugger - development files"
+ pkg_install() {
+ vmove usr/include/lldb
+ vmove "usr/lib/liblldb*.so"
+ }
+}
+
+llvm-libunwind_package() {
+ short_desc+=" - libunwind"
+ pkg_install() {
+ vmove "usr/lib/libunwind.so.*"
+ }
+}
+
+llvm-libunwind-devel_package() {
+ short_desc+=" - libunwind - development files"
+ depends="llvm-libunwind>=${version}_${revision}"
+ conflicts="libunwind-devel>=0"
+ pkg_install() {
+ vmove usr/lib/libunwind.so
+ vmove usr/lib/libunwind.a
+ vmove "usr/include/*unwind*"
+ vmove usr/include/mach-o
+ vmove usr/share/doc/libunwind
+ }
+}
+
+libcxxabi_package() {
+ short_desc+=" - low level support for libc++"
+ pkg_install() {
+ vmove "usr/lib/libc++abi.so.*"
+ }
+}
+
+libcxxabi-devel_package() {
+ short_desc+=" - low level support for libc++ - development files"
+ depends="libcxxabi>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/lib/libc++abi.so
+ vmove usr/lib/libc++abi.a
+ vmove "usr/include/*cxxabi*"
+ }
+}
+
+libcxx_package() {
+ short_desc+=" - C++ standard library"
+ pkg_install() {
+ vmove "usr/lib/libc++.so.*"
+ }
+}
+
+libcxx-devel_package() {
+ short_desc+=" - C++ standard library - development files"
+ depends="libcxx>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/lib/libc++.so
+ vmove usr/lib/libc++.a
+ vmove usr/lib/libc++experimental.a
+ vmove usr/include/c++
+ vmove usr/share/doc/libcxx
+ }
+}
+
+libomp_package() {
+ short_desc+=" - Clang OpenMP support library"
+ # Fix libomptarget.so name
+ mv usr/lib/libomptarget.so usr/lib/libomptarget.so.13
+ pkg_install() {
+ vmove usr/lib/libomp.so
+ vmove "usr/lib/libomptarget.rtl.*.so"
+ vmove usr/lib/libarcher.so
+ vmove "usr/lib/libomp*.so.*"
+ }
+}
+
+libomp-devel_package() {
+ short_desc+=" - Clang OpenMP support library - development files"
+ depends="libomp>=${version}_${revision}"
+ pkg_install() {
+ vmove "usr/lib/libomp*.so"
+ vmove "usr/lib/libarcher*"
+ vmove "usr/include/omp*.h"
+ vmove "usr/lib/clang/${version}/include/omp*.h"
+ vmove usr/share/man/man1/llvmopenmp.1
+ vmove usr/share/doc/openmp
+ }
+}
+
+libllvm13_package() {
+ short_desc+=" - runtime library"
+ pkg_install() {
+ vmove "usr/lib/libLLVM-*.so*"
+ }
+}
diff --git a/srcpkgs/llvm13/update b/srcpkgs/llvm13/update
new file mode 100644
index 000000000000..e95cf26b3586
--- /dev/null
+++ b/srcpkgs/llvm13/update
@@ -0,0 +1,3 @@
+site="https://github.com/llvm/llvm-project/releases"
+pattern="llvmorg-\K(\d+.){2}\d+(-rc\d+)?"
+ignore="*-rc*"
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR PATCH] [Updated] new package: llvm13-13.0.1
2022-03-22 14:15 [PR PATCH] new package: llvm13-13.0.1 subnut
2022-03-22 14:28 ` [PR PATCH] [Updated] " subnut
2022-03-22 14:31 ` subnut
@ 2022-03-22 14:40 ` subnut
2022-03-22 15:53 ` [ci skip] " subnut
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: subnut @ 2022-03-22 14:40 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]
There is an updated pull request by subnut against master on the void-packages repository
https://github.com/subnut/void-packages llvm13
https://github.com/void-linux/void-packages/pull/36280
new package: llvm13-13.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**
<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-glibc)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/36280.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-llvm13-36280.patch --]
[-- Type: text/x-diff, Size: 41565 bytes --]
From 82c9e26e658b0eaca2d2be80b87b6b985e83224e Mon Sep 17 00:00:00 2001
From: Subhaditya Nath <sn03.general@gmail.com>
Date: Tue, 22 Mar 2022 18:29:24 +0530
Subject: [PATCH] new package: llvm13-13.0.1
---
srcpkgs/clang | 2 +-
srcpkgs/clang-analyzer | 2 +-
| 2 +-
srcpkgs/libclang | 2 +-
srcpkgs/libclang-cpp | 2 +-
srcpkgs/libcxx | 2 +-
srcpkgs/libcxx-devel | 2 +-
srcpkgs/libcxxabi | 2 +-
srcpkgs/libcxxabi-devel | 2 +-
srcpkgs/libllvm13 | 1 +
srcpkgs/libomp | 2 +-
srcpkgs/libomp-devel | 2 +-
srcpkgs/lld | 2 +-
srcpkgs/lld-devel | 2 +-
srcpkgs/lldb | 2 +-
srcpkgs/lldb-devel | 2 +-
srcpkgs/llvm-libunwind | 2 +-
srcpkgs/llvm-libunwind-devel | 2 +-
.../llvm13/files/llvm-Config-llvm-config.h | 9 +
.../patches/compiler-rt-xray-ppc64-musl.patch | 62 +++
srcpkgs/llvm13/patches/libcxx-musl.patch | 26 ++
srcpkgs/llvm13/patches/libcxx-ppc.patch | 22 +
.../llvm13/patches/libcxx-ssp-nonshared.patch | 11 +
srcpkgs/llvm13/patches/libcxxabi-dl.patch | 25 +
srcpkgs/llvm13/patches/libunwind-ppc32.patch | 63 +++
srcpkgs/llvm13/patches/lldb-musl.patch | 31 ++
srcpkgs/llvm13/patches/llvm-001-musl.patch | 57 +++
.../patches/llvm-002-musl-ppc64-elfv2.patch | 30 ++
.../patches/llvm-003-ppc-secureplt.patch | 11 +
.../patches/llvm-004-override-opt.patch | 18 +
.../llvm13/patches/llvm-005-ppc-bigpic.patch | 36 ++
.../patches/llvm-006-aarch64-mf_exec.patch | 25 +
.../llvm13/patches/ppc32-compiler-rt.patch | 21 +
srcpkgs/llvm13/template | 429 ++++++++++++++++++
srcpkgs/llvm13/update | 3 +
35 files changed, 897 insertions(+), 17 deletions(-)
create mode 120000 srcpkgs/libllvm13
create mode 100644 srcpkgs/llvm13/files/llvm-Config-llvm-config.h
create mode 100644 srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-musl.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-ppc.patch
create mode 100644 srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
create mode 100644 srcpkgs/llvm13/patches/libcxxabi-dl.patch
create mode 100644 srcpkgs/llvm13/patches/libunwind-ppc32.patch
create mode 100644 srcpkgs/llvm13/patches/lldb-musl.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-001-musl.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-004-override-opt.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
create mode 100644 srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
create mode 100644 srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
create mode 100644 srcpkgs/llvm13/template
create mode 100644 srcpkgs/llvm13/update
diff --git a/srcpkgs/clang b/srcpkgs/clang
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang
+++ b/srcpkgs/clang
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/clang-analyzer b/srcpkgs/clang-analyzer
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang-analyzer
+++ b/srcpkgs/clang-analyzer
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
--git a/srcpkgs/clang-tools-extra b/srcpkgs/clang-tools-extra
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/clang-tools-extra
+++ b/srcpkgs/clang-tools-extra
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libclang b/srcpkgs/libclang
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libclang
+++ b/srcpkgs/libclang
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libclang-cpp b/srcpkgs/libclang-cpp
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libclang-cpp
+++ b/srcpkgs/libclang-cpp
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxx b/srcpkgs/libcxx
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxx
+++ b/srcpkgs/libcxx
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxx-devel b/srcpkgs/libcxx-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxx-devel
+++ b/srcpkgs/libcxx-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxxabi b/srcpkgs/libcxxabi
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxxabi
+++ b/srcpkgs/libcxxabi
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libcxxabi-devel b/srcpkgs/libcxxabi-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libcxxabi-devel
+++ b/srcpkgs/libcxxabi-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libllvm13 b/srcpkgs/libllvm13
new file mode 120000
index 000000000000..d6366d7d3b95
--- /dev/null
+++ b/srcpkgs/libllvm13
@@ -0,0 +1 @@
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libomp b/srcpkgs/libomp
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libomp
+++ b/srcpkgs/libomp
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/libomp-devel b/srcpkgs/libomp-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/libomp-devel
+++ b/srcpkgs/libomp-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lld b/srcpkgs/lld
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lld
+++ b/srcpkgs/lld
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lld-devel b/srcpkgs/lld-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lld-devel
+++ b/srcpkgs/lld-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lldb b/srcpkgs/lldb
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lldb
+++ b/srcpkgs/lldb
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/lldb-devel b/srcpkgs/lldb-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/lldb-devel
+++ b/srcpkgs/lldb-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind b/srcpkgs/llvm-libunwind
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/llvm-libunwind
+++ b/srcpkgs/llvm-libunwind
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm-libunwind-devel b/srcpkgs/llvm-libunwind-devel
index cd60fd7a981b..d6366d7d3b95 120000
--- a/srcpkgs/llvm-libunwind-devel
+++ b/srcpkgs/llvm-libunwind-devel
@@ -1 +1 @@
-llvm12
\ No newline at end of file
+llvm13
\ No newline at end of file
diff --git a/srcpkgs/llvm13/files/llvm-Config-llvm-config.h b/srcpkgs/llvm13/files/llvm-Config-llvm-config.h
new file mode 100644
index 000000000000..2fa08c9be696
--- /dev/null
+++ b/srcpkgs/llvm13/files/llvm-Config-llvm-config.h
@@ -0,0 +1,9 @@
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 32
+#include "llvm-config-32.h"
+#elif __WORDSIZE == 64
+#include "llvm-config-64.h"
+#else
+#error "Unknown word size"
+#endif
diff --git a/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch b/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
new file mode 100644
index 000000000000..d0b61c80c897
--- /dev/null
+++ b/srcpkgs/llvm13/patches/compiler-rt-xray-ppc64-musl.patch
@@ -0,0 +1,62 @@
+--- a/compiler-rt/lib/xray/xray_powerpc64.inc
++++ b/compiler-rt/lib/xray/xray_powerpc64.inc
+@@ -12,7 +12,13 @@
+
+ #include <cstdint>
+ #include <mutex>
++#ifdef __GLIBC__
+ #include <sys/platform/ppc.h>
++#else
++#include <cctype>
++#include <cstring>
++#include <cstdlib>
++#endif
+
+ #include "xray_defs.h"
+
+@@ -20,13 +26,45 @@ namespace __xray {
+
+ ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT {
+ CPU = 0;
++#ifdef __GLIBC__
+ return __ppc_get_timebase();
++#else
++ return __builtin_ppc_get_timebase();
++#endif
+ }
+
+ inline uint64_t getTSCFrequency() XRAY_NEVER_INSTRUMENT {
+ static std::mutex M;
+ std::lock_guard<std::mutex> Guard(M);
++#ifdef __GLIBC__
+ return __ppc_get_timebase_freq();
++#else
++ /* FIXME: a less dirty implementation? */
++ static uint64_t base;
++ if (!base) {
++ FILE *f = fopen("/proc/cpuinfo", "rb");
++ if (f) {
++ ssize_t nr;
++ /* virtually always big enough to hold the line */
++ char buf[512];
++ while (fgets(buf, sizeof(buf), f)) {
++ char *ret = strstr(buf, "timebase");
++ if (!ret) {
++ continue;
++ }
++ ret += sizeof("timebase") - 1;
++ ret = strchr(ret, ':');
++ if (!ret) {
++ continue;
++ }
++ base = strtoul(ret + 1, nullptr, 10);
++ break;
++ }
++ fclose(f);
++ }
++ }
++ return base;
++#endif
+ }
+
+ inline bool probeRequiredCPUFeatures() XRAY_NEVER_INSTRUMENT {
diff --git a/srcpkgs/llvm13/patches/libcxx-musl.patch b/srcpkgs/llvm13/patches/libcxx-musl.patch
new file mode 100644
index 000000000000..ef60a16c54bb
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-musl.patch
@@ -0,0 +1,26 @@
+--- a/libcxx/include/locale
++++ b/libcxx/include/locale
+@@ -747,7 +747,11 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
++#if defined(__linux__) && !defined(__GLIBC__)
++ long long __ll = strtoll(__a, &__p2, __base);
++#else
+ long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++#endif
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
+@@ -787,7 +791,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
+ typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ errno = 0;
+ char *__p2;
++#if defined(__linux__) && !defined(__GLIBC__)
++ unsigned long long __ll = strtoull(__a, &__p2, __base);
++#else
+ unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
++#endif
+ typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ if (__current_errno == 0)
+ errno = __save_errno;
diff --git a/srcpkgs/llvm13/patches/libcxx-ppc.patch b/srcpkgs/llvm13/patches/libcxx-ppc.patch
new file mode 100644
index 000000000000..7a92f8004e1c
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-ppc.patch
@@ -0,0 +1,22 @@
+This ensures `is_iec559` is defined correctly under all long double ABIs,
+including musl and its 64-bit long double. Also, `__ppc__` or `__ppc64__`
+is not defined on gcc.
+
+--- a/libcxx/include/limits
++++ b/libcxx/include/limits
+@@ -426,8 +426,14 @@ protected:
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
+
+-#if (defined(__ppc__) || defined(__ppc64__))
++#if defined(__powerpc__) || defined(__powerpc64__)
++#if (__LDBL_MAX_EXP__ > __DBL_MAX_EXP__) || (__LDBL_MANT_DIG__ == __DBL_MANT_DIG__)
++ /* IEEE 754 quadruple or double precision */
++ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
++#else
++ /* 128-bit IBM double-double */
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
++#endif
+ #else
+ static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
+ #endif
diff --git a/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch b/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
new file mode 100644
index 000000000000..55ece79f7f3a
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxx-ssp-nonshared.patch
@@ -0,0 +1,11 @@
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -800,6 +800,8 @@ function(cxx_link_system_libraries target)
+ target_link_libraries(${target} PRIVATE atomic)
+ endif()
+
++#ssp target_link_libraries(${target} PRIVATE ssp_nonshared)
++
+ if (MINGW)
+ target_link_libraries(${target} PRIVATE "${MINGW_LIBRARIES}")
+ endif()
diff --git a/srcpkgs/llvm13/patches/libcxxabi-dl.patch b/srcpkgs/llvm13/patches/libcxxabi-dl.patch
new file mode 100644
index 000000000000..fa84fe6fd94d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libcxxabi-dl.patch
@@ -0,0 +1,25 @@
+Also link to -ldl to prevent undefined references.
+
+--- a/libcxxabi/src/CMakeLists.txt.orig
++++ b/libcxxabi/src/CMakeLists.txt
+@@ -75,6 +75,7 @@ else()
+ endif()
+
+ add_library_flags_if(LIBCXXABI_HAS_C_LIB c)
++ add_library_flags_if(LIBCXXABI_HAS_C_LIB dl)
+ endif()
+
+ if (LIBCXXABI_USE_COMPILER_RT)
+--- a/libcxx/CMakeLists.txt
++++ b/libcxx/CMakeLists.txt
+@@ -781,6 +781,10 @@
+ target_link_libraries(${target} PRIVATE m)
+ endif()
+
++ if (LIBCXX_HAS_C_LIB)
++ target_link_libraries(${target} PRIVATE dl)
++ endif()
++
+ if (LIBCXX_HAS_RT_LIB)
+ target_link_libraries(${target} PRIVATE rt)
+ endif()
diff --git a/srcpkgs/llvm13/patches/libunwind-ppc32.patch b/srcpkgs/llvm13/patches/libunwind-ppc32.patch
new file mode 100644
index 000000000000..2dd7c681637d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/libunwind-ppc32.patch
@@ -0,0 +1,63 @@
+This fixes build at least with gcc9 which does not define `__ppc__`.
+
+--- a/libunwind/include/__libunwind_config.h
++++ b/libunwind/include/__libunwind_config.h
+@@ -55,7 +55,7 @@
+ # define _LIBUNWIND_CONTEXT_SIZE 167
+ # define _LIBUNWIND_CURSOR_SIZE 179
+ # define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64
+-# elif defined(__ppc__)
++# elif defined(__powerpc__)
+ # define _LIBUNWIND_TARGET_PPC 1
+ # define _LIBUNWIND_CONTEXT_SIZE 117
+ # define _LIBUNWIND_CURSOR_SIZE 124
+--- a/libunwind/src/UnwindRegistersRestore.S
++++ b/libunwind/src/UnwindRegistersRestore.S
+@@ -389,7 +389,7 @@ Lnovec:
+ PPC64_LR(3)
+ bctr
+
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+
+ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
+ //
+--- a/libunwind/src/UnwindRegistersSave.S
++++ b/libunwind/src/UnwindRegistersSave.S
+@@ -556,7 +556,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
+ blr
+
+
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+
+ //
+ // extern int unw_getcontext(unw_context_t* thread_state)
+--- a/libunwind/src/config.h
++++ b/libunwind/src/config.h
+@@ -105,12 +105,12 @@
+ #define _LIBUNWIND_BUILD_SJLJ_APIS
+ #endif
+
+-#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__)
++#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__powerpc64__)
+ #define _LIBUNWIND_SUPPORT_FRAME_APIS
+ #endif
+
+ #if defined(__i386__) || defined(__x86_64__) || \
+- defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) || \
++ defined(__powerpc__) || defined(__powerpc64__) || \
+ (!defined(__APPLE__) && defined(__arm__)) || \
+ defined(__aarch64__) || \
+ defined(__mips__) || \
+--- a/libunwind/src/libunwind.cpp
++++ b/libunwind/src/libunwind.cpp
+@@ -51,7 +51,7 @@ _LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor,
+ # define REGISTER_KIND Registers_x86_64
+ #elif defined(__powerpc64__)
+ # define REGISTER_KIND Registers_ppc64
+-#elif defined(__ppc__)
++#elif defined(__powerpc__)
+ # define REGISTER_KIND Registers_ppc
+ #elif defined(__aarch64__)
+ # define REGISTER_KIND Registers_arm64
diff --git a/srcpkgs/llvm13/patches/lldb-musl.patch b/srcpkgs/llvm13/patches/lldb-musl.patch
new file mode 100644
index 000000000000..601c0d138523
--- /dev/null
+++ b/srcpkgs/llvm13/patches/lldb-musl.patch
@@ -0,0 +1,31 @@
+--- a/lldb/source/Plugins/Process/Linux/Procfs.h
++++ b/lldb/source/Plugins/Process/Linux/Procfs.h
+@@ -10,21 +10,12 @@
+ // sys/procfs.h on Android/Linux for all supported architectures.
+
+ #include <sys/ptrace.h>
++#include <asm/ptrace.h>
+
+-#ifdef __ANDROID__
+-#if defined(__arm64__) || defined(__aarch64__)
+-typedef unsigned long elf_greg_t;
+-typedef elf_greg_t
+- elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))];
+-typedef struct user_fpsimd_state elf_fpregset_t;
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#elif defined(__mips__)
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#endif
+-#else // __ANDROID__
++#if !defined(__GLIBC__) && defined(__powerpc__)
++#define pt_regs musl_pt_regs
++#include <sys/procfs.h>
++#undef pt_regs
++#else
+ #include <sys/procfs.h>
+-#endif // __ANDROID__
++#endif
diff --git a/srcpkgs/llvm13/patches/llvm-001-musl.patch b/srcpkgs/llvm13/patches/llvm-001-musl.patch
new file mode 100644
index 000000000000..2580a1a518ca
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-001-musl.patch
@@ -0,0 +1,57 @@
+From faca3fbd15d0c3108493c3c54cd93138e049ac43 Mon Sep 17 00:00:00 2001
+From: Andrea Brancaleoni <miwaxe@gmail.com>
+Date: Tue, 8 Sep 2015 22:03:02 +0200
+Subject: [PATCH 3/3] musl
+
+---
+ include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
+ lib/Support/DynamicLibrary.cpp | 2 +-
+ lib/Support/Unix/Signals.inc | 6 +++---
+ utils/unittest/googletest/src/gtest.cc | 1 +
+ 5 files changed, 17 insertions(+), 6 deletions(-)
+
+diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
+index 34a8a1e3..1214ece5 100644
+--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
++++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+@@ -18,6 +18,15 @@
+ #include "llvm/IR/PassManager.h"
+ #include "llvm/Pass.h"
+
++#undef fopen64
++#undef fseeko64
++#undef fstat64
++#undef fstatvfs64
++#undef ftello64
++#undef lstat64
++#undef stat64
++#undef tmpfile64
++
+ namespace llvm {
+ template <typename T> class ArrayRef;
+ class Triple;
+diff --git a/lib/Support/Unix/DynamicLibrary.inc b/lib/Support/Unix/DynamicLibrary.inc
+index a2a37996..2f86c470 100644
+--- a/llvm/lib/Support/Unix/DynamicLibrary.inc
++++ b/llvm/lib/Support/Unix/DynamicLibrary.inc
+@@ -102,7 +102,7 @@ static void *DoSearch(const char* SymbolName) {
+
+ // This macro returns the address of a well-known, explicit symbol
+ #define EXPLICIT_SYMBOL(SYM) \
+- if (!strcmp(SymbolName, #SYM)) return &SYM
++ if (!strcmp(SymbolName, #SYM)) return (void *)&SYM
+
+ // Under glibc we have a weird situation. The stderr/out/in symbols are both
+ // macros and global variables because of standards requirements. So, we
+diff --git a/utils/unittest/googletest/src/gtest.cc b/utils/unittest/googletest/src/gtest.cc
+index d882ab2e..f1fb12d0 100644
+--- a/llvm/utils/unittest/googletest/src/gtest.cc
++++ b/llvm/utils/unittest/googletest/src/gtest.cc
+@@ -114,6 +114,7 @@
+
+ #if GTEST_CAN_STREAM_RESULTS_
+ # include <arpa/inet.h> // NOLINT
++# include <sys/socket.h> // NOLINT
+ # include <netdb.h> // NOLINT
+ # include <sys/socket.h> // NOLINT
+ # include <sys/types.h> // NOLINT
diff --git a/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch b/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
new file mode 100644
index 000000000000..68bd57ecbade
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-002-musl-ppc64-elfv2.patch
@@ -0,0 +1,30 @@
+This patches LLVM to use ELFv2 on ppc64 unconditionally unless overridden. We
+need this because unlike most distros we use ELFv2 for both glibc and musl
+on big endian ppc64.
+
+diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
+index 0634833e..b7cbc2e7 100644
+--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
++++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+@@ -226,9 +226,8 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
+
+ switch (TT.getArch()) {
+ case Triple::ppc64le:
+- return PPCTargetMachine::PPC_ABI_ELFv2;
+ case Triple::ppc64:
+- return PPCTargetMachine::PPC_ABI_ELFv1;
++ return PPCTargetMachine::PPC_ABI_ELFv2;
+ default:
+ return PPCTargetMachine::PPC_ABI_UNKNOWN;
+ }
+diff --git a/test/CodeGen/PowerPC/ppc64-elf-abi.ll b/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+index 8b1cf6b5..296a2afa 100644
+--- a/llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
++++ b/llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+@@ -1,4 +1,5 @@
+-; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv1
++; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2
++; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-musl < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+ ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2
diff --git a/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch b/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
new file mode 100644
index 000000000000..32bd57a25b1d
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-003-ppc-secureplt.patch
@@ -0,0 +1,11 @@
+--- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
++++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+@@ -169,7 +169,7 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
+
+ if ((TargetTriple.isOSFreeBSD() && TargetTriple.getOSMajorVersion() >= 13) ||
+ TargetTriple.isOSNetBSD() || TargetTriple.isOSOpenBSD() ||
+- TargetTriple.isMusl())
++ isTargetLinux())
+ SecurePlt = true;
+
+ if (HasSPE && IsPPC64)
diff --git a/srcpkgs/llvm13/patches/llvm-004-override-opt.patch b/srcpkgs/llvm13/patches/llvm-004-override-opt.patch
new file mode 100644
index 000000000000..8226f0704053
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-004-override-opt.patch
@@ -0,0 +1,18 @@
+This allows us to override the optimization level as not all platforms can
+deal with -O3.
+
+--- a/llvm/CMakeLists.txt
++++ b/llvm/CMakeLists.txt
+@@ -960,6 +960,12 @@ if( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
+ llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
+ endif()
+
++set(VOID_CXX_OPT_FLAGS "" CACHE STRING "Optimization level to use")
++
++if (NOT VOID_CXX_OPT_FLAGS STREQUAL "")
++ llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "${VOID_CXX_OPT_FLAGS}")
++endif()
++
+ # Put this before tblgen. Else we have a circular dependence.
+ add_subdirectory(lib/Demangle)
+ add_subdirectory(lib/Support)
diff --git a/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch b/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
new file mode 100644
index 000000000000..cb4eee59c340
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-005-ppc-bigpic.patch
@@ -0,0 +1,36 @@
+From f3dbdd49c06bfafc1d6138094cf42889c14d38b6 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sun, 3 Nov 2019 10:57:27 -0600
+Subject: [PATCH] [LLVM][PowerPC] Assume BigPIC if no PIC level is specified
+
+---
+ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 2 +-
+ llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
+index cce21f32..87ca5f9b 100644
+--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
++++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+@@ -599,7 +599,7 @@ void PPCAsmPrinter::EmitTlsCall(const MachineInstr *MI,
+
+ // Add 32768 offset to the symbol so we follow up the latest GOT/PLT ABI.
+ if (Kind == MCSymbolRefExpr::VK_PLT && Subtarget->isSecurePlt() &&
+- M->getPICLevel() == PICLevel::BigPIC)
++ M->getPICLevel() != PICLevel::SmallPIC)
+ TlsRef = MCBinaryExpr::createAdd(
+ TlsRef, MCConstantExpr::create(32768, OutContext), OutContext);
+ const MachineOperand &MO = MI->getOperand(2);
+diff --git a/lib/Target/PowerPC/PPCMCInstLower.cpp b/lib/Target/PowerPC/PPCMCInstLower.cpp
+index 5cc180d7..a5b02565 100644
+--- a/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
++++ b/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
+@@ -117,7 +117,7 @@ static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol,
+ const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, RefKind, Ctx);
+ // If -msecure-plt -fPIC, add 32768 to symbol.
+ if (Subtarget->isSecurePlt() && TM.isPositionIndependent() &&
+- M->getPICLevel() == PICLevel::BigPIC &&
++ M->getPICLevel() != PICLevel::SmallPIC &&
+ MO.getTargetFlags() == PPCII::MO_PLT)
+ Expr =
+ MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(32768, Ctx), Ctx);
diff --git a/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch b/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
new file mode 100644
index 000000000000..6cca600d6603
--- /dev/null
+++ b/srcpkgs/llvm13/patches/llvm-006-aarch64-mf_exec.patch
@@ -0,0 +1,25 @@
+Fix failures in AllocationTests/MappedMemoryTest.* on aarch64:
+
+ Failing Tests (8):
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3
+ LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3
+
+Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10
+
+--- a/llvm/lib/Support/Unix/Memory.inc
++++ b/llvm/lib/Support/Unix/Memory.inc
+@@ -50,7 +50,7 @@ static int getPosixProtectionFlags(unsigned Flags) {
+ return PROT_READ | PROT_WRITE | PROT_EXEC;
+ case llvm::sys::Memory::MF_EXEC:
+ #if (defined(__FreeBSD__) || defined(__POWERPC__) || defined (__ppc__) || \
+- defined(_POWER) || defined(_ARCH_PPC))
++ defined(_POWER) || defined(_ARCH_PPC) || (defined(__linux__) && defined(__aarch64__)))
+ // On PowerPC, having an executable page that has no read permission
+ // can have unintended consequences. The function InvalidateInstruction-
+ // Cache uses instructions dcbf and icbi, both of which are treated by
diff --git a/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch b/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
new file mode 100644
index 000000000000..f92efb6aade1
--- /dev/null
+++ b/srcpkgs/llvm13/patches/ppc32-compiler-rt.patch
@@ -0,0 +1,21 @@
+commit ba4ede595ff9599232f5dd2b4384c243137b53fc
+Author: Daniel Kolesa <daniel@octaforge.org>
+Date: Tue Jun 22 23:40:54 2021 +0200
+
+ enable compiler-rt support for ppc32
+
+diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake
+index 1edab43..5c0c8a2 100644
+--- a/compiler-rt/cmake/base-config-ix.cmake
++++ b/compiler-rt/cmake/base-config-ix.cmake
+@@ -207,9 +207,7 @@ macro(test_targets)
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc64le|ppc64le")
+ test_target_arch(powerpc64le "" "-m64")
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
+- if(CMAKE_SYSTEM_NAME MATCHES "AIX")
+- test_target_arch(powerpc "" "-m32")
+- endif()
++ test_target_arch(powerpc "" "-m32")
+ test_target_arch(powerpc64 "" "-m64")
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "s390x")
+ test_target_arch(s390x "" "")
diff --git a/srcpkgs/llvm13/template b/srcpkgs/llvm13/template
new file mode 100644
index 000000000000..ba3372b77d87
--- /dev/null
+++ b/srcpkgs/llvm13/template
@@ -0,0 +1,429 @@
+# Template file for 'llvm13'
+pkgname=llvm13
+version=13.0.1
+revision=1
+wrksrc="llvm-project-${version}.src"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="
+ -DCMAKE_BUILD_TYPE=Release -Wno-dev
+ -DENABLE_LINKER_BUILD_ID=YES
+ -DLLDB_USE_SYSTEM_SIX=YES
+ -DLIBCXX_CXX_ABI=libcxxabi
+ -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=YES
+ -DLIBCXXABI_USE_LLVM_UNWINDER=YES
+ -DLIBCXXABI_ENABLE_STATIC_UNWINDER=YES
+ -DLIBOMP_ENABLE_SHARED=YES
+ -DLIBOMP_INSTALL_ALIASES=NO
+ -DLLVM_INCLUDE_DOCS=YES
+ -DLLVM_BUILD_DOCS=YES
+ -DLLVM_ENABLE_SPHINX=YES
+ -DSPHINX_WARNINGS_AS_ERRORS=NO
+ -DLLVM_INSTALL_UTILS=YES
+ -DLLVM_BUILD_LLVM_DYLIB=YES
+ -DLLVM_LINK_LLVM_DYLIB=YES
+ -DLLVM_ENABLE_RTTI=YES
+ -DLLVM_ENABLE_FFI=YES
+ -DLLVM_BINUTILS_INCDIR=/usr/include"
+hostmakedepends="perl python3 zlib-devel libffi-devel swig python3-Sphinx
+ python3-recommonmark python3-sphinx-automodapi"
+makedepends="python3-devel zlib-devel elfutils-devel libffi-devel libedit-devel
+ libxml2-devel binutils-devel libatomic-devel"
+depends="libllvm13>=${version}_${revision}"
+short_desc="Low Level Virtual Machine"
+maintainer="q66 <daniel@octaforge.org>"
+license="Apache-2.0"
+homepage="https://www.llvm.org"
+distfiles="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz"
+checksum=326335a830f2e32d06d0a36393b5455d17dc73e0bd1211065227ee014f92cbf8
+lib32disabled=yes
+python_version=3
+
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+ configure_args+=" -DLIBCXX_HAS_MUSL_LIBC=YES"
+ makedepends+=" libexecinfo-devel"
+ depends+=" libexecinfo-devel"
+fi
+
+# "operand out of range" assembler failures
+case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ ppc*) configure_args+=" -DCLANG_ENABLE_CLANGD=OFF" ;;
+esac
+
+_enabled_projects="clang;clang-tools-extra;compiler-rt;libcxx;libcxxabi;libunwind;lld"
+
+_lldb_enable=yes
+_libomp_enable=no
+
+case "$XBPS_TARGET_MACHINE" in
+ ppc64le*) ;;
+ ppc*|i686*) _lldb_enable=no ;;
+esac
+
+case "$XBPS_TARGET_MACHINE" in
+ x86_64*|aarch64*|ppc64*) _libomp_enable=yes;;
+esac
+
+subpackages="clang-tools-extra"
+
+# must go before clang
+if [ "$_libomp_enable" = "yes" ]; then
+ _enabled_projects+=";openmp"
+ subpackages+=" libomp libomp-devel"
+ # because of cmake nonsense referencing libomptarget.so.*
+ depends+=" libomp>=${version}_${revision}"
+fi
+
+subpackages+=" clang clang-analyzer libclang libclang-cpp
+ llvm-libunwind llvm-libunwind-devel libcxx libcxx-devel
+ libcxxabi libcxxabi-devel libllvm13"
+
+if [ "$_lldb_enable" = "yes" ]; then
+ # XXX fails to cross compile due to python
+ _enabled_projects+=";lldb"
+ subpackages+=" lldb lldb-devel"
+fi
+
+subpackages+=" lld lld-devel"
+
+configure_args+=" -DLLVM_ENABLE_PROJECTS=${_enabled_projects}"
+
+post_patch() {
+ if [ "$_lldb_enable" = "yes" ]; then
+ if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+ vsed -i 's|__ptrace_request|int|g' \
+ ${wrksrc}/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+ fi
+ # disable docs for lldb as they fail to generate
+ vsed -i '/add_subdirectory(docs)/d' \
+ ${wrksrc}/lldb/CMakeLists.txt
+ fi
+
+ # update config.guess for better platform detection
+ cp $XBPS_COMMONDIR/environment/configure/automake/config.guess \
+ ${wrksrc}/llvm/cmake
+
+ # fix linker failures on some archs
+ vsed -i 's,check_library_exists(gcc_s .*,set(LIBCXXABI_HAS_GCC_S_LIB ON),' \
+ ${wrksrc}/libcxxabi/cmake/config-ix.cmake
+ vsed -i 's,check_library_exists(gcc .*,set(LIBCXXABI_HAS_GCC_LIB ON),' \
+ ${wrksrc}/libcxxabi/cmake/config-ix.cmake
+
+ # need libssp_nonshared on some musl platforms (because of nodefaultlibs)
+ case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ ppc*-musl|i686-musl|mips*-musl)
+ vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+ ${wrksrc}/libunwind/src/CMakeLists.txt
+ vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' \
+ ${wrksrc}/libcxxabi/src/CMakeLists.txt
+ vsed -i 's,#ssp,,' ${wrksrc}/libcxx/CMakeLists.txt
+ ;;
+ esac
+
+ case "$XBPS_TARGET_MACHINE" in
+ x86_64-musl) # some sanitizer currently only on x86_64 stuff needs backtrace
+ vsed -i 's,# Set common link flags.,list(APPEND SANITIZER_COMMON_LINK_LIBS execinfo),' \
+ ${wrksrc}/compiler-rt/CMakeLists.txt
+ ;;
+ arm*-musl|i686-musl) # sanitizer code is broken since it duplicates some libc bits
+ vsed -i 's/set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)/set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE)/' \
+ ${wrksrc}/compiler-rt/cmake/config-ix.cmake
+ ;;
+ esac
+}
+
+pre_configure() {
+ local triplet
+
+ # Vastly reduce size of debugging symbols:
+ CFLAGS=${CFLAGS/ -g/ -g1}
+ CXXFLAGS=${CXXFLAGS/ -g/ -g1}
+
+ # since gcc9, the build likes to blow up for ppc32 apparently because
+ # of clang being too large for a 24-bit relative call to the PLT, so
+ # optimize for size instead
+ case "$XBPS_TARGET_MACHINE" in
+ ppc64*) ;;
+ mips*-musl|ppc*) configure_args+=" -DVOID_CXX_OPT_FLAGS=-Os" ;;
+ esac
+
+ if [ "$CROSS_BUILD" ]; then
+ msg_normal "Building host tblgen\n"
+ mkdir -p build/HOST
+ cd build/HOST
+ CC="$BUILD_CC" CXX="$BUILD_CXX" CFLAGS="$BUILD_CFLAGS" \
+ CXXFLAGS="$BUILD_CXXFLAGS" LDFLAGS="$BUILD_LDFLAGS" \
+ cmake ../.. -DCMAKE_BUILD_TYPE=Release \
+ -DLLVM_ENABLE_PROJECTS=${_enabled_projects}
+ make ${makejobs} -C utils/TableGen
+ make ${makejobs} -C tools/clang/utils/TableGen
+ [ "$_lldb_enable" = "yes" ] && make ${makejobs} -C tools/lldb/utils/TableGen
+ configure_args+=" -DLLVM_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/llvm-tblgen"
+ configure_args+=" -DCLANG_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/clang-tblgen"
+ [ "$_lldb_enable" = "yes" ] && configure_args+=" -DLLDB_TABLEGEN=${wrksrc}/llvm/build/HOST/bin/lldb-tblgen"
+ cd ../..
+ fi
+
+ case "$XBPS_TARGET_MACHINE" in
+ i686*) _arch="X86";;
+ x86_64*) _arch="X86";;
+ armv5*) _arch="Armv5te";;
+ armv6*) _arch="Armv6";;
+ armv7*) _arch="Armv7";;
+ aarch64*) _arch="AArch64";;
+ mips*) _arch="Mips";;
+ ppc*) _arch="PowerPC";;
+ riscv64*) _arch="RISCV64";;
+ esac
+
+ triplet=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}
+
+ configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
+ configure_args+=" -DLLVM_HOST_TRIPLE=${triplet}"
+ configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${triplet}"
+}
+
+pre_install() {
+ # Fix libomptarget.so name
+ mv usr/lib/libomptarget.so usr/lib/libomptarget.so.13
+}
+
+do_install() {
+ cd build
+ cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr -P cmake_install.cmake
+
+ # Required for multilib.
+ if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
+ for _header in llvm-config; do
+ mv ${DESTDIR}/usr/include/llvm/Config/${_header}{,-64}.h
+ vinstall ${FILESDIR}/llvm-Config-${_header}.h 644 \
+ usr/include/llvm/Config ${_header}.h
+ done
+ fi
+
+ # Remove llvm-config-host in cross builds.
+ if [ "$CROSS_BUILD" ]; then
+ rm -f ${DESTDIR}/usr/bin/llvm-config-host
+ fi
+
+ # Install libcxxabi headers
+ vinstall ${wrksrc}/libcxxabi/include/__cxxabi_config.h 644 usr/include
+ vinstall ${wrksrc}/libcxxabi/include/cxxabi.h 644 usr/include
+
+ # Install libunwind headers
+ vinstall ${wrksrc}/libunwind/include/__libunwind_config.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/libunwind.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/unwind.h 644 usr/include
+ vinstall ${wrksrc}/libunwind/include/mach-o/compact_unwind_encoding.h \
+ 644 usr/include/mach-o
+}
+
+clang-analyzer_package() {
+ pycompile_dirs="usr/share/scan-view"
+ depends="clang-${version}_${revision} python3 perl"
+ short_desc+=" - A source code analysis framework"
+ homepage="https://clang-analyzer.llvm.org/"
+ pkg_install() {
+ vmove usr/share/man/man1/scan-build.1
+ vmove "/usr/bin/scan-*"
+ vmove "/usr/share/scan-*"
+ vmove "/usr/libexec/*analyzer"
+ }
+}
+
+clang-tools-extra_package() {
+ lib32disabled=yes
+ depends="clang-${version}_${revision} python3"
+ short_desc+=" - Extra Clang tools"
+ homepage="https://clang.llvm.org/extra/"
+ pkg_install() {
+ vmove usr/include/clang-tidy
+ vmove usr/bin/clang-apply-replacements
+ vmove usr/bin/clang-query
+ vmove usr/bin/clang-rename
+ vmove usr/bin/clang-tidy
+ vmove usr/bin/diagtool
+ vmove usr/bin/find-all-symbols
+ vmove usr/bin/hmaptool
+ vmove usr/bin/modularize
+ vmove usr/bin/pp-trace
+ vmove usr/bin/sancov
+ vmove "usr/lib/libclangApplyReplacements*"
+ vmove "usr/lib/libclangQuery*"
+ vmove "usr/lib/libclangTidy*"
+ vmove "usr/share/clang/*tidy*"
+ vmove usr/share/doc/clang-tools
+ vmove usr/share/man/man1/extraclangtools.1
+ vmove usr/share/man/man1/diagtool.1
+ }
+}
+
+clang_package() {
+ lib32disabled=yes
+ depends="libstdc++-devel libgcc-devel binutils ${XBPS_TARGET_LIBC}-devel
+ libclang-${version}_${revision}"
+ short_desc+=" - C language family frontend"
+ homepage="https://clang.llvm.org/"
+ pkg_install() {
+ vmove usr/include/clang
+ vmove usr/include/clang-c
+ vmove "usr/bin/*clang*"
+ vmove usr/bin/c-index-test
+ vmove usr/lib/clang
+ vmove usr/lib/cmake/clang
+ vmove "usr/lib/libclang*.a"
+ vmove "usr/lib/libclang*.so"
+ vmove usr/share/clang
+ vmove usr/share/doc/clang
+ vmove usr/share/man/man1/clang.1
+ }
+}
+
+libclang_package() {
+ short_desc+=" - C frontend runtime library"
+ pkg_install() {
+ vmove "usr/lib/libclang.so.*"
+ }
+}
+
+libclang-cpp_package() {
+ short_desc+=" - C frontend runtime library (C++ interface)"
+ pkg_install() {
+ vmove "usr/lib/libclang-cpp.so.*"
+ }
+}
+
+lld_package() {
+ lib32disabled=yes
+ short_desc+=" - linker"
+ homepage="https://lld.llvm.org"
+ pkg_install() {
+ vmove usr/bin/lld*
+ vmove usr/bin/wasm-ld
+ vmove usr/bin/ld.lld*
+ vmove usr/bin/ld64.lld*
+ vmove usr/share/doc/lld
+ }
+}
+
+lld-devel_package() {
+ lib32disabled=yes
+ short_desc+=" - linker - development files"
+ homepage="https://lld.llvm.org"
+ depends="lld>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/include/lld
+ vmove usr/lib/cmake/lld
+ vmove "usr/lib/liblld*a"
+ }
+}
+
+lldb_package() {
+ lib32disabled=yes
+ depends+=" python3-six"
+ short_desc+=" - LLDB debugger"
+ homepage="https://lldb.llvm.org/"
+ pkg_install() {
+ vmove usr/bin/*lldb*
+ vmove usr/lib/liblldb*so.*
+ vmove /usr/lib/python*
+ }
+}
+
+lldb-devel_package() {
+ lib32disabled=yes
+ depends="lldb>=${version}_${revision}"
+ short_desc+=" - LLDB debugger - development files"
+ pkg_install() {
+ vmove usr/include/lldb
+ vmove "usr/lib/liblldb*.so"
+ }
+}
+
+llvm-libunwind_package() {
+ short_desc+=" - libunwind"
+ pkg_install() {
+ vmove "usr/lib/libunwind.so.*"
+ }
+}
+
+llvm-libunwind-devel_package() {
+ short_desc+=" - libunwind - development files"
+ depends="llvm-libunwind>=${version}_${revision}"
+ conflicts="libunwind-devel>=0"
+ pkg_install() {
+ vmove usr/lib/libunwind.so
+ vmove usr/lib/libunwind.a
+ vmove "usr/include/*unwind*"
+ vmove usr/include/mach-o
+ vmove usr/share/doc/libunwind
+ }
+}
+
+libcxxabi_package() {
+ short_desc+=" - low level support for libc++"
+ pkg_install() {
+ vmove "usr/lib/libc++abi.so.*"
+ }
+}
+
+libcxxabi-devel_package() {
+ short_desc+=" - low level support for libc++ - development files"
+ depends="libcxxabi>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/lib/libc++abi.so
+ vmove usr/lib/libc++abi.a
+ vmove "usr/include/*cxxabi*"
+ }
+}
+
+libcxx_package() {
+ short_desc+=" - C++ standard library"
+ pkg_install() {
+ vmove "usr/lib/libc++.so.*"
+ }
+}
+
+libcxx-devel_package() {
+ short_desc+=" - C++ standard library - development files"
+ depends="libcxx>=${version}_${revision}"
+ pkg_install() {
+ vmove usr/lib/libc++.so
+ vmove usr/lib/libc++.a
+ vmove usr/lib/libc++experimental.a
+ vmove usr/include/c++
+ vmove usr/share/doc/libcxx
+ }
+}
+
+libomp_package() {
+ short_desc+=" - Clang OpenMP support library"
+ pkg_install() {
+ vmove usr/lib/libomp.so
+ vmove "usr/lib/libomptarget.rtl.*.so"
+ vmove usr/lib/libarcher.so
+ vmove "usr/lib/libomp*.so.*"
+ }
+}
+
+libomp-devel_package() {
+ short_desc+=" - Clang OpenMP support library - development files"
+ depends="libomp>=${version}_${revision}"
+ pkg_install() {
+ vmove "usr/lib/libomp*.so"
+ vmove "usr/lib/libarcher*"
+ vmove "usr/include/omp*.h"
+ vmove "usr/lib/clang/${version}/include/omp*.h"
+ vmove usr/share/man/man1/llvmopenmp.1
+ vmove usr/share/doc/openmp
+ }
+}
+
+libllvm13_package() {
+ short_desc+=" - runtime library"
+ pkg_install() {
+ vmove "usr/lib/libLLVM-*.so*"
+ }
+}
diff --git a/srcpkgs/llvm13/update b/srcpkgs/llvm13/update
new file mode 100644
index 000000000000..e95cf26b3586
--- /dev/null
+++ b/srcpkgs/llvm13/update
@@ -0,0 +1,3 @@
+site="https://github.com/llvm/llvm-project/releases"
+pattern="llvmorg-\K(\d+.){2}\d+(-rc\d+)?"
+ignore="*-rc*"
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ci skip] new package: llvm13-13.0.1
2022-03-22 14:15 [PR PATCH] new package: llvm13-13.0.1 subnut
` (2 preceding siblings ...)
2022-03-22 14:40 ` subnut
@ 2022-03-22 15:53 ` subnut
2022-03-22 15:53 ` [PR PATCH] [Closed]: " subnut
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: subnut @ 2022-03-22 15:53 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 193 bytes --]
New comment by subnut on void-packages repository
https://github.com/void-linux/void-packages/pull/36280#issuecomment-1075346501
Comment:
Closing in favor of #36229, as directed by @paper42.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR PATCH] [Closed]: [ci skip] new package: llvm13-13.0.1
2022-03-22 14:15 [PR PATCH] new package: llvm13-13.0.1 subnut
` (3 preceding siblings ...)
2022-03-22 15:53 ` [ci skip] " subnut
@ 2022-03-22 15:53 ` subnut
2022-03-23 16:07 ` dkwo
2022-03-23 16:36 ` subnut
6 siblings, 0 replies; 8+ messages in thread
From: subnut @ 2022-03-22 15:53 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]
There's a closed pull request on the void-packages repository
[ci skip] new package: llvm13-13.0.1
https://github.com/void-linux/void-packages/pull/36280
Description:
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**
<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-glibc)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ci skip] new package: llvm13-13.0.1
2022-03-22 14:15 [PR PATCH] new package: llvm13-13.0.1 subnut
` (4 preceding siblings ...)
2022-03-22 15:53 ` [PR PATCH] [Closed]: " subnut
@ 2022-03-23 16:07 ` dkwo
2022-03-23 16:36 ` subnut
6 siblings, 0 replies; 8+ messages in thread
From: dkwo @ 2022-03-23 16:07 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 338 bytes --]
New comment by dkwo on void-packages repository
https://github.com/void-linux/void-packages/pull/36280#issuecomment-1076469230
Comment:
@subnut could you comment in #36229 as to which patches are actually necessary? did you build successfully for x86-64-musl?
for comparison alpine has 3 patches; are all our patches needed for cross?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ci skip] new package: llvm13-13.0.1
2022-03-22 14:15 [PR PATCH] new package: llvm13-13.0.1 subnut
` (5 preceding siblings ...)
2022-03-23 16:07 ` dkwo
@ 2022-03-23 16:36 ` subnut
6 siblings, 0 replies; 8+ messages in thread
From: subnut @ 2022-03-23 16:36 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 330 bytes --]
New comment by subnut on void-packages repository
https://github.com/void-linux/void-packages/pull/36280#issuecomment-1076515567
Comment:
@dkwo
> did you build successfully for x86-64-musl?
nope.
> which patches are actually necessary?
I actually don't know. Otherwise I would've mentioned it in that PR already :)
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-03-23 16:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22 14:15 [PR PATCH] new package: llvm13-13.0.1 subnut
2022-03-22 14:28 ` [PR PATCH] [Updated] " subnut
2022-03-22 14:31 ` subnut
2022-03-22 14:40 ` subnut
2022-03-22 15:53 ` [ci skip] " subnut
2022-03-22 15:53 ` [PR PATCH] [Closed]: " subnut
2022-03-23 16:07 ` dkwo
2022-03-23 16:36 ` subnut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).