building for arm64 on alpine (musl)

335 views
Skip to first unread message

Jeroen Ooms

unread,
Aug 1, 2022, 5:06:20 AM8/1/22
to v8-dev
I maintain V8 bindings for the R programming language, for which we provide static v8 libraries for the most common distros, including one for alpine linux, and an arm64 build  cross compiled on Debian. The builds are dockerized and automated in ci: https://github.com/jeroen/build-v8-static

Now a user has requested an arm64 binary for alpine, but I am having a hard time making this work. Afaict, alpine has no cross compilers. So I tried to build it natively on arm64 hardware (docker on m1) but the build fails with:

 Assertion failed.
  assert(v8_snapshot_toolchain != "",\n^-----\nDo not know how to build a snapshot for //build/toolchain/linux:clang_x64 on linux arm64
  See //BUILD.gn:17:1: whence it was imported.

I suspect part of the problem may be that uname reports aarch64 instead of arm64? 

Leszek Swirski

unread,
Aug 1, 2022, 5:35:03 AM8/1/22
to v8-...@googlegroups.com
Hi Jeroen,

That sounds plausible, could you share your args.gn file? You may be able to fix this by setting your target_cpu there.

- Leszek

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/8bc1851f-6bab-47c9-a814-61ddc5091730n%40googlegroups.com.

Jakob Kummerow

unread,
Aug 1, 2022, 6:09:59 AM8/1/22
to v8-dev
https://docs.google.com/document/d/1u-HAFfjWIH3WY3xajuGxGii-lWi1rpf16hVmB-mRdTA/edit# contains my findings about building V8 on Linux-arm64 when I tried it last year. I don't remember whether I saw the exact same assertion failure. https://chromium-review.googlesource.com/c/v8/v8/+/2743889 should have taught gm.py to do the right thing automatically; if you're not using gm.py you may want to replicate what it does.

Jeroen Ooms

unread,
Aug 2, 2022, 6:21:16 AM8/2/22
to v8-...@googlegroups.com
On Mon, Aug 1, 2022 at 11:35 AM Leszek Swirski <les...@chromium.org> wrote:
>
> Hi Jeroen,
>
> That sounds plausible, could you share your args.gn file? You may be able to fix this by setting your target_cpu there.

I don't think we use an args.gn: we use this script, but then I
replaced x64 with arm64:
https://github.com/jeroen/build-v8-static/blob/master/alpine/Dockerfile
> You received this message because you are subscribed to a topic in the Google Groups "v8-dev" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-dev/B_RBMDV2FbY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to v8-dev+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAGRskv8dPEGKU0JR3LputGUEc9JfOqtvZui2fmtT_-o%2Bz%3DfJTg%40mail.gmail.com.

Jeroen Ooms

unread,
Aug 2, 2022, 6:38:11 AM8/2/22
to v8-...@googlegroups.com
On Mon, Aug 1, 2022 at 11:35 AM Leszek Swirski <les...@chromium.org> wrote:
>
> Hi Jeroen,
>
> That sounds plausible, could you share your args.gn file? You may be able to fix this by setting your target_cpu there.

Ah, I do notice that args.gn file that is autogenerated (via
tools/mb/mb.py I think) indeed seems to contain target_cpu = "x64"
even though we pass an argument target_cpu="arm64" to
tools/dev/v8gen.py in the build script. But
out.gn/arm64.release/args.gn contains this:

dcheck_always_on = false
is_debug = false
target_cpu = "x64"
v8_target_cpu = "arm64"

Where/when should we create the custom args.gn file to override this?
Currently we define all options as command line args:
https://github.com/jeroen/build-v8-static/blob/master/alpine/Dockerfile#L46-L77
I tried creating a custom args.gn in the build root, but that did not do much.
> You received this message because you are subscribed to a topic in the Google Groups "v8-dev" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-dev/B_RBMDV2FbY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to v8-dev+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAGRskv8dPEGKU0JR3LputGUEc9JfOqtvZui2fmtT_-o%2Bz%3DfJTg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages