Re:ARM MacBook vs. Intel MacBook: A SIMD Benchmark
by bacon_blood on Sunday December 13, 2020 @04:06PM
(#25410278)
Both x86 and arm clang can output for the other architecture, or universal.
Pass `-arch arm64` not `-march`
You can also `clang -arch x86_64 -arch arm64` to build for both at once.
You can even go a step further and run your clang as native from bazel, via `arch -arm64 clang`.
Put it all together and you have: `arch -arm64 clang -arch x86_64 -arch arm64`.
It may seem like I'm joking but I'm not.
Re:ARM MacBook vs. Intel MacBook: A SIMD Benchmark
by shepmaster on Sunday December 13, 2020 @04:11PM
(#25410322)
Related:
Why does my native application compiled on Apple Silicon sometimes build as arm64 and sometimes build as x86_64?
Why does my native arm64 application built using an x86_64 build system fail to be code signed unless I remove the previous executable?
[1] https://stackoverflow.com/questions/64830635/why-does-my-nat...
[2] https://stackoverflow.com/questions/64830671/why-does-my-nat...
Re:ARM MacBook vs. Intel MacBook: A SIMD Benchmark
by haberman on Sunday December 13, 2020 @04:51PM
(#25410696)
Thanks for the tips. I'm unable to replicate my previous experiment re: -arch. When I compile a wrapper program that does an exec() of clang, it is able to build arm64 or x86_64 even if the wrapper is built as x86_64.
The "arch" command is handy, thanks for that.
Re:ARM MacBook vs. Intel MacBook: A SIMD Benchmark
by erwincoumans on Sunday December 13, 2020 @06:49PM
(#25411706)
You can build bazel for arm M1, here is my binary
https://github.com/erwincoumans/bazel/releases/tag/bazel-3.7...
In my case I was building using Bazel. Bazel was running under Rosetta because they don't release a darwin_arm64 build yet. I didn't realize the resulting code was also built for x86-64.
I tried explicitly passing -march but the compiler rejected this, saying it was an unknown architecture. After some experimentation, it appears that when you exec clang from a Rosetta binary it puts it in a mode where it only knows how to build x86.