Created
November 14, 2023 00:10
-
-
Save Simon-L/e850fae740a79331ad097615ed691adb to your computer and use it in GitHub Desktop.
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) | |
get_filename_component(MYLIBFAUSTEMBEDDED_ROOT | |
"${CMAKE_CURRENT_LIST_DIR}/../" | |
ABSOLUTE) | |
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) | |
message(/usr/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/libz3.so) | |
message(${MYLIBFAUSTEMBEDDED_ROOT}/libfaust-ubuntu-x86_64/lib/libfaustwithllvm.a) | |
add_executable(faustuserprojectwithllvm ${MYLIBFAUSTEMBEDDED_ROOT}/source/main0.cpp) | |
target_compile_features(faustuserprojectwithllvm PRIVATE cxx_std_11) | |
target_link_libraries(faustuserprojectwithllvm PUBLIC | |
${MYLIBFAUSTEMBEDDED_ROOT}/libfaust-ubuntu-x86_64/lib/libfaustwithllvm.a | |
rt | |
dl | |
m | |
/usr/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/libz3.so | |
z | |
tinfo | |
xml2) | |
target_include_directories( | |
faustuserprojectwithllvm | |
PUBLIC | |
"${MYLIBFAUSTEMBEDDED_ROOT}/faust-2.69.3/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"; | |
} | |
} | |
extern "C" float foobar() | |
{ | |
// printf("Hello\n"); | |
return 42.0f; | |
} | |
void foo(int argc, const char* argv[]) | |
{ | |
registerForeignFunction("foobar"); | |
std::string error_msg; | |
llvm_dsp_factory* factory = createDSPFactoryFromFile(argv[argc-1], argc, argv, 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; | |
int fargc = argc - 1; | |
char* fargv[fargc]; | |
for (size_t i = 0; i < fargc; i++) { | |
fargv[i] = argv[i+1]; | |
std::cout << i << " : " << fargv[i] << std::endl; | |
} | |
auto cfargv = const_cast<const char **>(fargv); | |
foo(fargc, cfargv); | |
return 0; | |
} | |
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
❯ build-prebuilt/faustuserprojectwithllvm -I faust-2.69.3/libraries dsp1.dsp | |
Libfaust version : 2.69.3 (LLVM 15.0.7) | |
getDSPMachineTarget x86_64-linux-gnu:tigerlake | |
0 : -I | |
1 : faust-2.69.3/libraries | |
2 : dsp1.dsp | |
getCompileOptions -lang llvm 15.0.7 -ct 1 -es 1 -mcd 16 -single -ftz 0 | |
item: /home/xox/Sync/SyncMore/mylibfaustembedded/faust-2.69.3/libraries/stdfaust.lib | |
item: /home/xox/Sync/SyncMore/mylibfaustembedded/dsp1.dsp | |
item: /home/xox/Sync/SyncMore/mylibfaustembedded/faust-2.69.3/libraries | |
item: /usr/local/share/faust | |
item: /usr/local/share/faust | |
item: /usr/share/faust | |
item: . | |
item: /home/xox/Sync/SyncMore/mylibfaustembedded | |
getName dsp1 | |
getSHAKey 930EB205B25119EF54FB56507C16373AF82BC6CF | |
Render one buffer | |
[1] 67777 segmentation fault build-prebuilt/faustuserprojectwithllvm -I faust-2.69.3/libraries dsp1.dsp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment