v8go icon indicating copy to clipboard operation
v8go copied to clipboard

resolves #170 build v8go for musl libc

Open ggrossetie opened this issue 3 years ago • 7 comments

What I Did

  • create a new workflow to build GN on Alpine (build dependency of v8)
    • it will automatically create a pull request
    • if you don't trust the compiled file available at deps/alpine_x84_64/gn, you can run the workflow again to replace this file
  • add a new workflow to build v8 on Alpine
    • get v8 dependencies from the GitHub runner (ubuntu-20.04) because the script does not work on Alpine
    • use Docker to build v8 on Alpine
    • copy files from the Docker container and create a pull request
  • introduce two Python scripts to split the build task since we cannot get v8 dependencies from Alpine
    • get_v8deps.py : get v8 dependencies
    • compile_v8.py : compile v8
    • build.py uses functions from the get_v8deps.py and compile_v8.py scripts to get dependencies and compile v8 (in one go)
  • add cgo directive for deps/alpine_x86_64 (disclaimer: I don't know what I'm doing 🐶)
    • as far as I understand, it would allow to pass an environment variable CC=musl-gcc to install v8go on Alpine?
  • create a module deps/alpine_x84_64/vendor.go

resolves #170

ggrossetie avatar Nov 28 '22 10:11 ggrossetie

Note : I'm currently building libv8.a for Alpine on my fork

ggrossetie avatar Nov 28 '22 14:11 ggrossetie

I've added deps/alpine_x86_64/libv8.a. How can I test that everything is running fine on Alpine?

ggrossetie avatar Nov 28 '22 19:11 ggrossetie

Yay! tests are running fine on Alpine 🎉 I'm using a Docker container to run the test + coverage on Go 1.17.13 alpine3.16 and 1.19.3 alpine3.16.

You can see the result on my fork: https://github.com/Mogztter/v8go/pull/1

ggrossetie avatar Nov 29 '22 11:11 ggrossetie

Will this fix 32 bit arm too? Or is there perhaps a way to put the build workflow in the process, so don't need to pre-vendor?

Vaelatern avatar Nov 30 '22 21:11 Vaelatern

Not really but you can use the same approach to compile V8 on arm32 using Docker.

ggrossetie avatar Nov 30 '22 21:11 ggrossetie

Yay! tests are running fine on Alpine 🎉 I'm using a Docker container to run the test + coverage on Go 1.17.13 alpine3.16 and 1.19.3 alpine3.16.

You can see the result on my fork: https://github.com/Mogztter/v8go/pull/1

@ggrossetie Hi there! The link for the result is not working. Could you please share the working example?

wuzyk avatar Jun 14 '23 17:06 wuzyk

@ggrossetie Hi there! The link for the result is not working. Could you please share the working example?

I was trying to build a native binary for D2 but they are now using another library so I've deleted my fork 😞

ggrossetie avatar Jun 15 '23 09:06 ggrossetie