-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support dynamic linking musl libc #5364
Comments
Using the static version of the SDL also doesn't work, unfortunately EDIT: note that the executable wasn't fully static though |
I think it is fair to also call this a bug because it makes zig unusable on musl-based linux distros for applications that require dynamic linking. |
@ifreund from what I can gather, #7406 only allows dynamically linking musl when doing native builds, right? Is there a way to extend this support for cross scenarios? (I'm not overly familiar with how musl distros work - I just happened to notice that cross-compiling an |
Static is the default; you need to add the |
Ah, the issue was that I tried |
Is there a way to achieve the same with $ zig cc main.c -target x86_64-linux-musl -fPIE -lc
$ wsl musl-ldd a.out
musl-ldd (0x7f5ffe36e000) |
Full repro: main.c
Compiling:
Inspect the resulting
Looking at the linker line above, you can see that |
@motiejus Would you mind opening a new issue for that with that example? It seems like a bug in the |
downstream bug report https://gitlab.alpinelinux.org/alpine/aports/-/issues/11399.
Programs built by zig can't initialize video output (audio is fine, though):
SDL_Init(SDL_INIT_VIDEO)
fails.I wrote a minimal C program to test this further, but I originally noticed the issue when compiling zig code.
to test this, I used the following:
apk add -t .zig zig sdl2 sdl2-dev sdl2_image-dev build-base clang
on Alpine)(using the SDL_image pkg-config to ensure correctness)
Yet the C code is functional:
and clang (LLVM) also works:
The cause seems to reside at link time:
The issue was tested with Zig 0.6, and was already present with Zig 0.5. The same code works with Zig on Debian.
I don't know how to debug this further, but feel free to ask any question.
The text was updated successfully, but these errors were encountered: