breakfastquay / rubberband

Official mirror of Rubber Band Library, an audio time-stretching and pitch-shifting library.
http://breakfastquay.com/rubberband/
GNU General Public License v2.0
580 stars 93 forks source link

Cannot build on Apple Silicon #31

Closed tcjennings closed 3 years ago

tcjennings commented 3 years ago

Makefile.osx hardcodes an architecture and cpu options that are incompatible with Apple Silicon.

This patch is a starting point for arm builds: changing the arch and removing the sse optimizations. Whether a separate Makefile or conditional patch/generation of the existing Makefile.osx depends on the needs of the project.

diff --git a/Makefile.osx b/Makefile.osx
index 642533f..d39b044 100644
--- a/Makefile.osx
+++ b/Makefile.osx
@@ -2,8 +2,8 @@
 PREFIX         := /usr/local
 CXX            := clang++ -stdlib=libc++
 CC             := clang
-ARCHFLAGS      := -arch x86_64 -mmacosx-version-min=10.7
-OPTFLAGS       := -DNDEBUG -ffast-math -mfpmath=sse -msse -msse2 -O3 -ftree-vectorize
+ARCHFLAGS      := -arch arm -mmacosx-version-min=11.0
+OPTFLAGS       := -DNDEBUG -ffast-math -O3 -ftree-vectorize

 CXXFLAGS       := $(ARCHFLAGS) $(OPTFLAGS) -I. -Isrc -Irubberband -I/usr/local/include -DUSE_PTHREADS -DMALLOC_IS_ALIGNED -DHAVE_VDSP -DUSE_SPEEX -DNO_THREAD_CHECKS -DNO_TIMING
cannam commented 3 years ago

Thanks! I'll be reviewing this subject when I have access to the hardware in question, which I hope will be within the next couple of weeks. Happy to see suggestions for where to start, but I don't intend to commit anything until I've tested it myself (since I do actually expect to be able to do so soon).

fxcoudert commented 3 years ago
cannam commented 3 years ago

OK, thanks again - this should be working in the default branch. Just need to warn you that I've also renamed Makefile.osx to Makefile.macos (sorry).

There are now two Mac Makefiles. Makefile.macos just uses the native arch, whatever that is, and drops the arch-specific flags. Makefile.macos-universal builds both architectures in one (if supported by your SDK).

Note that I have kept the -mmacosx-version-min=10.7 flag in place because it is still valid for the Intel build, and it is simply ignored for the ARM build where this target isn't possible. I'm happy to listen to arguments why this may be a bad idea, though if possible I would prefer to ship a Makefile that targets the oldest supported OS version by default.

cannam commented 3 years ago

(reopened issue, didn't intend to close without waiting for feedback)