Skip to content
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

Fails to link with musl libc #595

Open
kv-o opened this issue Apr 15, 2024 · 1 comment
Open

Fails to link with musl libc #595

kv-o opened this issue Apr 15, 2024 · 1 comment

Comments

@kv-o
Copy link

kv-o commented Apr 15, 2024

Go version: 1.20
Go-SDL2 version: 0.4.38
SDL2 version: 2.26.5
OS: Alpine Linux 3.18.2
Architecture: amd64


Any attempt to build a basic go-sdl2 program on Alpine Linux fails due to undefined references to libc functions. My assumption is that go-sdl2 expects glibc, and as a result fails to link with my system's musl libraries.

% CGO_ENABLED=1 CC=gcc go build -tags static -ldflags "-s -w"
go: downloading github.com/veandco/go-sdl2 v0.4.38
# main
/usr/kvo/tech/extra/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_syshaptic.c.o): in function `snprintf':
/usr/include/bits/stdio2.h:67: undefined reference to `__snprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_image_linux_amd64.a(IMG_jpg.o): in function `my_error_exit':
IMG_jpg.c:(.text+0x124): undefined reference to `__longjmp_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_image_linux_amd64.a(IMG_png.o): in function `IMG_SavePNG_RW_libpng':
IMG_png.c:(.text+0x406): undefined reference to `__longjmp_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_image_linux_amd64.a(IMG_png.o): in function `IMG_LoadPNG_RW':
IMG_png.c:(.text+0x3bf4): undefined reference to `__longjmp_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libpng_linux_amd64.a(png.o): in function `png_create_png_struct':
(.text+0x1837): undefined reference to `__longjmp_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libpng_linux_amd64.a(pngerror.o):(.text+0x12d): undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libpng_linux_amd64.a(pngerror.o): in function `png_free_jmpbuf':
(.text+0x73b): undefined reference to `__longjmp_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libpng_linux_amd64.a(pngerror.o): in function `png_longjmp':
(.text+0x7bb): undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libpng_linux_amd64.a(pngerror.o): in function `png_safe_error':
(.text+0xb35): undefined reference to `__longjmp_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libpng_linux_amd64.a(pngrutil.o): in function `png_do_read_interlace':
(.text+0x48a1): undefined reference to `__memcpy_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libpng_linux_amd64.a(pngwutil.o): in function `png_write_sCAL_s':
(.text+0x284a): undefined reference to `__memcpy_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libjpeg_linux_amd64.a(jerror.o):(.text+0x113): undefined reference to `__sprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libjpeg_linux_amd64.a(jerror.o):(.text+0x1d0): undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libjpeg_linux_amd64.a(jerror.o):(.text+0x180): undefined reference to `__sprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_dynapi.c.o): in function `fprintf':
/usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_dynapi.c.o):/usr/include/bits/stdio2.h:100: more undefined references to `__fprintf_chk' follow
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_string.c.o): in function `vsnprintf':
/usr/include/bits/stdio2.h:80: undefined reference to `__vsnprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:80: undefined reference to `__vsnprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_kmsdrmvideo.c.o): in function `printf':
/usr/include/bits/stdio2.h:107: undefined reference to `__printf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:107: undefined reference to `__printf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_syspower.c.o): in function `snprintf':
/usr/include/bits/stdio2.h:67: undefined reference to `__snprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_log.c.o): in function `SDL_LogOutput':
/usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_dspaudio.c.o): in function `read':
/usr/include/bits/unistd.h:39: undefined reference to `__read_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_alsa_audio.c.o): in function `fprintf':
/usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_x11events.c.o): in function `fprintf':
/usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_x11keyboard.c.o): in function `printf':
/usr/include/bits/stdio2.h:107: undefined reference to `__printf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:107: undefined reference to `__printf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(SDL_x11modes.c.o): in function `fprintf':
/usr/include/bits/stdio2.h:100: undefined reference to `__fprintf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(edid-parse.c.o): in function `printf':
/usr/include/bits/stdio2.h:107: undefined reference to `__printf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:107: undefined reference to `__printf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:107: undefined reference to `__printf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:107: undefined reference to `__printf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/include/bits/stdio2.h:107: undefined reference to `__printf_chk'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /data/kvo/go/pkg/mod/github.com/veandco/[email protected]/img/../_libs/libSDL2_linux_amd64.a(edid-parse.c.o):/usr/include/bits/stdio2.h:107: more undefined references to `__printf_chk' follow
collect2: error: ld returned 1 exit status
% 
@veeableful
Copy link
Contributor

Hi @kv-o, yes we built the static libraries using glibc. There is no plan to support musl at the moment as we lack maintainers but PRs would be accepted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants