Accéder au contenu.
Menu Sympa

belenios-discuss - Re: [belenios-discuss] Statically linking Belenios

Objet : Discussion list for Belenios

Archives de la liste

Re: [belenios-discuss] Statically linking Belenios


Chronologique Discussions 
  • From: Stéphane Glondu <stephane.glondu AT inria.fr>
  • To: Alban Bruder <alban.bruder AT uni-weimar.de>, belenios-discuss AT inria.fr
  • Subject: Re: [belenios-discuss] Statically linking Belenios
  • Date: Wed, 18 Aug 2021 14:48:26 +0200
  • Ironport-hdrordr: A9a23:/d7I7KFazknCRYqMpLqE48eALOsnbusQ8zAXPjNKOHlom6uj5qSTdZUgpH3JYVkqNk3I9ersBEDEewK+yXcX2+ks1NWZMzUO0VHARL2Kr7GJ/9SKIUHDH4BmvpuIP5IeNOHN

Dear Alban,

Le 18/08/2021 à 14:07, Alban Bruder a écrit :
> for a slimmed down installation, I am trying to statically link
> Belenios. My incentive is that the whole OPAM installation is quite big
> (around 3 GB) and I wonder if this could be less. E.G for a distribution
> where only the binaries and the Belenios source code would be required.

This is exactly what is done in doc/nspawn:

https://gitlab.inria.fr/belenios/belenios/-/tree/master/doc/nspawn

With Belenios 1.15, one can get a ~200 MB image; with 1.16, it is ~400
MB and with master, it is ~125 MB.

> My understanding of OCAML/OPAM is that this might be possible by
> including "(flags (-ccopt -static))" in the dune files. Did one of you
> already try this or is it a bad idea?

This might work for belenios-tool, but not for the web server (at least
in <= 1.16). Indeed, ocsigenserver does dynamic lookups and loading of
numerous OCaml libraries which cannot be avoided by merely stuffing
-static into the linking command line.

However, in master, I've implemented so-called "static linking" (in the
Ocsigen/Eliom sense; beware, this is not exactly what you mean) of the
web server. It consists in creating a new executable, "belenios-server"
that embeds ocsigenserver, eliom, belenios and all OCaml libraries. It
still uses shared libraries (such as libc and libssl), though. I guess
it could be workable to turn this "belenios-server" executable into a
true static binary but I didn't try. The reduced size of the nspawn
image in master is due to this new strategy.

If your goal is to reduce the footprint of Belenios and its dependencies
on a production server, I would recommend to use nspawn as instructed above.


Cheers,

--
Stéphane



Archives gérées par MHonArc 2.6.19+.

Haut de le page