Full patch 20161223141136-c9899-352eb6f9eec8d2f1094318778a551517c51bd3fb

Fri Dec 23 14:11:36 UTC 2016  Alexander Markov <apsheronets@gmail.com>
 * ?;>E> ?@>25@8;, =04> 5I5

en/howto_link_c_lib_statically_with_ocaml_app
@@ -33,7 +33,7 @@
+ as -o '/tmp/camlstartupe71be7.o' '/tmp/camlstartupaa15d5.s'
+ gcc -o 'test'   '-L/usr/lib/ocaml/magic' '-L/usr/lib/ocaml' '/tmp/camlstartupe71be7.o' '/usr/lib/ocaml/std_exit.o' 'test.o' '/usr/lib/ocaml/magic/magic.a' '/usr/lib/ocaml/stdlib.a' '-Wl,-Bstatic' '-lmagic_stubs' '-lmagic' '-Wl,-Bdynamic' '-lz' '/usr/lib/ocaml/libasmrun.a' -lm  -ldl 

Yet another way — no @-noautolink@ but @-static@ and @-dynamic@ instead of @-Wl,-Bstatic@ and @-Wl,-Bdynamic@. But in this way it links libc and other stuff. For example I got 959K binary instead of 284K. I don't know yet why.

bc. systemA:~$ $ ocamlfind ocamlopt test.ml -o test -package magic -linkpkg -cclib '-static -lmagic_stubs -lmagic -dynamic -lz' -verbose
Effective set of compiler predicates: pkg_magic,autolink,native