Skip to content
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

Compile tools statically linked #7

Open
mpolitzer opened this issue May 16, 2023 · 5 comments
Open

Compile tools statically linked #7

mpolitzer opened this issue May 16, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@mpolitzer
Copy link
Collaborator

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
Copy link
Collaborator Author

(For reference)

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

  • The first is that their RISC-V is Tier-3, that is untested and not even build automatically by them (but available on alpine), and even though it seems to work fine there is an increased risk of finding bugs along the way, such as cargo update memory blowing up.
  • The second is that since they don't provide a nightly version, and from what I searched that is required for static compilation.

@mpolitzer
Copy link
Collaborator Author

@edubart edubart added the enhancement New feature or request label May 30, 2023
@edubart
Copy link
Contributor

edubart commented Apr 11, 2024

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:

  • Bundle busybox or toybox
  • Link everything statically OR link dynamically but provide a libc shared library like in libc-cartesi.so

@edubart edubart changed the title Compile tools statically linked to MUSL instead of GLIBC Compile tools statically linked Apr 11, 2024
@mpolitzer
Copy link
Collaborator Author

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

3 participants