sonic-pi-net / sonic-pi

Code. Music. Live.
https://sonic-pi.net
Other
10.74k stars 918 forks source link

OpenBSD port #3143

Open ibz opened 2 years ago

ibz commented 2 years ago

Will use this issue to track the progress of the OpenBSD port. Feel free to assign the issue to me.

First things first:

Nice to have:

samaaron commented 2 years ago

Super.

Here's the original question and introduction of this effort for reference: https://in-thread.sonic-pi.net/t/porting-sonic-pi-to-openbsd/6942

samaaron commented 2 years ago

Also, CCing @lilyinstarlight as she has been instrumental in improving the build process recently and is likely to be able to help here.

ibz commented 2 years ago

The issue I am currently facing is:

Consolidate compiler generated dependencies of target sonic-pi
[ 74%] Building CXX object gui/qt/CMakeFiles/sonic-pi.dir/mainwindow.cpp.o
[ 75%] Building CXX object gui/qt/CMakeFiles/sonic-pi.dir/utils/sonicpi_i18n.cpp.o
[ 75%] Building CXX object gui/qt/CMakeFiles/sonic-pi.dir/sonic-pi_autogen/EWIEGA46WW/qrc_help_files.cpp.o
[ 76%] Building CXX object gui/qt/CMakeFiles/sonic-pi.dir/sonic-pi_autogen/EWIEGA46WW/qrc_info_files.cpp.o
[ 76%] Linking CXX executable sonic-pi
ld: error: unable to find library -lrt
c++: error: linker command failed with exit code 1 (use -v to see invocation)

So it is trying to link to librt which does not exist on OpenBSD. I’ve been trying for hours to find where this dependency comes from, but I can’t seem to find it. I tried removing the dependency on flac from within aubio, but it doesn’t help. There's a few more places where librt is used in vcpkg but I think those dependencies would not be carried over to the sonic-pi project, right? So the question is... how does gui/qt/ end up depending on librt?

I searched for this flag all over the place, but honestly, it is also hard to grep (grepping for “-lrt” or “lrt” is not enough, since the linked libraries are sometimes passed without the -l flag, so I should grep for “rt” - but good luck with that in such a huge repo…)

lilyinstarlight commented 2 years ago

It's possibly coming from https://github.com/sonic-pi-net/sonic-pi/blob/31a823eb323f0fe5c12b4ec73f69d17d0bc148c7/app/gui/qt/CMakeLists.txt#L337-L340 but that should only be happening on Linux

Edit: It could also be propagated from the API library from https://github.com/sonic-pi-net/sonic-pi/blob/02b8c892b90f1ecbfe6e074a2f4f2cbe50b92e84/app/api/CMakeLists.txt#L98-L107 but again that should only be included on Linux

ibz commented 2 years ago

@lilyinstarlight Thanks! In fact I deleted these lines, just to be safe, and after that I also deleted the build/ directory, but the issue stays the same.

So either it was indeed coming from here but there is some more caching happening at some point, or it was not coming from here.

I suppose I could check this by fetching a fresh clone of the repo, applying all my changes and rebuilding? Unless you know where else cmake is caching things and how to start a fresh build?

EDIT: OK, that one I didn't catch. Let's see...

lilyinstarlight commented 2 years ago

CMake keeps everything in whatever directory you ran it in (i.e. the build directory) so that's probably not it then. If it's not that second location, I'll see if I can't track down where it's coming from when I get a chance. CMake also possibly has a way to show where executable target libs/dependencies are added

Also a BSD port sounds pretty cool!

ibz commented 2 years ago

@lilyinstarlight Unfortunately that was not it.

Let me know if you have any other ideas.

lilyinstarlight commented 2 years ago

I'll take a look when I get a chance! (probably within the next week) I don't have any *BSD installs laying around right now (well other than my home network router appliance) but I might manually trace through the deps to find something or install OpenBSD in a VM to debug

ibz commented 2 years ago

I managed to get a build by calling the linker manually.

In ./build/gui/qt/CMakeFiles/sonic-pi.dir/build.make, line 3901 says: cd /home/ibz/src/sonic-pi/app/build/gui/qt && $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/sonic-pi.dir/link.txt --verbose=$(VERBOSE)

So I edited link.txt to remove -lrt, ran this command manually, and it worked!

Now the question is who generates that link.txt file and how can I make it not include the -lrt flag?

ibz commented 2 years ago

After a lot more messing around to make sonic-pi actually run (not just build) - I got stuck again when trying to make tau start.

I am trying to start it manually using the following command (although letting Sonic Pi do it leads me to the same error):

./server/beam/tau/_build/prod/rel/tau/releases/0.1.0/elixir --boot ./server/beam/tau/_build/prod/rel/tau/releases/0.1.0/start

The result of this is:

{"init terminating in do_boot",{load_failed,[logger_simple_h,code,code_server,erl_parse,supervisor,proc_lib,lists,logger_config,logger_backend,logger_server,logger_filters,logger,kernel,heart,gen_server,gen_event,gen,file_server,file_io_server,filename,file,ets,error_logger,erl_lint,erl_eval,application_master,application_controller,application,error_handler]}}
init terminating in do_boot ({load_failed,[logger_simple_h,code,code_server,erl_parse,supervisor,proc_lib,lists,logger_config,logger_backend,logger_server,logger_filters,logger,kernel,heart,gen_server

Crash dump is being written to: erl_crash.dump...done

Any suggestions are very welcome. I am a noob with Elixir...

NitroNils commented 1 year ago

I would love to see this process progress. Sorry I can't help other than testing on OpenBSD 🐡