Following is a example when i try build tartrazine.
without --static
╰─ $ shards build --cross-compile --target=x86_64-linux-musl
Dependencies are satisfied
Building: tartrazine
cc /home/zw963/Crystal/git/tartrazine/bin/tartrazine.o -o /home/zw963/Crystal/git/tartrazine/bin/tartrazine -rdynamic -L/home/zw963/Crystal/bin/../lib/crystal -lyaml -lxml2 -lz -lpcre2-8 -lgc -lpthread -ldl -levent
with static.
╰─ $ shards build --cross-compile --target=x86_64-linux-musl --static
Dependencies are satisfied
Building: tartrazine
cc /home/zw963/Crystal/git/tartrazine/bin/tartrazine.o -o /home/zw963/Crystal/git/tartrazine/bin/tartrazine -rdynamic -static -L/home/zw963/Crystal/bin/../lib/crystal -lyaml -lxml2 -lm -licuuc -licudata -lpthread -lm -lz -llzma -pthread -lpthread -licui18n -lz -lpcre2-8 -lgc -lpthread -ldl -levent
As you can see, the latter add the -licuuc -licudata -licui18n
into the cc output.
But, the wired things is, it doesn’t matter which one you use for linking, both of them with generate static version binary use zig cc, even, binary size is almost same, and both of them works when copy binary into a new linux host.
╰─ $ ldd tartrazine_no_static tartrazine_static
tartrazine_no_static:
statically linked
tartrazine_static:
statically linked
╰─ $ file tartrazine_no_static tartrazine_static
tartrazine_no_static: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), static-pie linked, with debug_info, not stripped
tartrazine_static: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), static-pie linked, with debug_info, not stripped
╰─ $ ls -lh tartrazine_no_static tartrazine_static
Permissions Size User Date Modified Name
.rwxr-xr-x 11M zw963 8 minutes tartrazine_no_static*
.rwxr-xr-x 11M zw963 8 minutes tartrazine_static*
So, my question is, why the latter --static version, will add -licuuc -licudata -licui18n
as linking dependencies? It’s seem like never used them when linking, right?
Thanks.