I have some experience developing plugins for VCV Rack on Windows. After recently purchasing an M1 Mac, I would like to be able to develop plugins on that machine as well.
For example, I would like to be able to build the Fundamental modules from source.
When I cd into the repo and run make, I get
clang: error: the clang compiler does not support '-march=nocona'
As far as I understand, this is because the $(CXX) commands in the makefile call g++, and g++ --version gives
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 Apple clang version 12.0.0 (clang-1200.0.32.29) Target: arm64-apple-darwin20.3.0 Thread model: posix
The compiler is targeting arm64, so obviously there will be problems, because Rack is an x86_64 program running through Rosetta2.
What can I change in the makefile to get clang to build x86_64 libraries rather than arm64?
@rsmus7@LarsBjerregaard Thank you both for your help. It was sufficient to set up a Rosetta terminal as per source1, and run arch -x86_64 make, and the plugin builds.
Something else I tried was using a separate x86 homebrew installation per this article, and installing gcc separate under this homebrew. For example the native homebrew is /usr/opt/homebrew and the x86 homebrew is /usr/local/homebrew.
I added the x86 homebrew to the path and changed CC and CXX to x86_64-apple-darwin20-gcc-10 and x86_64-apple-darwin20-g++-10 respectively, but when I try to build like this I get an error,
It was always my impression that “gcc” on the mac is just a front-end for clang that tries to make the command line options look the same. But maybe there is some “real” gcc? In any case the normal way of building VCV plugins on rack does (I’m pretty sure?) use the “built-in” gcc that just drives clang.
Not sure why this was so tricky to find last year, but searching again this year to see if I could develop VCV Rack modules on Apple M1 machines finally turned up this solution.
I am happily creating modules on M1 with my make targets wrapping the VCV Rack SDK make targets, e.g.:
include $(RACK_DIR)/plugin.mk
rebuild:
@arch -x86_64 $(MAKE) install