Cross-compiling from Mac to Linux Arm

303 views
Skip to first unread message

Igor Bukanov

unread,
Feb 13, 2023, 1:00:22 PM2/13/23
to Chromium-dev
Hi,

Is it possible on MacOS to cross-compile a Chromium Linux Arm64 build?

Regards, Igor 

Dirk Pranke

unread,
Feb 13, 2023, 3:04:51 PM2/13/23
to ibuk...@zscaler.com, Chromium-dev
Hi Igor,

Not out of the box, no, as far as I know.

I hacked on doing so two years ago and according to my CL description, I got pretty close to getting it working with a few steps outside of the normal build flow.

That might be useful to you as a starting point.

-- Dirk

--
--
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/604fe440-0404-414c-9ea2-36f54eeea226n%40chromium.org.

Dirk Pranke

unread,
Feb 13, 2023, 4:27:50 PM2/13/23
to Igor Bukanov, Chromium-dev
On Mon, Feb 13, 2023 at 12:18 PM Igor Bukanov <ibuk...@zscaler.com> wrote:
Thanks for the reference! I presume the change for third_party/wayland/ was to fix a bug as the assert should have targeted the target_host, not the source one. 

Either that or just not have the assert at all. Your suggestion is probably a bit better.

-- Dirk

Igor Bukanov

unread,
Feb 13, 2023, 4:53:52 PM2/13/23
to Chromium-dev, Dirk Pranke, Chromium-dev, ibuk...@zscaler.com
Thanks for the reference! I presume the change for third_party/wayland/ was to fix a bug as the assert should have targeted the target_host, not the source one. 

On Monday, February 13, 2023 at 9:04:51 PM UTC+1 Dirk Pranke wrote:

Igor Bukanov

unread,
Feb 14, 2023, 1:36:24 PM2/14/23
to Chromium-dev, Dirk Pranke, Chromium-dev, Igor Bukanov
Hi Dirk,

beside your adjusted patch to compile I had to remove almost all "checkout linux" conditions in DEPS file. It seems the conditions are there to save bandwidth under assumption that one cross-compiles Linux only from Linux. But given that .gclient explicitly specifies target_os = ['linux'] I suppose this a bug in gclient or DEPS definitions as the conditions should check for the target OS selection, not the checkout OS.

With that base_unittests compiles, but building the browser fails when linking V8 shared library with the linker complaining about undefined references. I suspect the fix for that is yet another trivial change, but the experience clearly shows that support for such cross-compilation is not there...

Regards, Igor 

Dirk Pranke

unread,
Feb 14, 2023, 3:22:15 PM2/14/23
to Igor Bukanov, Chromium-dev
Hi Igor,

I missed that you were trying to compile Linux ARM. That's probably a tougher deal, since we don't actually support Linux ARM in any configuration.

I'd be curious to see what you've ended up doing, if you felt like uploading a patch. If you set target_os in gclient, then checkout_linux should be true, but there are some comments in the DEPS file about a bug in that code. I'd have to look into it.

I also don't remember offhand which things might be needed for the host os as opposed to the target os, so there could be bugs there as well (since we don't target linux as a cross-compile anywhere).

-- Dirk

Dirk Pranke

unread,
Feb 15, 2023, 3:37:37 PM2/15/23
to Igor Bukanov, Chromium-dev
I'm not 100% sure I follow you. Are you going to run them in an x64 docker container, or an arm one?

Those compile errors kinda sorta look like what I'd expect for something where the platform wasn't supported (i.e., linux arm). But I'm not a v8 dev, so I could be wrong.

-- Dirk

On Wed, Feb 15, 2023 at 12:22 PM Igor Bukanov <ibuk...@zscaler.com> wrote:
Hi Dirk,

our use case is to run Chromium in a sort-off headless mode. In production Chromium builds run on Linux x64 servers. But of cause these days most developers have M1 Mac. As developing against in a cloud VM often is not convenient, we tried to investigate if it is possible to build Chromium on laptops. Since various VMs for M1 has a substantial overhead, an optimal situation will be to cross-compile under MacOS and run resulting binaries in a Linux docker container. But I guess much more work is necessary than few hours of hacking Chromium build to enable that.

I attach a patch that allowed to build at least unit tests. It is essentially your original change plus removal of conditions in DEPS.

When I tried to compile Chromium with it, I got errors:

FAILED: libv8.so libv8.so.TOC 

python3 "../../build/toolchain/gcc_solink_wrapper.py" --readelf="../../third_party/llvm-build/Release+Asserts/bin/llvm-readelf" --nm="nm"  --sofile="./libv8.so" --tocfile="./libv8.so.TOC" --output="./libv8.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-soname="libv8.so" -Werror -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,--color-diagnostics -Wl,--undefined-version -Wl,--no-call-graph-profile-sort --target=aarch64-linux-gnu -Wl,-mllvm,-enable-machine-outliner=never -no-canonical-prefixes -Wl,--gdb-index -rdynamic -Wl,-z,defs -Wl,--as-needed -nostdlib++ --sysroot=../../build/linux/debian_bullseye_arm64-sysroot --target=aarch64-unknown-linux -Wl,-rpath=\$ORIGIN -Wl,-O2 -Wl,--gc-sections -o "./libv8.so" @"./libv8.so.rsp"  

ld.lld: error: undefined symbol: Builtins_InterpreterEnterAtBytecode

>>> referenced by deoptimizer-cfi-builtins.cc:54 (../../v8/src/deoptimizer/deoptimizer-cfi-builtins.cc:54)

>>>               obj/v8/v8_snapshot/deoptimizer-cfi-builtins.o:(v8::internal::Deoptimizer::IsValidReturnAddress(unsigned long, v8::internal::Isolate*))

>>> referenced by deoptimizer-cfi-builtins.cc:54 (../../v8/src/deoptimizer/deoptimizer-cfi-builtins.cc:54)

>>>               obj/v8/v8_snapshot/deoptimizer-cfi-builtins.o:(v8::internal::Deoptimizer::IsValidReturnAddress(unsigned long, v8::internal::Isolate*))


ld.lld: error: undefined symbol: Builtins_InterpreterEnterAtNextBytecode

>>> referenced by deoptimizer-cfi-builtins.cc:54 (../../v8/src/deoptimizer/deoptimizer-cfi-builtins.cc:54)

>>>               obj/v8/v8_snapshot/deoptimizer-cfi-builtins.o:(v8::internal::Deoptimizer::IsValidReturnAddress(unsigned long, v8::internal::Isolate*))

>>> referenced by deoptimizer-cfi-builtins.cc:0 (../../v8/src/deoptimizer/deoptimizer-cfi-builtins.cc:0)

>>>               obj/v8/v8_snapshot/deoptimizer-cfi-builtins.o:(v8::internal::Deoptimizer::IsValidReturnAddress(unsigned long, v8::internal::Isolate*))


ld.lld: error: undefined symbol: Builtins_ContinueToCodeStubBuiltinWithResult

>>> referenced by deoptimizer-cfi-builtins.cc:0 (../../v8/src/deoptimizer/deoptimizer-cfi-builtins.cc:0)

>>>               obj/v8/v8_snapshot/deoptimizer-cfi-builtins.o:(v8::internal::Deoptimizer::IsValidReturnAddress(unsigned long, v8::internal::Isolate*))

>>> referenced by deoptimizer-cfi-builtins.cc:0 (../../v8/src/deoptimizer/deoptimizer-cfi-builtins.cc:0)

>>>               obj/v8/v8_snapshot/deoptimizer-cfi-builtins.o:(v8::internal::Deoptimizer::IsValidReturnAddress(unsigned long, v8::internal::Isolate*))


ld.lld: error: undefined symbol: Builtins_ContinueToCodeStubBuiltin

>>> referenced by deoptimizer-cfi-builtins.cc:0 (../../v8/src/deoptimizer/deoptimizer-cfi-builtins.cc:0)

>>>               obj/v8/v8_snapshot/deoptimizer-cfi-builtins.o:(v8::internal::Deoptimizer::IsValidReturnAddress(unsigned long, v8::internal::Isolate*))

>>> referenced by deoptimizer-cfi-builtins.cc:0 (../../v8/src/deoptimizer/deoptimizer-cfi-builtins.cc:0)

>>>               obj/v8/v8_snapshot/deoptimizer-cfi-builtins.o:(v8::internal::Deoptimizer::IsValidReturnAddress(unsigned long, v8::internal::Isolate*))

....



Dirk Pranke

unread,
Feb 15, 2023, 3:55:11 PM2/15/23
to Igor Bukanov, Chromium-dev
Okay, thanks.

As I said before, Linux ARM isn't a platform we support. So, you'd probably have to write a bunch of code to get it to work, cross-compile or no.

-- Dirk

On Wed, Feb 15, 2023 at 12:49 PM Igor Bukanov <ibuk...@zscaler.com> wrote:
Also, here for references the .gclient file:

solutions = [

  {

    "name": "src",

    "url": "https://chromium.googlesource.com/chromium/src.git",

    "managed": False,

    "custom_deps": {},

    "custom_vars": {},

  },

]

target_os = ['linux']


On Wed, Feb 15, 2023 at 9:48 PM Igor Bukanov <ibuk...@zscaler.com> wrote:
Now, the containers on Mac will be Linux Arm containers. They use generic software and one can get Arm64 version of them with very minimal efforts.

Igor Bukanov

unread,
Feb 16, 2023, 1:53:04 PM2/16/23
to Dirk Pranke, Chromium-dev
attempt_to_enable_mac_linux_arm_cross-compile.patch

Igor Bukanov

unread,
Feb 16, 2023, 1:53:17 PM2/16/23
to Dirk Pranke, Chromium-dev
Now, the containers on Mac will be Linux Arm containers. They use generic software and one can get Arm64 version of them with very minimal efforts.

Igor Bukanov

unread,
Feb 16, 2023, 1:53:18 PM2/16/23
to Dirk Pranke, Chromium-dev
Also, here for references the .gclient file:

solutions = [

  {

    "name": "src",

    "url": "https://chromium.googlesource.com/chromium/src.git",

    "managed": False,

    "custom_deps": {},

    "custom_vars": {},

  },

]

target_os = ['linux']


Reply all
Reply to author
Forward
0 new messages