Cross-compile for Linux on macOS ARM?

288 views
Skip to first unread message

Jason Han

unread,
Jul 5, 2023, 5:47:24 AM7/5/23
to Chromium-dev
Hi, has anyone successfully cross-compiled Chromium for Linux on an OS that isn't Linux? I made attempts to do this on macOS but I hit some roadblocks. This doesn't seem to be officially supported by the Chromium project. Thanks!

Erik Staab

unread,
Jul 6, 2023, 6:39:49 PM7/6/23
to jasone...@gmail.com, Chromium-dev
Hi Jason,

Can you share more about what roadblocks you hit? What errors did you get and what do you have in your .gclient file and in your args.gn file?

Thanks,
Erik

On Wed, Jul 5, 2023 at 2:47 AM Jason Han <jasone...@gmail.com> wrote:
Hi, has anyone successfully cross-compiled Chromium for Linux on an OS that isn't Linux? I made attempts to do this on macOS but I hit some roadblocks. This doesn't seem to be officially supported by the Chromium project. Thanks!

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/410d07e3-17d0-426f-b1f6-b64481fa6568n%40chromium.org.

Jason Han

unread,
Jul 7, 2023, 12:03:59 AM7/7/23
to Chromium-dev, Erik Staab, Chromium-dev, jasone...@gmail.com
Hi Erik,

Sure! I didn't save the exact error message, but I know GN hit the assert on line 9 in third_party/wayland/BUILD.gn. The line is "assert(is_linux || is_chromeos)".

Then, I tried out a hack where I set "is_linux" to true and "is_mac"/"is_apple" to false and GN was actually able to generate targets. However, running autoninja resulted in a lexing error. I took a look at the generated Ninja file and it contained garbage output, and that's as far as I got.

I've attached my args.gn file here! I successfully used a similar one to build macOS Chromium so I believe the args are okay.

Best,
Jason

args.gn

Dirk Pranke

unread,
Jul 7, 2023, 3:11:43 PM7/7/23
to jasone...@gmail.com, Chromium-dev, Erik Staab
I would not expect a cross-compile from Mac to Linux to work out of the box. I hacked together a patch at one point that worked, but that was two years ago so it probably needs more work now.

However, your build is targeting an arm64 mac build, which isn't supported and I have no idea if it works at all, so I would expect you to hit more issues there. You also have an unusual bunch of flags set; where did you get all of them from?

-- Dirk

Jason Han

unread,
Jul 8, 2023, 5:52:47 AM7/8/23
to Chromium-dev, Dirk Pranke, Chromium-dev, Erik Staab, jasone...@gmail.com
Hi Dirk,

Long story short, most of those flags were from the Thorium browser. Chromium kept crashing in debug and release mode, making it hard to develop, and I couldn't figure out why. I soon figured out that "is_official_build" is all I needed for a performant, non-crash prone build. The rest of the flags are pretty unnecessary and are really there because I was too lazy to spend 3-4 hours recompiling. For this issue, I'm pretty sure you can ignore them though.

Thanks for linking your old patch! I'll try to use it as a reference. When you say arm64 mac builds aren't supported, do you mean cross-compiling arm64 Linux from arm64 mac, or compiling natively for arm64 mac? If it's the latter, I actually got that to work without doing anything special and just following these docs.

Best,
Jason

Dirk Pranke

unread,
Jul 8, 2023, 11:21:17 AM7/8/23
to Jason Han, Chromium-dev, Erik Staab
Oh, sorry, that was a typo in my email. I meant to say "arm64 linux build, which isn't supported", i.e., the arm64 linux target. Arm64 mac works fine and is supported (both as target and host).

-- Dirk
Reply all
Reply to author
Forward
0 new messages