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
{{ message }}
Repository navigation
Segmentation fault by default due to a wrong dynamic linker on KissLinux #21963
After digging a little bit I realized that the linking stage was failing but still outputs the executable:
By taking the exact build command and removing the listen=- argument and adding --dynamic-linker /usr/lib/ld-musl-x86_64.so.1 the executable get successfully linked and works as expected
Yes, because it checks /usr/bin/env or its interpreter (/usr/bin/coreutils, /bin/sh) to find out libc, and if you compile it statically, it would assume that whole system is static -> musl needed.
In kiss-chroot-24.06.14-2:
$ file usr/bin/envusr/bin/env: symbolic link to busybox
$ file usr/bin/busyboxusr/bin/busybox: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
$ file usr/bin/x86_64-pc-linux-musl-gccusr/bin/x86_64-pc-linux-musl-gcc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, stripped
Yes, because it checks /usr/bin/env or its interpreter (/usr/bin/coreutils, /bin/sh) to find out libc, and if you compile it statically, it would assume that whole system is static -> musl needed.
In kiss-chroot-24.06.14-2:
$ file usr/bin/env
usr/bin/env: symbolic link to busybox
$ file usr/bin/busybox
usr/bin/busybox: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
$ file usr/bin/x86_64-pc-linux-musl-gcc
usr/bin/x86_64-pc-linux-musl-gcc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, stripped
Yes, this is exactly what I want, a workaround for this issue is to simply manually set the dynamic_linker as you shown in the build.zig like this:
As an easier alternative, you can pass zig build -Ddynamic-linker=/usr/lib/... in projects that use b.standardTargetOptions in their build.zig, same way as you passed --dynamic-linker /usr/lib/ld-musl-x86_64.so.1 in zig build-exe
Activity
alexrp commentedon Nov 11, 2024
Please try this with a nightly build from https://ziglang.org/download as there have been multiple changes to
std.Target.DynamicLinkerin master.Ogromny commentedon Nov 11, 2024
Unfortunately I get the same issue with the latest nightly build

BratishkaErik commentedon Nov 17, 2024
I guess it's similar reason as in #21941 (comment) :
In
kiss-chroot-24.06.14-2:So if you start
zig build-exe --show-builtin:But if I replace
envwithx86_64-pc-linux-musl-gcc, this part changes:I assume result above is what you want?
Ogromny commentedon Nov 17, 2024
Yes, this is exactly what I want, a workaround for this issue is to simply manually set the
dynamic_linkeras you shown in thebuild.ziglike this:BratishkaErik commentedon Nov 17, 2024
As an easier alternative, you can pass
zig build -Ddynamic-linker=/usr/lib/...in projects that useb.standardTargetOptionsin their build.zig, same way as you passed--dynamic-linker /usr/lib/ld-musl-x86_64.so.1inzig build-exe