You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's controlled via the target platform. A pure Zig binary on Linux should already be statically linked. But, if it depends on a libc, then it depends on which libc you choose. The default is glibc, in which case the binary will be dynamically linked. Using musl instead will yield a static binary.
Example platform configurations can be found here.
The following should yield a statically linked binary using musl with bazel build :static:
platform(
name = "x86_64-linux-musl",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
"@rules_zig//zig/platforms/abi:musl",
],
)
zig_binary(
name = "unconfigured",
main = "main.zig",
# ...
tags = ["manual"],
)
zig_configure_binary(
name = "static",
actual = ":unconfigured",
target = ":x86_64-linux-musl",
)
The same applies to test targets.
The linker-script attribute should not be needed here. But, an example can be found here.
It's very unclear to me how to create statically linked output for either binaries or tests.
There is a "linker_script" param, but I can't see any examples using it, or what the format of the param or "script" should be.
Thanks in advance.
The text was updated successfully, but these errors were encountered: