Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

Released binaries don't work with musl #241

Open
115100 opened this issue Jun 5, 2017 · 2 comments
Open

Released binaries don't work with musl #241

115100 opened this issue Jun 5, 2017 · 2 comments

Comments

@115100
Copy link

115100 commented Jun 5, 2017

For alpine-based Docker containers, binaries won't work without statically compiling, due to musl being the default libc:

# /usr/local/bin/migrate3
sh: /usr/local/bin/migrate3: not found
# ldd /usr/local/bin/migrate3 
        /lib64/ld-linux-x86-64.so.2 (0x55925953c000)
        libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x55925953c000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x55925953c000)
Error relocating /usr/local/bin/migrate3: __vfprintf_chk: symbol not found
Error relocating /usr/local/bin/migrate3: __fprintf_chk: symbol not found

This can be fixed by compiling without cgo enabled within Makefile, i.e.:

	cd ./cli && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o build/migrate.linux-amd64 -ldflags='-X main.Version=$(VERSION)' -tags '$(DATABASE) $(SOURCE)' .
@mattes
Copy link
Owner

mattes commented Jun 5, 2017

I just enabled CGO because of this actually: #238 (comment)

@alecmev
Copy link

alecmev commented Nov 7, 2017

Maybe putting -static in -ldflags ought to do it? runc does it, for example.

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

No branches or pull requests

3 participants