Created
July 19, 2023 20:21
-
-
Save Simon-L/7f975a43d8165d6a60586fcf6de3b5bb to your computer and use it in GitHub Desktop.
Build libfaust with llvm using prebuilt llvm from debian packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# For debian-based | |
# Requires mktemp and dpkg-deb | |
llvmroot=$(mktemp -d) | |
echo ${llvmroot} | |
pushd ${llvmroot} | |
wget http://ftp.de.debian.org/debian/pool/main/l/llvm-toolchain-15/llvm-15-dev_15.0.7-6_amd64.deb | |
dpkg-deb -x llvm-15-dev_15.0.7-6_amd64.deb . | |
wget http://ftp.de.debian.org/debian/pool/main/l/llvm-toolchain-15/llvm-15_15.0.7-6_amd64.deb | |
dpkg-deb -x llvm-15_15.0.7-6_amd64.deb . | |
wget http://ftp.de.debian.org/debian/pool/main/l/llvm-toolchain-15/libpolly-15-dev_15.0.7-6_amd64.deb | |
dpkg-deb -x libpolly-15-dev_15.0.7-6_amd64.deb . | |
popd | |
export PATH="${llvmroot}/usr/lib/llvm-15/bin:$PATH" | |
pushd build | |
cmake -C ./backends/all.cmake . -Bbuild -DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_VERBOSE_MAKEFILE=ON -DINCLUDE_DYNAMIC=ON -DINCLUDE_STATIC=ON \ | |
-DINCLUDE_LLVM=ON -DUSE_LLVM_CONFIG=ON \ | |
-DLLVM_CONFIG=${llvmroot}/usr/lib/llvm-15/bin/llvm-config \ | |
-DCMAKE_PREFIX_PATH=${llvmroot}/usr/lib/llvm-15/lib/cmake/llvm | |
cmake --build build --config Release --parallel 16 | |
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.14) | |
project(faustuserprojectwithllvm) | |
add_executable(faustuserprojectwithllvm main.cpp) | |
target_compile_features(faustuserprojectwithllvm PRIVATE cxx_std_11) | |
target_link_libraries(faustuserprojectwithllvm PUBLIC | |
${PROJECT_SOURCE_DIR}/libfaustwithllvm.a | |
rt | |
dl | |
m | |
/usr/lib/x86_64-linux-gnu/libz3.so | |
z | |
tinfo | |
xml2) | |
target_include_directories( | |
faustuserprojectwithllvm | |
PUBLIC | |
"../architecture" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copied from llvm-test.cpp | |
#include <iostream> | |
#include <fstream> | |
#include <sstream> | |
#include <thread> | |
#include <vector> | |
#include "faust/dsp/llvm-dsp.h" | |
#include "faust/audio/dummy-audio.h" | |
#include "faust/gui/DecoratorUI.h" | |
#include "faust/gui/PrintUI.h" | |
#include "faust/misc.h" | |
// To do CPU native compilation | |
#ifndef JIT_TARGET | |
#define JIT_TARGET "" | |
#endif | |
static void printList(const std::vector<std::string>& list) | |
{ | |
for (int i = 0; i < list.size(); i++) { | |
std::cout << "item: " << list[i] << "\n"; | |
} | |
} | |
void foo() | |
{ | |
std::string error_msg; | |
llvm_dsp_factory* factory = createDSPFactoryFromString("FaustDSP", "import(\"stdfaust.lib\");process = os.osc(440);", 0, NULL, JIT_TARGET, error_msg, -1); | |
if (!factory) { | |
std::cerr << "Cannot create factory : " << error_msg; | |
exit(EXIT_FAILURE); | |
} | |
std::cout << "getCompileOptions " << factory->getCompileOptions() << std::endl; | |
printList(factory->getLibraryList()); | |
printList(factory->getIncludePathnames()); | |
dsp* DSP = factory->createDSPInstance(); | |
if (!DSP) { | |
std::cerr << "Cannot create instance "<< std::endl; | |
exit(EXIT_FAILURE); | |
} | |
std::cout << "getName " << factory->getName() << std::endl; | |
std::cout << "getSHAKey " << factory->getSHAKey() << std::endl; | |
dummyaudio audio(1); | |
if (!audio.init("FaustDSP", DSP)) { | |
exit(EXIT_FAILURE); | |
} | |
audio.start(); | |
audio.stop(); | |
delete DSP; | |
deleteDSPFactory(factory); | |
} | |
int main(int argc, char* argv[]) | |
{ | |
std::cout << "Libfaust version : " << getCLibFaustVersion () << std::endl; | |
std::cout << "getDSPMachineTarget " << getDSPMachineTarget() << std::endl; | |
foo(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment