how to get bazel to build arm64 instead of x86_64 on an M3 Max

412 views
Skip to first unread message

Ronald Fenner

unread,
Dec 2, 2023, 12:00:34 AM12/2/23
to bazel-discuss
I'm having a problem where bazel wants to default to building my code as x86_64 on a M3 Max using xcode 15. I tried using --cpu:arm64 and arm64e but bazel didn't regonize those.

While the x86_64 build code will run one of the test apps I'm having a problem with anohter test app that links in a library that is missing some symbols posiibly cuase it was cross compiled and the symbols may be assembly related and were dropped during the cross compile. I'm waiting to hear on a solution to that and would like to get unstuck and use the arm64 builds instead.

Gunnar Wagenknecht

unread,
Dec 2, 2023, 8:12:25 AM12/2/23
to Ronald Fenner, bazel-discuss
On Dec 1, 2023, at 21:00, 'Ronald Fenner' via bazel-discuss <bazel-...@googlegroups.com> wrote:

I'm having a problem where bazel wants to default to building my code as x86_64 on a M3 Max using xcode 15. I tried using --cpu:arm64 and arm64e but bazel didn't regonize those.

That sounds like something triggers the process chain to go into Rosetta mode.

Check Terminal, Bash as well as Basilisk and Bazel and its JDK to be of the correct platform for Mac Silicon. Anything in the chain can trigger Rosetta. If you use a tools/bazel wrapper script, ensure its binary (eg., Python) is also of the correct platform. We added a check with `sysctl -in sysctl.proc_translated` to our tools/bazel wrapper script to detect broken environments early.

-Gunnar

-- 
Gunnar Wagenknecht
gun...@wagenknecht.org, http://guw.io/



Ronald Fenner

unread,
Dec 2, 2023, 1:09:00 PM12/2/23
to bazel-discuss
Ok adfter checking i relaized i had used the x86_64 installer instead of the arm64 one. Had missed that in the file when following the binary install instructions. 
Maybe a wrapper that could auto detect tje proper platform would be nice.

Reply all
Reply to author
Forward
0 new messages