Detecting Apple Silicon (vs. legacy Intel)

Ryan Schmidt ryandesign at
Sat Jan 1 07:01:59 UTC 2022

On Dec 31, 2021, at 11:36, Chris Jones wrote:
> On 31 Dec 2021, at 5:13 pm, Vincent Habchi wrote:
>> finally put my hands on my brand new MacBook Pro 14”! (Well, not really mine, rather my company’s, but let’s pretend…)
>> I was wondering if there is a simple scheme to detect on which type of architecture MacPorts is running. My problem here is that clang on M1 does not honour the -march flag and exits with an error.
> if {${os.arch} eq "arm"} {
>> }

If you were asking how to do this within a Portfile, yes, that's how you would do it. However, note that we don't want any Portfile to use -march flags, no matter what architecture, unless within a variant called "native", since -march flags enable features specific to some processor whereas we want to produce binaries that could run on any processor.

More information about the macports-dev mailing list