crun icon indicating copy to clipboard operation
crun copied to clipboard

How to Nix static build with wasmedge?

Open Edingh opened this issue 2 years ago • 7 comments

The way you recommended to static build using Nix does not include wasmedge support. So how to Nix static build with wasmedge? Is it possible? If it's possible, would you like to release the binary with wasmedge support? Thanks for the hlep!

Edingh avatar May 19 '22 14:05 Edingh

If I change nix as follows, the result crun will become dynamic.

vi default-arm64.nix configureFlags = [ "--enable-static" "--with-wasmedge" ]

./result/bin/crun --version crun version 1.4.5.0.0.0.25-7077-dirty commit: 7077fa1d40e8a4a9e473dcf8c20e5b36b49dfca4 spec: 1.0.0 +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +WASM:wasmedge +YAJL

file ./result/bin/crun ./result/bin/crun: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=28f43744c5fe655de47f339076eebcc64dc27cc5, for GNU/Linux 3.7.0, not stripped

chairwa avatar May 20 '22 08:05 chairwa

Hi @Edingh , I don't think crun supports static binary with wasm support out of the box as of now.I think code would need a slight refactor since crun uses dlopen and dlsym and I don't know if we will loose benefits of static linking while still using dlopen under the hood. @giuseppe are there any drawbacks of dlopen and dlsym for static linking.

Since all the runtimes already ship static library i think it should not be too hard with a slight refactor but afaik its not on the roadmap yet so maybe we can keep issue open till we get more request for it ?

flouthoc avatar May 20 '22 09:05 flouthoc

we would need to statically build and link wasmedge as well, and not use dlopen and dlsym.

giuseppe avatar May 25 '22 10:05 giuseppe

Yes I think it would be a small refactor. I'll try checking this issue.

flouthoc avatar May 25 '22 10:05 flouthoc

I don't think it is a high priority issue that you should hurry to look at. Still it is not clear what are the advantages

giuseppe avatar May 25 '22 11:05 giuseppe

I would leave this to community. Quite often people say they want static and then they disappear.

rhatdan avatar May 25 '22 14:05 rhatdan

As you can see, docker release include static build runc binary; and it can run on Android and other linuxKernel-based OS. https://download.docker.com/linux/static/stable/aarch64/docker-20.10.16.tgz

k3s (or even almost all k8s-related project) also released in static build binary.

This way (static build binary), we can extend crun usage range.

chairwa avatar May 26 '22 06:05 chairwa