You can simply pass in the arches you want using the "arch" makefile variable:
make arch="x86_64 arm64"
For example:
danomatika@danomatika helloworld % make arch="x86_64 arm64" ++++ info: using Makefile.pdlibbuilder version 0.6.0 ++++ info: using Pd API /Applications/Pd-0.52-2.app/Contents/Resources/src/m_pd.h ++++ info: making target all in lib helloworld ++++ info: making helloworld.o in lib helloworld cc -DPD -I "/Applications/Pd-0.52-2.app/Contents/Resources/src" -DUNIX -DMACOSX -I /sw/include -Wall -Wextra -Wshadow -Winline -Wstrict-aliasing -O3 -ffast-math -funroll-loops -fomit-frame-pointer -arch x86_64 -arch arm64 -mmacosx-version-min=10.6 -o helloworld.o -c helloworld.c ++++ info: linking objects in helloworld.pd_darwin for lib helloworld cc -undefined suppress -flat_namespace -bundle -arch x86_64 -arch arm64 -mmacosx-version-min=10.6 -o helloworld.pd_darwin helloworld.o -lc ++++info: target all in lib helloworld completed
danomatika@danomatika helloworld % file helloworld.pd_darwin helloworld.pd_darwin: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64] helloworld.pd_darwin (for architecture x86_64): Mach-O 64-bit bundle x86_64 helloworld.pd_darwin (for architecture arm64): Mach-O 64-bit bundle arm64
As to which versions of macOS (that's the official name for some years now) to build on, I believe you can still build the i386 arch with Xcode on macOS 10.15, so judging from the following it may be Xcode 11 or 12: https://xcodereleases.com https://xcodereleases.com/. I think Alex Porres is using this set up, so maybe he can chime in with his combo of OS and Xcode. The irony is that you can't run the 32 bit arch on 10.15, but at least you can build for it. Xcode on macOS 11 (version after 10.15) only allows for building x64_64 and arm64.
I did add an "automatic" fat lib checker which determines which arch are available for the Xcode version but it's sitting in a PR right now. IN the end, I think I agree with IOhannes that it's maybe better to document and ask the user to set the required arch manually. It certainly keeps things simpler to maintain.
The readme should probably be updated with this info as these questions keep resurfacing.
On Jun 8, 2022, at 12:00 PM, pd-dev-request@lists.iem.at wrote:
Message: 1 Date: Wed, 8 Jun 2022 01:18:39 +0200 From: Thomas Mayer <thomas@residuum.org mailto:thomas@residuum.org> To: pd-dev <pd-dev@lists.iem.at mailto:pd-dev@lists.iem.at> Subject: [PD-dev] Compiling fat external binaries for Mac OS X Message-ID: <7fd6ada6-3f36-316b-9000-30e0cd64118a@residuum.org mailto:7fd6ada6-3f36-316b-9000-30e0cd64118a@residuum.org> Content-Type: text/plain; charset=UTF-8; format=flowed
Hi,
I am currently working on the last steps for releasing a new version of PuREST JSON.
My main concern is now building fat binaries for Mac OS X.
When I look at the list at the different versions for 0.52-2 at https://puredata.info/downloads/pure-data https://puredata.info/downloads/pure-data there is a version labeled "M1 and Intel/64bit". I guess, I should link to it.
Is there any environment variable I have to set for building building?
I am using the current master version of pd-lib-builder, and I do not see any reference to M1 in the block there: https://github.com/pure-data/pd-lib-builder/blob/e6cff665a3a30a967c72c382c6f... https://github.com/pure-data/pd-lib-builder/blob/e6cff665a3a30a967c72c382c6fe92bcdedd7b44/Makefile.pdlibbuilder#L506
Also, what should be in the filename for deken zips?
Any other version of Mac OS X that I should compile the external as well, since there are downloads for 32 and 64 bit Intel as well? Especially, because the 64 bit version is labeled as OS X 10.7 - 10.9.
The question about filename of deken zips applies to these as well.
Thanks, Thomas -- "As long as people kept worrying that the machines were taking over, they wouldn't notice what was really happening. Which was that the programmers were taking over." (Robert Anton Wilson - The Homing Pidgeons) http://www.residuum.org/ http://www.residuum.org/
-------- Dan Wilcox @danomatika http://twitter.com/danomatika danomatika.com http://danomatika.com/ robotcowboy.com http://robotcowboy.com/
In double-checking, posts like the following make me think that Xcode 9.4 is the last version which supports compiling for i386: https://developer.apple.com/forums/thread/108704 https://developer.apple.com/forums/thread/108704 This would make your 32 bit setup require macOS 10.14 + Xcode 9.4.
To clarify, I added Alex in CC. Alex: What is your current build setup (OS and Xcode version) for building fat libs with 32 bit Intel (i386) for distribution?
On Jun 8, 2022, at 8:04 PM, Dan Wilcox danomatika@gmail.com wrote:
As to which versions of macOS (that's the official name for some years now) to build on, I believe you can still build the i386 arch with Xcode on macOS 10.15, so judging from the following it may be Xcode 11 or 12: https://xcodereleases.com https://xcodereleases.com/. I think Alex Porres is using this set up, so maybe he can chime in with his combo of OS and Xcode. The irony is that you can't run the 32 bit arch on 10.15, but at least you can build for it. Xcode on macOS 11 (version after 10.15) only allows for building x64_64 and arm64.
-------- Dan Wilcox @danomatika http://twitter.com/danomatika danomatika.com http://danomatika.com/ robotcowboy.com http://robotcowboy.com/
On Wed, 2022-06-08 at 20:04 +0200, Dan Wilcox wrote:
You can simply pass in the arches you want using the "arch" makefile variable:
make arch="x86_64 arm64"
That's cool to know. In the case of purest_json, I believe it ships with other dependencies (libjson?) and if those come from homebrew, they're probably not fat. Is my assumption correct, that a fat binary would have to link to fat binary?
In the case for the mp3cast~ external, I went a different route. I built separate binaries for different archs and used different extensions so that they can be placed in the same package:
For M1:
make extension=d_arm64
For Intel:
make extension=d_amd64
I also took care to place local dependencies into folders named $arch, so that amd64 and arm64 libraries can co-exist in the same package.
Here is the Makefile and localdeps script: https://github.com/pd-externals/mp3cast
On a related note:
In the past, when I wanted to use purest_json from Deken on Ubuntu (can't recall the version), the package didn't ship with local dependencies, but was linked against system-provided binaries. However, my Ubuntu shipped an incompatible version of libjson, so I had to compile purest_json locally. It would be nice, if you could add the local dependencies _also_ to the Linux builds.
Roman