If a Linux host has gcc with both [g]libc-dev and musl-dev installed, how should the user signal to the go
compiler which one to use, when producing glibc vs musl binaries?
评论:
Creshal:
mcandre:
CC=musl-gcc go build
Odd, go1.8.1 appears to ignore
$CC
, at least in OpenSuSE amd64.I set
$CC
tomusl-gcc
,gcc
, andno-such-gcc
. All of these end up using/usr/bin/[g]cc
, not sure which is called yet.Some Go distributions behave differently. Alpine's go package has
go build
dynamically linking against musl, while Debian/Ubuntu's golang package hasgo build
statically linking with the GNU/Linux kernel.Even more confusing, Alpine's
go build
default coniguration can be overridden with the traditionalgo build --ldflags '-linkmode external -extldflags "-static"'
, in order to produce completely static binaries that bundle musl. While Debian/Ubuntu'sgo build
can't easily disable static linking, at least not with flags I've played with.
