grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.54k stars 319 forks source link

feature request: allow to explicitly enable foreign functions with LLVM #783

Closed jcelerier closed 2 years ago

jcelerier commented 2 years ago

Hi,

to give the context: I'm trying to see if the Guitarix plugs can work in ossia score . Some of them call some foreign functions implemented in C/C++ (basically data tables for valve simulation).

What would be great would be to have something in the API such as:

registerKnownForeignFunction("some_function");

to allow Faust to generate llvm bitcode knowing that "some_function" will be in the address space of the process which will be loading and linking the LLVM bitcode afterwards.

I've tried looking at how to implement it like this: https://github.com/jcelerier/faust/commit/5b612e2ea12a989d07477b886bfa111fd26af02f but I'm getting crashes at compilation time so there is certainly a lot missing for it to work - if this is even possible?

Thanks !

sletz commented 2 years ago

Any crash log?

jcelerier commented 2 years ago

hmm it turns out that I get the crashes on master-dev even without my patch aha. sending a log asap

jcelerier commented 2 years ago

hmmm even with CMAKE_BUILDTYPE=Debug and checking that libfaust.so has debug symbols I still can't seem to get symbols: (while trying to compile `process = ;`

ASSERT : please report this message, the stack trace, and the failing DSP file to Faust developers (file: fir_to_fir.hh, line: 572, version: 2.44.5, options: -lang llvm 14.0.6 -es 1 -mcd 16 -double -ftz 0 -vec -lv 0 -vs 32 )
====== stack trace start ======
/usr/lib/libfaust.so.2(+0x286093) [0x7f8f41a86093]
/usr/lib/libfaust.so.2(+0x28505b) [0x7f8f41a8505b]
/usr/lib/libfaust.so.2(+0x35e78f) [0x7f8f41b5e78f]
/usr/lib/libfaust.so.2(+0x2b6ea2) [0x7f8f41ab6ea2]
/usr/lib/libfaust.so.2(+0x2bac5a) [0x7f8f41abac5a]
/usr/lib/libfaust.so.2(+0x2b6090) [0x7f8f41ab6090]
/usr/lib/libfaust.so.2(+0x2bb4db) [0x7f8f41abb4db]
/usr/lib/libfaust.so.2(+0x2b722a) [0x7f8f41ab722a]
/usr/lib/libfaust.so.2(+0x2bb1aa) [0x7f8f41abb1aa]
/usr/lib/libfaust.so.2(+0x2b821a) [0x7f8f41ab821a]
/usr/lib/libfaust.so.2(+0x2bb4db) [0x7f8f41abb4db]
/usr/lib/libfaust.so.2(+0x2b722a) [0x7f8f41ab722a]
/usr/lib/libfaust.so.2(+0x2bb1aa) [0x7f8f41abb1aa]
/usr/lib/libfaust.so.2(+0x2b821a) [0x7f8f41ab821a]
/usr/lib/libfaust.so.2(+0x2bb4db) [0x7f8f41abb4db]
/usr/lib/libfaust.so.2(+0x2b722a) [0x7f8f41ab722a]
/usr/lib/libfaust.so.2(+0x2bb4db) [0x7f8f41abb4db]
/usr/lib/libfaust.so.2(+0x2b722a) [0x7f8f41ab722a]
/usr/lib/libfaust.so.2(+0x348f35) [0x7f8f41b48f35]
/usr/lib/libfaust.so.2(+0x45a981) [0x7f8f41c5a981]
====== stack trace stop ======
jcelerier commented 2 years ago

It works at 38ab1bc42d8ea091d3e6915d2a6b419d06ced5da

sletz commented 2 years ago