SoundScapeRenderer/ssr

Compiling the Ssr Flext Pd Externals on macos

brandflake11 opened this issue · 11 comments

I am back again to get these pd externals compiled on macos. I have flext installed where it defaults to on macos (10.13.6), and I am having an issue that I didn't see on Linux:

bash-3.2$ make FLEXTPATH="/usr/local/include/flext" 
NAME='ssr_binaural~' MAIN_SOURCE='ssr_binaural.cpp' /usr/local/include/flext/build.sh pd gcc
/Library/Developer/CommandLineTools/usr/bin/make -f /usr/local/include/flext/buildsys/gnumake-sub.mak  PLATFORM=mac RTSYS=pd COMPILER=gcc BUILDPATH=/usr/local/include/flext/buildsys/ PKGINFO=package.txt BUILDCLASS=ext TARGETMODE=release TARGETTYPE=single _build_
/usr/local/include/flext/buildsys/mac/gnumake-gcc-targets.inc:22: warning: overriding commands for target `pd-darwin/release-single'
/usr/local/include/flext/buildsys/mac/gnumake-gcc-targets.inc:18: warning: ignoring old commands for target `pd-darwin/release-single'
mkdir -p pd-darwin/release-single
mkdir -p pd-darwin/release-single/
c++ -c -ffast-math -mmacosx-version-min=10.6  -O3 -mtune=native  -DNDEBUG -DFLEXT_SYS=2 -DPD -I../apf -I../src -I../gml/include `pkg-config --cflags libxml-2.0` -I/Applications/Pd-0.50-2.app/Contents/Resources/src -I/Applications/Pd-0.50-2.app/Contents/Resources/include -I/Applications/Pd-0.50-2.app/Contents/Resources/include/pd -I/usr/local/include/flext /usr/local/include/flext/flext.h -o pd-darwin/release-single/flext.h.gch
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
mkdir -p ./
c++ -c -ffast-math -mmacosx-version-min=10.6  -O3 -mtune=native  -std=c++17 -DENABLE_SOFA -fvisibility-inlines-hidden -arch x86_64    -DNDEBUG -DFLEXT_SYS=2 -DPD -I pd-darwin/release-single -I../apf -I../src -I../gml/include `pkg-config --cflags libxml-2.0` -I/Applications/Pd-0.50-2.app/Contents/Resources/src -I/Applications/Pd-0.50-2.app/Contents/Resources/include -I/Applications/Pd-0.50-2.app/Contents/Resources/include/pd -I/usr/local/include/flext ssr_binaural.cpp -o pd-darwin/release-single/ssr_binaural.opp_x86_64
In file included from ssr_binaural.cpp:29:
In file included from ./ssr_flext.h:36:
In file included from /usr/local/include/flext/flext.h:60:
In file included from /usr/local/include/flext/flclass.h:18:
In file included from /usr/local/include/flext/flbase.h:19:
/usr/local/include/flext/flsupport.h:134:34: error: ISO C++17 does not allow dynamic
      exception specifications [-Wdynamic-exception-spec]
void *operator new(size_t bytes) NEWTHROW;
                                 ^~~~~~~~
/usr/local/include/flext/flsupport.h:126:18: note: expanded from macro 'NEWTHROW'
#define NEWTHROW throw(std::bad_alloc)
                 ^~~~~~~~~~~~~~~~~~~~~
/usr/local/include/flext/flsupport.h:134:34: note: use 'noexcept(false)' instead
void *operator new(size_t bytes) NEWTHROW;
                                 ^~~~~~~~
                                 noexcept(false)
/usr/local/include/flext/flsupport.h:126:18: note: expanded from macro 'NEWTHROW'
#define NEWTHROW throw(std::bad_alloc)
                 ^
/usr/local/include/flext/flsupport.h:137:36: error: ISO C++17 does not allow dynamic
      exception specifications [-Wdynamic-exception-spec]
void *operator new[](size_t bytes) NEWTHROW;
                                   ^~~~~~~~
/usr/local/include/flext/flsupport.h:126:18: note: expanded from macro 'NEWTHROW'
#define NEWTHROW throw(std::bad_alloc)
                 ^~~~~~~~~~~~~~~~~~~~~
/usr/local/include/flext/flsupport.h:137:36: note: use 'noexcept(false)' instead
void *operator new[](size_t bytes) NEWTHROW;
                                   ^~~~~~~~
                                   noexcept(false)
/usr/local/include/flext/flsupport.h:126:18: note: expanded from macro 'NEWTHROW'
#define NEWTHROW throw(std::bad_alloc)
                 ^
In file included from ssr_binaural.cpp:29:
In file included from ./ssr_flext.h:51:
In file included from ../apf/apf/pointer_policy.h:34:
../apf/apf/parameter_map.h:72:47: error: no member named 'forward' in namespace 'std'
    : std::map<std::string, std::string>(std::forward<Args>(args)...)
                                         ~~~~~^
../apf/apf/parameter_map.h:72:55: error: 'Args' does not refer to a value
    : std::map<std::string, std::string>(std::forward<Args>(args)...)
                                                      ^
../apf/apf/parameter_map.h:70:24: note: declared here
  template<typename... Args>
                       ^
In file included from ssr_binaural.cpp:29:
In file included from ./ssr_flext.h:51:
In file included from ../apf/apf/pointer_policy.h:35:
../apf/apf/iterator.h:35:10: fatal error: 'type_traits' file not found
#include <type_traits>  // for std::remove_reference, std::result_of
         ^~~~~~~~~~~~~
5 errors generated.
make[2]: *** [pd-darwin/release-single/ssr_binaural.opp_x86_64] Error 1
make[1]: *** [build-release-single] Error 2
make: *** [ssr_binaural_pd] Error 2

Any help would be amazing!

Which Xcode version are you using?

I ran gcc --version and this is what it outputs:

bash-3.2$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I am using the xcode CommandLineTools that comes with macos 10.13.6. I can't figure out a good way to show what version of xcode that is. Please let me know if you need more info and I can do more digging.

Based on the error messages above, it looks like the version of the C++ compiler (and/or the standard library) is too old.

If there is a way to upgrade Xcode, you should try to do that.

We are using macOS 10.13 with Xcode10.1 on Travis-CI, so these versions do actually work:

ssr/.travis.yml

Lines 113 to 115 in 844a995

- name: macOS 10.13 with Xcode10.1/Clang
os: osx
osx_image: xcode10.1

Here's a recent log file (without errors): https://travis-ci.org/github/SoundScapeRenderer/ssr/jobs/697190854

Here's an excerpt with a few version numbers:

$ g++ --version
Configured with: --prefix=/Applications/Xcode-10.1.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode-10.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

It looks very similar to your versions above, but the compiler version is newer, so maybe that's making the difference?

Thank you, I will look into updating xcode and see what happens.

EDIT: I am not sure if you want to do this, but would you be able to send me a build of the pd externals for macos?

I might be necessary that you upgrade your macOS as newer xcode versions tend to be available only on new macOS versions.

I'll look into compiling the externals for you shortly.

I've created #206, which may or may not help with the std::forward problem.
It won't help with the type_traits thing, though.

This (temporary!) branch might help with the "dynamic exception specifications": https://github.com/mgeier/flext/tree/mac-fixes
This has been inspired by two other forks: https://github.com/ahihi/flext and https://github.com/SopiMlab/flext (which you can also try, if you want).

I've tried to create the externals with Github Actions, see #207.
I have no clue if those binaries work at all, but you can download them from there: https://github.com/mgeier/ssr/actions/runs/136504305

Do they work?

OK, the "dynamic exception specifications" thing is fixed in flext's master branch, see grrrr/flext#42.

Here's a new batch of compiled externals: https://github.com/mgeier/ssr/actions/runs/136957309

Thank you very much for the compiled externals. I have yet to be able to try them fully, but will keep you posted. I will also try to build them on my own machine, so thank you for your help.

In the meantime I've tried the pre-compiled externals on Linux, and I think I have bad news:

Those externals are dynamically linked to a few libraries, which means they are most likely broken as soon as they are copied to a different system.

I'll still have to find out how to compile "static" externals with flext.
If anybody has an idea, please let me know!

I've just created a new WIP PR which builds the externals on CI: #255.

@brandflake11 If you have some time, it would be great if you could test the macOS externals from there.

mgeier commented

The externals are now available from within Pd using its built-in package manager. Just go to "Help" -> "Find externals" and search for "ssr". See also https://ssr.readthedocs.io/en/0.6.1/use-cases.html#ssr-in-pure-data.

Building them locally should also work, see https://github.com/SoundScapeRenderer/ssr/tree/master/flext.