forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Using `musl` to get a completely static binary
Tobias Schottdorf edited this page Dec 11, 2015
·
3 revisions
musl is an implementation of libc
. When linking against it instead of glibc
(on Linux systems), a completely static binary can be produced with some caveats.
- This has not been tested (for correctness or performance)
- The
netgo
build tag must be used (musl
s resolver does not work in some situations). - Use the following settings:
CC = /usr/local/musl/bin/musl-gcc
# `-v` so warnings from the linker aren't suppressed.
# `-a` so dependencies are rebuilt (they may have been dynamically
# linked).
GOFLAGS += -a -v
LDFLAGS += -extldflags '-static'
See #3413 and referenced commits for tracing the work done on this. It was abandoned since linking glibc
dynamically seemed acceptable. It is very unwise to try to link glibc
statically.
- Home
- Beta Dashboard
- Release Process
- [Building and running tests](Building and running tests)
- [Using
musl
to get a completely static binary](Usingmusl
to get a completely static binary)
- [Using
-
Productivity
- [Multiple GOPATHs](Multiple GOPATHs)
- [Ben's Go Emacs setup](Ben's Go Emacs setup)
- [Radu's vim setup](Radu's vim setup)
- [Speeding up cgo builds](Speeding up cgo builds)
- [Rando scripts](Rando scripts)
- [Life of a transaction](Life of a transaction)
- Readings