denoland / rusty_v8

Rust bindings for the V8 JavaScript engine
https://crates.io/crates/v8
MIT License
3.18k stars 305 forks source link

target x86_64-unknown-linux-musl #49

Open hayd opened 4 years ago

hayd commented 4 years ago

It would be great to build/publish this as a target (for alpine and other platforms without glibc, iiuc).

It already seems to build okay (--target x86_64-unknown-linux-musl). (see also https://github.com/denoland/deno/issues/3711#issuecomment-576040797)

It's unclear to me if it's best to only target x86_64-unknown-linux-musl or to additionally support it. e.g. sccache seems to only provide binaries for that target.

kesor commented 4 years ago

If anyone is interested, I have compiled DENO with V8 in Alpine Linux Docker container - without glibc, but completely using the Alpine muslc library.

https://gist.github.com/kesor/68df53a5d76784a235ca6b0e7efed4d9

Enjoy!

theoparis commented 2 years ago

Any updates on this? It's been 2 years ... I need musl support in order to embed deno into my linux kernel-based system because it needs to be linked statically with no /lib/*.so dependencies.

kitsonk commented 2 years ago

Just because something is open doesn't mean that a) it is being actively worked on or b) set any expectations about it being closed, especially when it comes to open source software.

I am sure a contribution in this area would be welcome.

localhosted commented 1 year ago

I'm trying to build a static Edge Runtime but I'm new to Rust. Where could I start to attempt to build deno statically?

groboclown commented 3 days ago

I'm attempting to work my way through what it takes to build on musl. Part of this comes from having issues just getting the static build to work, regardless of musl or glibc.

My current approach runs the build inside a container to ensure it's reproducible. For those playing the home game, I'm running off the base image docker.io/rust:latest, which builds off an Ubuntu distro.

I start off easy:

$ apt-get update && apt-get install -y musl-tools musl-dev libclang-dev clang
$ rustup target add x86_64-unknown-linux-musl
$ cd /tmp
$ cargo init v8test
$ cd v8test
$ cargo add v8
$ rustup component add rustfmt
$ V8_FROM_SOURCE=1 cargo build --target x86_64-unknown-linux-musl --release -vv
(snip)
  --- stderr
  ninja: error: '../../../../../../usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/v8-0.106.0/third_party/icu/common/icudtl.dat', needed by 'icudtl.dat', missing and no known rule to make it

This is the old error reported in other issues. I use an ugly work-around to get past it: I replace the Rust cache version of the v8 repository (which explicitly omits items) with the full Git version:

$ v8_src="$( readlink -f /usr/local/cargo/registry/src/index.crates.io-*/v8-0.106.0/)"
$ rm -r "${v8_src}"
$ git clone --depth 1 -j8 --recurse-submodules --branch v0.106.0 https://github.com/denoland/rusty_v8.git "${v8_src}"

And build again:

$ V8_FROM_SOURCE=1 cargo build --target x86_64-unknown-linux-musl --release -vv

This time it works. Notice that there were many additional dependencies necessary to get this to build, but it does work.

devsnek commented 3 days ago

The icudtl.dat issue will be fixed when we merge v8 13.0, but that is blocked on another issue not yet fixed in upstream.