cartesi / machine-emulator-tools

Set of tools to help the development
Apache License 2.0
13 stars 20 forks source link

Compile tools statically linked #7

Open mpolitzer opened 1 year ago

mpolitzer commented 1 year ago

Statically linking to MUSL instead of GLIBC would make the final binaries smaller, allowing rootfs to be more compact. Also statically linking GLIBC is not recommend, though @mpolitzer pointed this does not impact us.

To do this we would need to use a MUSL toolchain to build the tools, we could probably use Alpine toolchain or some other distro to compile them instead of creating our own toolchain, or maybe we could move our toolchain to use MUSL once we get rid of buildroot.

mpolitzer commented 1 year ago

(For reference)

As mentioned, there are a couple of problems with the musl solution, both regarding rust.

mpolitzer commented 1 year ago

notes on glibc static compilation: https://sourceware.org/glibc/wiki/FAQ#Even_statically_linked_programs_need_some_shared_libraries_which_is_not_acceptable_for_me.__What_can_I_do.3F

edubart commented 7 months ago

We should not forget about this, there have been some interest from others to use Alpine for example. I also have interest to make "distroless" dapps, where I would install tools into an empty filesystem and copy my dapp statically linked, the dapp rootfs would be very tiny this way.

To make this happen we need to:

mpolitzer commented 7 months ago

There are plans to deprecate the rollup-http-server and remove it from this repo. We'll have a lot more flexibility when that happens. With only C/C++ code on the repository we'll be able to experiment with a statically compiled tools.

endersonmaia commented 7 months ago

On the boxybox, toybox, I'd suggest taking a look at s6 ecosystem, where is provided a lot of simple versions of useful linux tools with support for musl and multicall binary just like busybox.

I've already used its s6-rc and s6-overlays on container environments, but I never used it inside cartesi-machine, but I plan to test it.