[PD-dev] Compiling fat external binaries for Mac OS X

Dan Wilcox danomatika at gmail.com
Wed Jun 8 20:04:23 CEST 2022


You can simply pass in the arches you want using the "arch" makefile variable:

make arch="x86_64 arm64"

For example:

danomatika at 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 at 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 at lists.iem.at wrote:
> 
> Message: 1
> Date: Wed, 8 Jun 2022 01:18:39 +0200
> From: Thomas Mayer <thomas at residuum.org <mailto:thomas at residuum.org>>
> To: pd-dev <pd-dev at lists.iem.at <mailto:pd-dev at lists.iem.at>>
> Subject: [PD-dev] Compiling fat external binaries for Mac OS X
> Message-ID: <7fd6ada6-3f36-316b-9000-30e0cd64118a at residuum.org <mailto:7fd6ada6-3f36-316b-9000-30e0cd64118a at 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/e6cff665a3a30a967c72c382c6fe92bcdedd7b44/Makefile.pdlibbuilder#L506 <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/>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20220608/7fcf84b4/attachment-0001.htm>


More information about the Pd-dev mailing list