-
Notifications
You must be signed in to change notification settings - Fork 757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use fftw in supernova on macos #4583
Use fftw in supernova on macos #4583
Conversation
README_MACOS.md
Outdated
@@ -72,7 +72,9 @@ Build instructions | |||
cd build | |||
cmake -G Xcode -DCMAKE_PREFIX_PATH=`brew --prefix qt5` .. | |||
# or, if you want to build with supernova: | |||
export FFTW3_DIR=`brew --prefix fftw-sc` # indicate where our custom FFTW is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively, we could add /usr/local/opt/fftw-sc
to search paths in cmake_modules/FindFFTW3f.cmake
I'm not sure how to set up travis... I'd appreciate any help with that. |
travis error seems related to linking with fftw. Perhaps linking should be updated in cmake? |
server/scsynth/CMakeLists.txt
Outdated
@@ -193,7 +193,7 @@ if (LIBSCSYNTH) | |||
set_property(TARGET libscsynth PROPERTY SOVERSION 1) | |||
endif() | |||
|
|||
if (FFTW3F_FOUND) | |||
if (FFTW3F_FOUND AND NOT APPLE) | |||
target_include_directories(libscsynth PUBLIC ${FFTW3F_INCLUDE_DIR}) | |||
target_link_libraries(libscsynth ${FFTW3F_LIBRARY}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be added in APPLE and supernova for linking to succed!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For scsynth we want to use vDSP with Apple by default, not FFTW. But I agree that it seems that now it's not possible to use FFTW if one wishes to do so...
Supernova seems to have this declaration, am I seeing this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was confused with the linking error
"_rffts", referenced from:
scfft_dofft(scfft*) in libsupernova.a(SC_fftlib.o)
"_riffts", referenced from:
scfft_doifft(scfft*) in libsupernova.a(SC_fftlib.o)
which seems related to https://github.com/supercollider/supercollider/blob/develop/common/SC_fftlib.cpp#L412
meaning that SC_FFT_GREEN is defined (and it should not)
The only cause for this seems to be FFTW is not found!!
supernova/CMakeLists.txt has merge conflicts so it is not working as expected!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks for the pointers @sonoro1234 ! Very much appreciated. I'll look into this...
hi marcin, where are we at with this? |
Good question.
Option 1 seems more feasible, but it looks quite messy (CMake and linking-wise) to use one FFT library in supernova and another everywhere else. Ideas? |
just looking this over now. @dyfer i know we discussed this before, but remind me what is wrong with using the FFTW library supplied by homebrew right now? (https://formulae.brew.sh/formula/fftw) i think we can definitely go ahead with this PR, or at least this general approach for fixing the issue, but i can't review this further until that's addressed. |
Great question, I had to dig back in as I completely forgot what the problem is.
cmake --build . --target install --config RelWithDebInfo
# ...
-- executable file 5: /Volumes/data/Dokumenty/src/supercollider/build/Install/SuperCollider/SuperCollider.app/Contents/Resources/supernova
-- verified='0'
-- info='external prerequisites found:
f='/Volumes/data/Dokumenty/src/supercollider/build/Install/SuperCollider/SuperCollider.app/Contents/Resources/supernova'
external_prereqs='/usr/local/lib/gcc/9/libgcc_s.1.dylib'
I have a feeling I should mention these^^ somewhere for future reference. Where would be a good place?
sounds good, I'll keep working on this |
cb6a9b4
to
ea652be
Compare
All right, so this seems to build fine now. I moved FFT definitions from I think now the next steps are:
EDIT: one outstanding question I have is whether my handling of custom fftw path is best: export FFTW3_DIR=`brew --prefix fftw-sc` vs adding |
few more thoughts on fftw build:
|
Following up a discussion on a dev call, @brianlheim suggested that using regular homebrew-provided ffftw library and fixing linking would be better. I briefly looked at this again, and with my very basic understanding of linking I have a question: are we sure that we need to have |
so, having taken some time to investigate this more, i strongly feel the self-hosted repository is unnecessary, and that we can use the one from homebrew. specifically, we can use the shared library, which is also used on linux and possibly Windows (i'm too confused by that process to know for sure). i apologize for typing without thinking, and also for the wasted effort and inconvenience that may have caused you @dyfer. also, it should be trivial to have nested dependencies like i say "should" because this particular case (
i tried to get macdeployqt to do the right thing here, for instance by adding diff --git a/editors/sc-ide/CMakeLists.txt b/editors/sc-ide/CMakeLists.txt
index 6be0447fd..04d482eac 100644
--- a/editors/sc-ide/CMakeLists.txt
+++ b/editors/sc-ide/CMakeLists.txt
@@ -476,20 +476,29 @@ if(APPLE OR WIN32)
# only the IDE executable is scanned normally, so force scanning of sclang as well
# to get QtWebEngine, libsndfile, and other libs. also force scanning of QtWebEngineProcess
# because macdeployqt is a fickle beast.
+ set(CONTENTS_DIR ${CMAKE_INSTALL_PREFIX}/SuperCollider/SuperCollider.app/Contents)
set(DEPLOY_CMD "\"${DEPLOY_PROG}\"
\"${CMAKE_INSTALL_PREFIX}/SuperCollider/SuperCollider.app\"
-verbose=1
- -executable=${CMAKE_INSTALL_PREFIX}/SuperCollider/SuperCollider.app/Contents/MacOS/sclang
- -executable=${CMAKE_INSTALL_PREFIX}/SuperCollider/SuperCollider.app/Contents/Resources/scsynth
- -executable=${CMAKE_INSTALL_PREFIX}/SuperCollider/SuperCollider.app/Contents/Resources/supernova
- -executable=${CMAKE_INSTALL_PREFIX}/SuperCollider/SuperCollider.app/Contents/Resources/plugins/DiskIO_UGens.scx
- -executable=${CMAKE_INSTALL_PREFIX}/SuperCollider/SuperCollider.app/Contents/Resources/plugins/DiskIO_UGens_supernova.scx
- -executable=${CMAKE_INSTALL_PREFIX}/SuperCollider/SuperCollider.app/Contents/Frameworks/QtWebEngineCore.framework/Versions/5/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
+ -executable=${CONTENTS_DIR}/MacOS/sclang
+ -executable=${CONTENTS_DIR}/Resources/scsynth
+ -executable=${CONTENTS_DIR}/Resources/supernova
+ -executable=${CONTENTS_DIR}/Resources/plugins/DiskIO_UGens.scx
+ -executable=${CONTENTS_DIR}/Resources/plugins/DiskIO_UGens_supernova.scx
+ -executable=${CONTENTS_DIR}/Frameworks/QtWebEngineCore.framework/Versions/5/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
")
- set(VERIFY_CMD "include(BundleUtilities)
+ set(VERIFY_CMD "include(BundleUtilities)")
+ if(SUPERNOVA)
+ # For supernova, libfftw3f.3.dylib has a further dependency (libgcc_s) which is copied in,
+ # but libfftw3f is not fixed up automatically when supernova is deployed.
+ string(APPEND VERIFY_CMD "
+ message(STATUS \"Fixing up bad path in libfftw3f.3.dylib manually due to faulty logic in macdeployqt\")
+ execute_process(COMMAND install_name_tool -change /usr/local/lib/gcc/9/libgcc_s.1.dylib
+ @loader_path/libgcc_s.1.dylib ${CONTENTS_DIR}/Frameworks/libfftw3f.3.dylib)")
+ endif()
+ string(APPEND VERIFY_CMD "
message(STATUS \"Verifying app\")
- verify_app(\"${CMAKE_INSTALL_PREFIX}/SuperCollider/SuperCollider.app\")
- ")
+ verify_app(\"${CMAKE_INSTALL_PREFIX}/SuperCollider/SuperCollider.app\")")
else() # WIN32
find_program(DEPLOY_PROG windeployqt PATHS ${CMAKE_PREFIX_PATH})
set(DEPLOY_CMD "\"${DEPLOY_PROG}\" with this change, i am able to successfully deploy the bundle from scratch. it's a bit more low level than i'd like to be but so long as people are getting FFTW from homebrew it should work. and if they're not, then hopefully this path/symlinks issue is not a problem in the first place -- a library dependency living in FWIW @dyfer , FFTW3 from homebrew most definitely provides static versions of all library variants:
perhaps you weren't searching for it correctly when you tried before? |
Thank you so much @brianlheim for investigating this! And no worries about sending me down the static lib chase, I've learned some things.
Great! questions:
Thanks for pointing it out. I think I was confused with the --enable-shared build option in the formula. PS I hope you don't mind I edited your comment to make the diff blocks display properly (missing empty line after |
yes, simulataneously removing all the things that have been added to work around not using homebrew FFTW
more or less by definition, the
thanks. not a problem at all, i'm very OK with editing comments if it's just to fix formatting. |
I think this works now. Notes:
EDIT: I rebased this PR to include changes from #4764. I also used a more streamlined check for the presence of FFTW in the macdeployqt section of CMakeLists. This is ready for (final?) review. |
92bcaf1
to
b1c6c40
Compare
macOS: use FFTW in supernova
add FFTW debug posting
b1c6c40
to
8eed3b7
Compare
# For supernova, libfftw3f.3.dylib has a further dependency (libgcc_s) which is copied in, | ||
# but libfftw3f is not fixed up automatically when supernova is deployed. | ||
string(APPEND VERIFY_CMD " | ||
message(STATUS \"Fixing up bad path in libfftw3f.3.dylib manually due to faulty logic in macdeployqt\") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was going to ask why you're invoking install_name_tool directly... i forgot about this, bleh
@@ -140,6 +160,7 @@ endif() | |||
if (FFTW3F_FOUND) | |||
target_include_directories(libsupernova PUBLIC ${FFTW3F_INCLUDE_DIR}) | |||
target_link_libraries(libsupernova ${FFTW3F_LIBRARY}) | |||
set_property(TARGET libsupernova PROPERTY SUPERNOVA_FFTW ON) # for fixing linking in macdeployqt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a fantastic solution actually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, thanks!!
Purpose and Motivation
In the process of trying to find solutions to #4289, it was suggested to use the
FFTW
library on macOS for supernova.This PR adds build instructions for including FFTW in supercollider built on macOS (for supernova only; scsynth still uses vDSP).
In order to provide static FFTW I am using a custom homebrew formula. This formula is temporarily hosted on my github, but if we decide to accept this PR, it should be moved to a more permanent place (and appropriate portions of this PR should be updated).EDIT: This uses a regular FFTW from homebrew. Thanks to @brianlheim for figuring out how to fix linking with it.
Types of changes
To-do list