aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpsykose <alice@ayaya.dev>2022-06-10 20:24:49 +0000
committerpsykose <alice@ayaya.dev>2022-06-10 23:06:43 +0200
commit34e6abe17a377ae9917f6994b89188005e1a3052 (patch)
tree9b7a4e068d97a04fea48cceec5034360ccde1a1c
parent7693fa5ca2ed753662c7afc08ce3e257a13bf6cb (diff)
downloadaports-34e6abe17a377ae9917f6994b89188005e1a3052.tar.gz
aports-34e6abe17a377ae9917f6994b89188005e1a3052.tar.bz2
aports-34e6abe17a377ae9917f6994b89188005e1a3052.tar.xz
testing/faust: rebuild against llvm14
-rw-r--r--testing/faust/APKBUILD4
-rw-r--r--testing/faust/llvm14.patch185
2 files changed, 188 insertions, 1 deletions
diff --git a/testing/faust/APKBUILD b/testing/faust/APKBUILD
index 56080b5106..ef63beb096 100644
--- a/testing/faust/APKBUILD
+++ b/testing/faust/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Francesco Camuffo <dev@fmac.xyz>
pkgname=faust
pkgver=2.40.0
-pkgrel=0
+pkgrel=1
pkgdesc="Functional programming language for realtime audio signal processing"
url="https://faust.grame.fr"
arch="all"
@@ -25,6 +25,7 @@ subpackages="
"
source="$pkgname-$pkgver.tar.gz::https://github.com/grame-cncm/faust/releases/download/$pkgver/faust-$pkgver.tar.gz
faust-musl-stacktrace.patch
+ llvm14.patch
"
build() {
@@ -88,4 +89,5 @@ vim() {
sha512sums="
7ecb334b95042caa3a44ecbb711a972b6f979afca4c67fc4f32acf548ed85472e941c6590a139464aeb5266c3e88fe639e2060a110a98e88fd7b1994e0a87650 faust-2.40.0.tar.gz
f3e07bdd26ab8f0ffbf0c0dfbf8141facc07d2db05346f3b982faca613aa5ecad8986683db8d49caed720d58b183b215d6e1c4ceef069f29f41bcfa699ad5f28 faust-musl-stacktrace.patch
+e28a76fe56deeac83c2f751933e6106c4f4e9903c7b8ec850eeb98f482cf85b37973caba96525f583b59952d0017c50f5956d537ac3f40fb88774bdc74ae2cec llvm14.patch
"
diff --git a/testing/faust/llvm14.patch b/testing/faust/llvm14.patch
new file mode 100644
index 0000000000..f311a4228c
--- /dev/null
+++ b/testing/faust/llvm14.patch
@@ -0,0 +1,185 @@
+Patch-Source: https://github.com/grame-cncm/faust/commit/1275ec6774e0fb8eaf12fd1cb30b16a08044bcb7
+From 1275ec6774e0fb8eaf12fd1cb30b16a08044bcb7 Mon Sep 17 00:00:00 2001
+From: Stephane Letz <letz@grame.fr>
+Date: Wed, 30 Mar 2022 09:31:01 +0200
+Subject: [PATCH] Add support for LLVM 14.
+
+---
+ compiler/generator/llvm/llvm_dsp_aux.cpp | 4 +-
+ .../generator/llvm/llvm_dynamic_dsp_aux.cpp | 2 +-
+ compiler/generator/llvm/llvm_instructions.hh | 77 ++++++++-----------
+ 3 files changed, 35 insertions(+), 48 deletions(-)
+
+diff --git a/compiler/generator/llvm/llvm_dsp_aux.cpp b/compiler/generator/llvm/llvm_dsp_aux.cpp
+index 1d08a1be2a..232aef616c 100644
+--- a/compiler/generator/llvm/llvm_dsp_aux.cpp
++++ b/compiler/generator/llvm/llvm_dsp_aux.cpp
+@@ -116,7 +116,7 @@ void llvm_dsp_factory_aux::startLLVMLibrary()
+ {
+ if (llvm_dsp_factory_aux::gInstance++ == 0) {
+ // Install the LLVM error handler
+- #if defined(__APPLE__) && LLVM_VERSION_MAJOR == 13
++ #if defined(__APPLE__) && LLVM_VERSION_MAJOR >= 11
+ #warning Crash on OSX so deactivated in this case
+ #else
+ LLVMInstallFatalErrorHandler(llvm_dsp_factory_aux::LLVMFatalErrorHandler);
+@@ -128,7 +128,7 @@ void llvm_dsp_factory_aux::stopLLVMLibrary()
+ {
+ if (--llvm_dsp_factory_aux::gInstance == 0) {
+ // Remove the LLVM error handler
+- #if defined(__APPLE__) && (LLVM_VERSION_MAJOR >= 11 && LLVM_VERSION_MAJOR <= 13)
++ #if defined(__APPLE__) && LLVM_VERSION_MAJOR >= 11
+ #warning Crash on OSX so deactivated in this case
+ #else
+ LLVMResetFatalErrorHandler();
+diff --git a/compiler/generator/llvm/llvm_dynamic_dsp_aux.cpp b/compiler/generator/llvm/llvm_dynamic_dsp_aux.cpp
+index 60a71df70f..3e5c30bf8e 100644
+--- a/compiler/generator/llvm/llvm_dynamic_dsp_aux.cpp
++++ b/compiler/generator/llvm/llvm_dynamic_dsp_aux.cpp
+@@ -65,7 +65,7 @@
+ #include <llvm/Bitcode/BitcodeWriter.h>
+
+ // Disappears in LLVM 15
+-#if LLVM_VERSION_MAJOR >= 15
++#if LLVM_VERSION_MAJOR >= 14
+ #include <llvm/MC/TargetRegistry.h>
+ #else
+ #include <llvm/Support/TargetRegistry.h>
+diff --git a/compiler/generator/llvm/llvm_instructions.hh b/compiler/generator/llvm/llvm_instructions.hh
+index 91ead36d37..c092db8c64 100644
+--- a/compiler/generator/llvm/llvm_instructions.hh
++++ b/compiler/generator/llvm/llvm_instructions.hh
+@@ -57,7 +57,16 @@ using namespace llvm;
+
+ #define MakeIdx(beg, end) llvm::ArrayRef<LLVMValue>(beg, end)
+ #define MakeArgs(args) llvm::ArrayRef<lLLVMValue>(args)
++#if LLVM_VERSION_MAJOR >= 14
++#define GetType(ptr) ptr->getType()->getScalarType()->getPointerElementType()
++#define MakeStructGEP(v1, v2) fBuilder->CreateStructGEP(GetType(v1), v1, v2);
++#define MyCreateLoad(var, is_volatile) fBuilder->CreateLoad(GetType(var), var, is_volatile)
++#define MyCreateLoad1(var) fBuilder->CreateLoad(GetType(var), var)
++#else
+ #define MakeStructGEP(v1, v2) fBuilder->CreateStructGEP(v1, v2);
++#define MyCreateLoad(var, is_volatile) fBuilder->CreateLoad(var, is_volatile)
++#define MyCreateLoad1(var) fBuilder->CreateLoad(var)
++#endif
+ #define MakeConstGEP32(type_def, llvm_name) fBuilder->CreateConstGEP2_32(type_def, llvm_name, 0, 0);
+ #define MakeIntPtrType() fModule->getDataLayout().getIntPtrType(fModule->getContext())
+
+@@ -284,42 +293,32 @@ class LLVMInstVisitor : public InstVisitor, public LLVMTypeHelper {
+
+ LLVMValue loadStructVarAddress(const string& name)
+ {
+-#if LLVM_VERSION_MAJOR >= 15
+-#warning FIXME
+- faustassert(false);
+- return {};
+-#else
+ return MakeStructGEP(loadFunArg("dsp"), fStructVisitor->getFieldIndex(name));
+-#endif
+ }
+
+ LLVMValue loadStructArrayVarAddress(const string& name)
+ {
+-#if LLVM_VERSION_MAJOR >= 15
+-#warning FIXME
+- faustassert(false);
+- return {};
+-#else
+ int field_index = fStructVisitor->getFieldIndex(name);
+ LLVMValue idx[] = {genInt32(0), genInt32(field_index)};
++ #if LLVM_VERSION_MAJOR >= 14
++ return fBuilder->CreateInBoundsGEP(GetType(loadFunArg("dsp")), loadFunArg("dsp"), MakeIdx(idx, idx + 2));
++ #else
+ return fBuilder->CreateInBoundsGEP(loadFunArg("dsp"), MakeIdx(idx, idx + 2));
+-#endif
++ #endif
+ }
+
+- LLVMValue loadArrayAsPointer(LLVMValue variable, bool is_volatile = false)
++ LLVMValue loadArrayAsPointer(LLVMValue var, bool is_volatile = false)
+ {
+-#if LLVM_VERSION_MAJOR >= 15
+-#warning FIXME
+- faustassert(false);
+- return {};
+-#else
+- if (isa<ArrayType>(variable->getType()->getPointerElementType())) {
++ if (isa<ArrayType>(var->getType()->getPointerElementType())) {
+ LLVMValue idx[] = {genInt32(0), genInt32(0)};
+- return fBuilder->CreateInBoundsGEP(variable, MakeIdx(idx, idx + 2));
++ #if LLVM_VERSION_MAJOR >= 14
++ return fBuilder->CreateInBoundsGEP(GetType(var), var, MakeIdx(idx, idx + 2));
++ #else
++ return fBuilder->CreateInBoundsGEP(var, MakeIdx(idx, idx + 2));
++ #endif
+ } else {
+- return fBuilder->CreateLoad(variable, is_volatile);
++ return MyCreateLoad(var, is_volatile);
+ }
+-#endif
+ }
+
+ LLVMValue loadFunArg(const string& name)
+@@ -583,19 +582,21 @@ class LLVMInstVisitor : public InstVisitor, public LLVMTypeHelper {
+ return nullptr;
+ }
+
+-#if LLVM_VERSION_MAJOR >= 15
+-#warning FIXME
+- faustassert(false);
+- return {};
+-#else
+ // Indexed adresses can actually be values in an array or fields in a struct type
+ if (isStructType(indexed_address->getName())) {
+ LLVMValue idx[] = {genInt32(0), fCurValue};
++ #if LLVM_VERSION_MAJOR >= 14
++ return fBuilder->CreateInBoundsGEP(GetType(load_ptr), load_ptr, MakeIdx(idx, idx + 2));
++ #else
+ return fBuilder->CreateInBoundsGEP(load_ptr, MakeIdx(idx, idx + 2));
++ #endif
+ } else {
++ #if LLVM_VERSION_MAJOR >= 14
++ return fBuilder->CreateInBoundsGEP(GetType(load_ptr), load_ptr, fCurValue);
++ #else
+ return fBuilder->CreateInBoundsGEP(load_ptr, fCurValue);
++ #endif
+ }
+-#endif
+ }
+
+ virtual LLVMValue visit(Address* address)
+@@ -630,14 +631,8 @@ class LLVMInstVisitor : public InstVisitor, public LLVMTypeHelper {
+ fCurValue = loadArrayAsPointer(visit(inst->fAddress), named_address->fAccess & Address::kVolatile);
+ }
+ } else if (indexed_address) {
+-
+-#if LLVM_VERSION_MAJOR >= 15
+-#warning FIXME
+- faustassert(false);
+- return;
+-#else
+- fCurValue = fBuilder->CreateLoad(visit(inst->fAddress));
+-#endif
++ Value* Ptr = visit(inst->fAddress);
++ fCurValue = MyCreateLoad1(Ptr);
+ } else {
+ faustassert(false);
+ }
+@@ -985,15 +980,7 @@ class LLVMInstVisitor : public InstVisitor, public LLVMTypeHelper {
+ // Emit merge block
+ function->getBasicBlockList().push_back(merge_block);
+ fBuilder->SetInsertPoint(merge_block);
+-
+-#if LLVM_VERSION_MAJOR >= 15
+-#warning FIXME
+- faustassert(false);
+- return;
+-#else
+- // Load result in fCurValue
+- fCurValue = fBuilder->CreateLoad(typed_res);
+-#endif
++ fCurValue = MyCreateLoad1(typed_res);
+ }
+
+ virtual void visit(IfInst* inst)