Skip to content

Static linking for OpenBSD#6705

Merged
kit-ty-kate merged 2 commits intoocaml:masterfrom
flumf:master
Sep 26, 2025
Merged

Static linking for OpenBSD#6705
kit-ty-kate merged 2 commits intoocaml:masterfrom
flumf:master

Conversation

@flumf
Copy link
Copy Markdown
Contributor

@flumf flumf commented Sep 25, 2025

Building with ./configure --enable-static --with-vendored-deps on an OpenBSD 7.7 system results in a statically linked opam binary. Brief testing of the binary shows no problems, although I've admittedly not strenuously tested it, nor have I tried building with non-vendored dependencies.

Resolves #6241.

@kit-ty-kate
Copy link
Copy Markdown
Member

Thanks! I'll just need up a couple of hours to test the second commit which makes the release binary static on OpenBSD, but in the meantime ./configure --enable-static works like a charm, thanks a lot!

Here's a before/after picture (after strip, aka. make opam-stripped):

Before:

$ ldd opam
opam:
	Start            End              Type  Open Ref GrpRef Name
	00000d6ceee2b000 00000d6cef94d000 exe   2    0   0      opam
	00000d6ef8f2e000 00000d6ef904b000 rlib  0    1   0      /usr/lib/libc++.so.10.0
	00000d6fa9349000 00000d6fa9391000 rlib  0    2   0      /usr/lib/libc++abi.so.7.0
	00000d6f52565000 00000d6f52572000 rlib  0    1   0      /usr/lib/libpthread.so.27.1
	00000d6fedf43000 00000d6fedf75000 rlib  0    1   0      /usr/lib/libm.so.10.1
	00000d6fd9560000 00000d6fd9667000 rlib  0    1   0      /usr/lib/libc.so.100.3
	00000d6f74173000 00000d6f74173000 ld.so 0    1   0      /usr/libexec/ld.so
$ ls -lh opam                                                                                                                                                                                          
-rwxr-xr-x  1 kit_ty_kate  kit_ty_kate  11.1M Jul 23 14:20 opam

After:

$ ldd opamMain.exe                                                                                                                                                                                     
opamMain.exe:
	Start            End              Type  Open Ref GrpRef Name
	00000b777e09d000 00000b777ec74000 dlib  1    0   0      <path>/opamMain.exe
$ ls -lh opamMain.exe
-r-xr-xr-x  1 kit_ty_kate  kit_ty_kate  11.8M Sep 25 22:16 opamMain.exe

I've added a line to the changelog, renamed the commit message and made you co-author of the follow-up commit. Does that look alright to you?

@flumf
Copy link
Copy Markdown
Contributor Author

flumf commented Sep 25, 2025

Looks good to me, thanks!

@kit-ty-kate kit-ty-kate changed the title Initial work on static linking for OpenBSD Static linking for OpenBSD Sep 26, 2025
@kit-ty-kate
Copy link
Copy Markdown
Member

I can confirm, the release script now outputs a static OpenBSD binary. Thanks a lot!

@kit-ty-kate kit-ty-kate merged commit 5b5c906 into ocaml:master Sep 26, 2025
46 checks passed
@semarie
Copy link
Copy Markdown
Contributor

semarie commented Oct 21, 2025

I saw this PR due to release notes about opam-2.5.0~alpha1, so it is a somehow late comment.

Just to note that it will not work on all architectures supported by OpenBSD, but only on archs using llvm. We still have architectures using gcc (and so stdc++ instead of c++ and c++abi libraries).

But it is a good thing to have it. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release binaries: Statically linked OpenBSD binaries

3 participants