about summary refs log tree commit diff stats
path: root/bb85ca.ocaml-static-linking.txt
blob: d6cef84ec83908a045af14008751733392031054 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
ID: bb85caff-be39-47b0-9add-42fae180c796
Title: OCaml static linking
Authors: Nova[有線魔女] <novaburst@envs.net>
Date: 2021-09-28T13:36:52-00:00
Date-Edited: 2022-01-25T13:03:02-03:00
Topics: Computing > Programming > OCaml 

Since quite a while ago (a month or so I guess) I had read this blog post by OCamlPro[1] about generating static PIE with OCaml.
The first project on where I have tried doing so was Logarion[2] , and afterwards bumpmap-tool[2], each using a different build system.
In the 1st case I had to add the field '(flags (:standard -cclib -static))' to the 'cli/dune' file and rebuilt with 'dune build'
As for the 2nd case I added '-cclib -static' to the 'ocamlopt' flags in the command line and rebuilt.

I ran the ldd command in both (test done on a musl-based distro) only to have this output:
	- /lib/ld-musl-x86_64.so.1: (insert executable name here): Not a valid dynamic program

Which means that it does actually work, but I'm not sure whether it could work for bigger projects.
I think that's all I've got to say here.

## Links
[1]: <https://www.ocamlpro.com/2021/09/02/generating-static-and-portable-executables-with-ocaml/>
[2]: <http://logarion.orbitalfox.eu>
[3]: <https://git.sr.ht/~novaburst-dev/bumpmap-tool>

## Extras
[Static builds of my own branch of Logarion]: <https://novaburst.bsd.tilde.team/logarion/>