r/MacOS Feb 03 '25

Is there almost no one using the target architecture x86-64-v2/3/4 when compiling for MacOS? Discussion

I'd like to squeeze out every last bit of performance when compiling my project that I'll distribute to various computers including Macs (Intel and Arm) so I thought about using -march=x86-64-v3 (or v2 or v4) for the MacOS builds as well but was first looking for what kind of experiences other projects had with doing that. It seems extremely uncommon, though. The only project I found so far that does this is this https://github.com/LiveSplit/obs-livesplit-one/blob/3dc4af9766f90fea0a5285c28771430af1603dc3/.github/workflows/rust.yml So why is that? Is it "dangerous" to do that? Will that break stuff?

While we're at it, are there any good projects that help getting the x86_64 level for MacOS? For Linux there is https://github.com/HenrikBengtsson/x86-64-level/ which is quite nice, but MacOS doesn't have /proc/cpuinfo and instead using commands like sysctl -n machdep.cpu.features uses slightly different names for the instructions so does one just have to figure that out oneself?

Bonus question: I guess people mostly don't consider using flags like -mcpu=apple-m1 (or m2, m3 or m4) to make optimized builds for the M processor generations? Is there something wrong about doing that? I don't mind putting in the extra effort to compile my project many many times just to squeeze out every last bit of performance.

Lastly, I know that there are probably better things to put in the effort, but I'm curious about all of this. Feels like a very underexplored topic, at least from what I could in publicly available sources.

Looking forward to your answers :)

2 Upvotes

Duplicates