diff --git a/faust-2.40.0-llvm-14.0.3.patch b/faust-2.40.0-llvm-14.0.3.patch new file mode 100644 index 0000000..7cc0200 --- /dev/null +++ b/faust-2.40.0-llvm-14.0.3.patch @@ -0,0 +1,184 @@ +From 1275ec6774e0fb8eaf12fd1cb30b16a08044bcb7 Mon Sep 17 00:00:00 2001 +From: Stephane Letz +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 + + // Disappears in LLVM 15 +-#if LLVM_VERSION_MAJOR >= 15 ++#if LLVM_VERSION_MAJOR >= 14 + #include + #else + #include +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(beg, end) + #define MakeArgs(args) llvm::ArrayRef(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(variable->getType()->getPointerElementType())) { ++ if (isa(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) diff --git a/faust.spec b/faust.spec index 32e5609..ad77d8b 100644 --- a/faust.spec +++ b/faust.spec @@ -1,6 +1,6 @@ Name: faust Version: 2.40.0 -Release: 1mamba +Release: 2mamba Summary: Functional programming language for signal processing and sound synthesis Group: Applications/Development Vendor: openmamba @@ -11,19 +11,23 @@ Source: https://github.com/grame-cncm/faust/releases/download/%{version}/ Patch0: faust-2.30.5-llvm-11.1.0.patch Patch1: faust-2.30.5-missing-include-limits.patch Patch2: faust-2.30.5-sound2file-missing-include-limits.patch +Patch3: faust-2.40.0-llvm-14.0.3.patch License: GPL ## AUTOBUILDREQ-BEGIN BuildRequires: glibc-devel BuildRequires: libflac-devel BuildRequires: libgcc +BuildRequires: liblame-devel BuildRequires: libllvm-devel BuildRequires: libmicrohttpd-devel +BuildRequires: libmpg123-devel BuildRequires: libogg-devel BuildRequires: libopus-devel BuildRequires: libsndfile-devel BuildRequires: libstdc++6-devel BuildRequires: libvorbis-devel ## AUTOBUILDREQ-END +BuildRequires: libllvm-devel >= 14.0.3 Requires: lib%{name} = %{?epoch:%epoch:}%{version}-%{release} %description @@ -55,6 +59,7 @@ This package contains libraries and header files for developing applications tha #%patch0 -p1 #%patch1 -p1 %patch2 -p1 +%patch3 -p1 -b .llvm-14.0.3 %build #:<< _EOF @@ -134,6 +139,9 @@ rm -f %{buildroot}%{_datadir}/faust/max-msp/sndfile/*/libsndfile.a %changelog +* Mon May 02 2022 Silvan Calarco 2.40.0-2mamba +- rebuilt with llvm 14.0.3 + * Wed Apr 13 2022 Automatic Build System 2.40.0-1mamba - automatic version update by autodist