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

How to staticly compile? #76

Open
berney opened this issue Aug 3, 2019 · 0 comments
Open

How to staticly compile? #76

berney opened this issue Aug 3, 2019 · 0 comments

Comments

@berney
Copy link

berney commented Aug 3, 2019

I've tried go build -ldflags '-extldflags "-fno-PIC -static"' -buildmode pie -tags 'osusergo netgo static_build' and go build -ldflags '-extldflags "-fPIC -static"' -buildmode pie -tags 'osusergo netgo static_build'.

Both get issues with trying to link.

/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpthread.a(pthread_create.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpthread.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

I don't want a shared object I want a self-contained static binary that I can use in a Docker container FROM scratch.

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

1 participant