grame-cncm / faust

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

basic Interpreter test failing for make libsall option #973

Closed shakfu closed 9 months ago

shakfu commented 9 months ago

I'm on macOS M1 Ventura 13.6.1 and I want a non-llvm-dependent build of libfaust.a and libfaust.dylib (with the intent to wrap some parts of the interface in cython).

I've tried the following sequence:

git clone --recursive https://github.com/grame-cncm/faust.git
cd faust
PREFIX=`pwd`/prefix make libsall
# it builds successfully
PREFIX=`pwd`/prefix make install
cp tests/interp-tests/interp-test.cpp ./prefix/
cd prefix

Then the first test

% g++ -DINTERP_DSP=1 -std=c++11 -O3 interp-test.cpp -I./include -L./lib -L`brew --prefix`/lib ./lib/libfaust.a -o interp-test

ld: warning: object file (./lib/libfaust.a[51](export.cpp.o)) was built for newer 'macOS' version (13.6) than being linked (13.0)
ld: Undefined symbols:
  deleteInterpreterDSPFactory(interpreter_dsp_factory*), referenced from:
      _main in interp-test-0c62af.o
      _main in interp-test-0c62af.o
      _main in interp-test-0c62af.o
      _main in interp-test-0c62af.o
  createInterpreterDSPFactoryFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, char const**, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&), referenced from:
      _main in interp-test-0c62af.o
  createInterpreterDSPFactoryFromString(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, char const**, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&), referenced from:
      _main in interp-test-0c62af.o
      _main in interp-test-0c62af.o
  writeInterpreterDSPFactoryToBitcodeFile(interpreter_dsp_factory*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&), referenced from:
      _main in interp-test-0c62af.o
  readInterpreterDSPFactoryFromBitcodeFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&), referenced from:
      _main in interp-test-0c62af.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Clearly there are symbols missing, so add /faust/dsp/faust-dynamic-engine.cpp

% g++ -DINTERP_DSP=1 -std=c++11 -O3 interp-test.cpp ./include/faust/dsp/faust-dynamic-engine.cpp -I./include -L./lib -L`brew --prefix`/lib ./lib/libfaust.a -o interp-test
./include/faust/dsp/faust-dynamic-engine.cpp:156:17: warning: 7 enumeration values not handled in switch: 'kPortAudioRenderer', 'kRtAudioRenderer', 'kJackRenderer'... [-Wswitch]
        switch (renderer) {
                ^~~~~~~~
./include/faust/dsp/faust-dynamic-engine.cpp:156:17: note: add missing switch cases
        switch (renderer) {
                ^
1 warning generated.
ld: warning: object file (./lib/libfaust.a[51](export.cpp.o)) was built for newer 'macOS' version (13.6) than being linked (13.0)
ld: Undefined symbols:
  deleteInterpreterDSPFactory(interpreter_dsp_factory*), referenced from:
      _main in interp-test-83d3cd.o
      _main in interp-test-83d3cd.o
      _main in interp-test-83d3cd.o
      _main in interp-test-83d3cd.o
      dsp_aux::~dsp_aux() in faust-dynamic-engine-e3328e.o
      dsp_aux::~dsp_aux() in faust-dynamic-engine-e3328e.o
  createInterpreterDSPFactoryFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, char const**, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&), referenced from:
      _main in interp-test-83d3cd.o
  createInterpreterDSPFactoryFromString(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, char const**, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&), referenced from:
      _main in interp-test-83d3cd.o
      _main in interp-test-83d3cd.o
      dsp_aux::dsp_aux(char const*, char const*, int, char const**, char const*, int) in faust-dynamic-engine-e3328e.o
  writeInterpreterDSPFactoryToBitcodeFile(interpreter_dsp_factory*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&), referenced from:
      _main in interp-test-83d3cd.o
  readInterpreterDSPFactoryFromBitcodeFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&), referenced from:
      _main in interp-test-83d3cd.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

At this point, I throw the kitchen sink:

 % g++ -DINTERP_DSP=1 -std=c++11 -O3 interp-test.cpp ./include/faust/dsp/faust-dynamic-engine.cpp -I./include -L./lib -L`brew --prefix`/lib ./lib/libfaust.a ./lib/libfaustmachine.a ./lib/libOSCFaust.a ./lib/libHTTPDFaust.a -o interp-test
./include/faust/dsp/faust-dynamic-engine.cpp:156:17: warning: 7 enumeration values not handled in switch: 'kPortAudioRenderer', 'kRtAudioRenderer', 'kJackRenderer'... [-Wswitch]
        switch (renderer) {
                ^~~~~~~~
./include/faust/dsp/faust-dynamic-engine.cpp:156:17: note: add missing switch cases
        switch (renderer) {
                ^
1 warning generated.
ld: warning: object file (./lib/libfaust.a[51](export.cpp.o)) was built for newer 'macOS' version (13.6) than being linked (13.0)
ld: warning: object file (./lib/libfaust.a[127](lock_api.cpp.o)) was built for newer 'macOS' version (13.6) than being linked (13.0)
ld: warning: object file (./lib/libfaustmachine.a[3](interpreter_dsp_aux.cpp.o)) was built for newer 'macOS' version (13.6) than being linked (13.0)
ld: Undefined symbols:
  createInterpreterDSPFactoryFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, char const**, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&), referenced from:
      _main in interp-test-a67d6b.o
  createInterpreterDSPFactoryFromString(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, char const**, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&), referenced from:
      _main in interp-test-a67d6b.o
      _main in interp-test-a67d6b.o
      dsp_aux::dsp_aux(char const*, char const*, int, char const**, char const*, int) in faust-dynamic-engine-c0155e.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So clearly createInterpreterDSPFactoryFromFile and createInterpreterDSPFactoryFromString are not built using the make libsall option... how do I incorporate them into such a build?

sletz commented 9 months ago

The Interpreter is not built al all inmake liball. Have a look https://github.com/grame-cncm/faust/wiki/Building ?

Hacking https://github.com/grame-cncm/faust/blob/master-dev/build/backends/interp.cmake ?

shakfu commented 9 months ago

Thanks for the advice. I will look into this more closely.

shakfu commented 9 months ago

@sletz I figured it out by adding a target to the main faust/Makefile:

interp : updatesubmodules
    $(MAKE) -C $(BUILDLOCATION) cmake BACKENDS=interp.cmake TARGETS=interp.cmake
    $(MAKE) -C $(BUILDLOCATION)

then

make interp
PREFIX=`pwd`/prefix make install
cp tests/interp-tests/interp-test.cpp ./prefix/
cd prefix
g++ -DINTERP_DSP=1 -std=c++11 -O3 interp-test.cpp -I./include -L./lib -L`brew --prefix`/lib ./lib/libfaust.a -o interp-test

then

./interp-test --help
Libfaust version : 2.69.3
=============================
Test createInterpreterDSPFactoryFromFile
Cannot create factory : File Extension is not the one expected (.dsp expected)
shakfu commented 9 months ago

I would like to add some further info since I ended it with the following custom backend config which I called interp_plus.cmake so thatI could build the faust executable and set the path to the lib folder correct for both interp tests:

# this file may be used to select different backends
# it's always read by the default makefile target
# values are among: 
#    OFF       don't include the backend
#    COMPILER  embed the backend in the faust compiler
#    STATIC    embed the backend in the faust static library
#    DYNAMIC   embed the backend in the faust dynamic library
#    WASM      embed the backend in the faust wasm library

set ( C_BACKEND      STATIC DYNAMIC    CACHE STRING  "Include C backend" FORCE )
set ( CPP_BACKEND    STATIC DYNAMIC    CACHE STRING  "Include CPP backend" FORCE )
set ( CMAJOR_BACKEND OFF    CACHE STRING  "Include Cmajor backend" FORCE )
set ( CSHARP_BACKEND OFF    CACHE STRING  "Include CSharp backend" FORCE )
set ( DLANG_BACKEND  OFF    CACHE STRING  "Include Dlang backend" FORCE )
set ( FIR_BACKEND    OFF    CACHE STRING  "Include FIR backend" FORCE )
set ( INTERP_BACKEND OFF CACHE STRING  "Include Interpreter backend" FORCE )
set ( INTERP_COMP_BACKEND STATIC DYNAMIC CACHE STRING "Include Interpreter/Cmmpiler backend" FORCE )
set ( JAVA_BACKEND   OFF    CACHE STRING  "Include JAVA backend" FORCE )
set ( JAX_BACKEND    OFF    CACHE STRING  "Include JAX backend"  FORCE )
set ( JULIA_BACKEND  OFF    CACHE STRING  "Include Julia backend" FORCE )
set ( JSFX_BACKEND  OFF    CACHE STRING  "Include JSFX backend" FORCE )
set ( LLVM_BACKEND   OFF    CACHE STRING  "Include LLVM backend" FORCE )
set ( OLDCPP_BACKEND OFF    CACHE STRING  "Include old CPP backend" FORCE )
set ( RUST_BACKEND   OFF    CACHE STRING  "Include Rust backend" FORCE )
# Template is deactivated 
set ( TEMPLATE_BACKEND   OFF    CACHE STRING  "Include Template backend" FORCE )
set ( WASM_BACKEND   OFF    CACHE STRING  "Include WASM backend" FORCE )

and also a custom target, called interp_plus.cmake:

# this file may be used to select different target
# values are among ON or OFF 

set ( INCLUDE_EXECUTABLE  ON  CACHE STRING  "Include Faust compiler" FORCE )
set ( INCLUDE_STATIC      ON CACHE STRING  "Include static Faust library" FORCE )
set ( INCLUDE_DYNAMIC     ON CACHE STRING  "Include dynamic Faust library" FORCE )

set ( INCLUDE_OSC         OFF  CACHE STRING  "Include Faust OSC static library" FORCE )
set ( INCLUDE_HTTP        OFF  CACHE STRING  "Include Faust HTTPD static library" FORCE )

set ( INCLUDE_ITP         OFF  CACHE STRING  "Include Faust Machine library" FORCE )
set ( ITPDYNAMIC          OFF  CACHE STRING  "Include Faust Machine library" FORCE )

set ( OSCDYNAMIC          OFF CACHE STRING  "Include Faust OSC dynamic library" FORCE )
set ( HTTPDYNAMIC         OFF CACHE STRING  "Include Faust HTTP dynamic library" FORCE )

This was called in a custom target in the main Makefile as follows:

interp : updatesubmodules
    $(MAKE) -C $(BUILDLOCATION) cmake BACKENDS=interp_plus.cmake TARGETS=interp_plus.cmake
    $(MAKE) -C $(BUILDLOCATION)