-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release musl builds #3711
Comments
Some progress using rust-musl-builder, but run into GLIBC issue (maybe?): https://gist.github.com/hayd/ae5cbe81117863fff98c2f0c877f2b34
Note: In this context it seems like rusty_v8 builds:
Not sure what that means... But it seems like it's the
|
Not sure if it's helpful but On my system:
|
🤷♂ I think the objective is for musl to statically link, specifically not to link them to that specific system... this might already be possible with some flags? (The environment is in the Dockerfile.) cc @chrmoritz ? |
crtbegin.o is linked in statically, not dynamically. |
It is in the docker image too, perhaps an env issue? (e.g. RUST_FLAGS or CFLAGS? 😬 )
|
@jeromegn Do you have any tips/suggestions here, noting your comment: Did the musl binaries you created for fly work on other linux systems? |
I'm not sure I have much to add. I mostly used the linked Dockerfile and it worked. Inspired (read: ripped off) from: https://hub.docker.com/r/alexmasterov/alpine-libv8 That said, there are alpine images with glibc compiled in there, that might help. It's a lot of trial and error to get it to compile. And then the performance can vary a bit between musl and glibc. |
If anyone is interested, I have compiled DENO with V8 in Alpine Linux Docker container - without https://gist.github.com/kesor/68df53a5d76784a235ca6b0e7efed4d9 Enjoy! |
@kesor This is great, good work! Do these (or some of these) options make sense to be incorporated as gn args? |
I spent hours trying to find GN args to pass via env var or some other way. Couldn’t find how. My knowledge of GN is limited, probably someone with more experience can find the way. Didn’t mean to provide that patch as “the solution” only as a proof of concept. PS: Alpine has other llvm versions as well, maybe with llvm8 the binary will be smaller? Also note that the eventual binary still has dependency on libgcc at the least, maybe other dependencies I didn’t quite catch, it does run with the provided docker image resulting from the Dockerfile build. |
In llvm10 there is no_inline_line_tables which shrinks the binary. Are both these required? Do you have any idea of the reasons? - ldflags += [ "-Wl,--color-diagnostics" ]
+ ldflags += [ ]
- libs = []
+ libs = ["execinfo"] |
Color diagnostics was reported as an invalid option for the linker. Wouldn’t work with it. I also think that there was a different linker used for parts of the build for some reason. Maybe that can be the root cause and resolving it can solve the arguments issue. libexecinfo was also required because of failing linking. I don’t really know the reason why. The most annoying thing was the custom location of the header files which was not automatically detected, and I couldn’t find a way to provide an include path via GN args. I would also assume that this path will change for different llvm/alpine versions. |
Yes, I think we'd want to pass this (as a GN_ARGS)...? @ry do you have any pointers in adding these/or suggest whether this a good/bad way forward? https://gist.github.com/kesor/68df53a5d76784a235ca6b0e7efed4d9#file-rusty-changed-build-diff |
Is this referring to the libgcc alpine package? I wanted to avoid this dependency by compiling with musl and the linux musl headers in order for deno to be a fully static binary. This can be achieved with node but I'm not sure how far down the rust toolchain requires glibc. |
@nathanblair Note that |
I had a similar problem with Also, you should be able to replace the |
Can deno static link to c library to resolve issue like golang does? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I think this one could probably stay open? |
I have managed to build rusty_v8.a for musl, but deno fails with:
|
Works after switching to older zig (version 0.8.1)
Attached is |
Succesfully deployed and working in AWS:
|
Hey @Cloudef, does this indicate you've gotten a musl build working? I would be much happier to continue with a current pipeline automation project with Deno rather than Golang, but the complexity + size of gcc requirement is currently pushing me toward the latter. Musl builds would make life a lot easier, even if small things sometimes break :) |
@Propolisa I've got I pushed the build files here: https://github.com/Cloudef/nix-zig-stdenv/tree/master/sketchpad One thing to note is that, building To use the prebuilt static lib, run I've tested building on both aarch64-darwin and x86_64-linux and confirmed the builds working. TL;DRGet nix from https://nix.dev/tutorials/install-nix I want to use prebuilt librusty-v8curl -O 'https://github.com/denoland/deno/files/9923527/librusty_v8-aarch64-unknown-linux-musl.zip'
unzip librusty_v8-aarch64-unknown-linux-musl.zip
nix store add-file librusty_v8-aarch64-unknown-linux-musl.a
git clone https://github.com/Cloudef/nix-zig-stdenv.git
cd nix-zig-stdenv/sketchpad
# you might need '--argstr zig-version 0.8.1' here if you are on linux
nix-build -A deno-core-hello-world --argstr target aarch64-unknown-linux-musl
file result/bin/deno-core-hello-world
# result/bin/deno-core-hello-world: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, stripped I want to build everything from scratchYou need to be on a linux system for this with git clone https://github.com/Cloudef/nix-zig-stdenv.git
cd nix-zig-stdenv/sketchpad
nix-build -A deno-core-hello-world --arg with-rusty-v8 true --argstr target aarch64-unknown-linux-musl
file result/bin/deno-core-hello-world
# result/bin/deno-core-hello-world: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, stripped I don't care about the hello-world, give me the static lib for rusty-v8git clone https://github.com/Cloudef/nix-zig-stdenv.git
cd nix-zig-stdenv/sketchpad
nix-build -A rusty-v8 --argstr target aarch64-unknown-linux-musl
ls result/lib/librusty_v8.a
# result/lib/librusty_v8.a Wait what is this nix? Why do I need itSimply put, it makes your life easier. Go learn it. |
@Cloudef really appreciate the quality of this reply. I am short for free time to set this environment up, but perhaps another may be able to use your writeup to attempt building |
Hmm, it seems like a true Deno alpine container image might be just around the corner. The current one uses |
I have successfully built a musl binary (on Alpine) that passes the WPT tests (although it does not pass
|
I’ve packaged Deno for Alpine Linux (package deno); it’s currently available in the testing repository (in edge). All tests pass on x86_64, a few tests fail on aarch64. |
This is lovely for testing, thank you! FROM alpine:edge
RUN apk add --no-cache deno For comparison, this produces a 95MB image vs the 127MB |
I use openwrt, I hope the official can provide musl builds. |
You can package it yourself for OpenWrt… |
It's very hard for me, many errors. |
Did you use patches from the deno aport on Alpine Linux? |
I copy deno from alpine to openwrt. it throws Error loading shared library libzstd.so.1: No such file or directory (needed by ./deno)
Error loading shared library libffi.so.8: No such file or directory (needed by ./deno)
Error loading shared library libz-ng.so.2: No such file or directory (needed by ./deno)
Error loading shared library libsqlite3.so.0: No such file or directory (needed by ./deno)
Error loading shared library libicui18n.so.73: No such file or directory (needed by ./deno)
Error loading shared library libicuuc.so.73: No such file or directory (needed by ./deno)
Error relocating ./deno: _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found
Error relocating ./deno: _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found
Error relocating ./deno: _ZNKRSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE3strEv: symbol not found
Error relocating ./deno: _ZNKRSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEE3strEv: symbol not found
Error relocating ./deno: _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC2ERKNS_12basi |
None of these are the build system, you have some missing libraries (your package definition likely lacks them as runtime dependencies) and have some relocation errors in the c++ standard library (usually suggesting it wasn't linked or available, which is likely given the other errors). |
This is a misunderstanding. Musl (like every other libc currently available) only allows for Whether your deno will run FFI code based on It's technically possible to have a statically linked executable that can call |
Looks like you're right! Sorry for confusion. |
probably solves denoland/deno_docker#373 and denoland/deno_docker#350 |
Previously I was able to use
--target x86_64-unknown-linux-musl
on rusty_v8 and deno (excluding the plugin). denoland/rusty_v8#49The one concern is that glibc is required for plugins (but I don't know if that means glibc cannot be used on a binary created with musl 🤷♂ ).
This is useful for platforms without glibc, examples alpine linux and amazon linux (which is occasionally a pain building, so would be helpful if a compatible binaries was in deno's CI).
xlink: #3243 #1658 #1495 #3356
The text was updated successfully, but these errors were encountered: