<p>If a Linux host has gcc with both [g]libc-dev and musl-dev installed, how should the user signal to the <code>go</code> compiler which one to use, when producing glibc vs musl binaries?</p>
<hr/>**评论:**<br/><br/>Creshal: <pre><p><code>CC=musl-gcc go build</code></p></pre>mcandre: <pre><p>Odd, go1.8.1 appears to ignore <code>$CC</code>, at least in OpenSuSE amd64.</p>
<p>I set <code>$CC</code> to <code>musl-gcc</code>, <code>gcc</code>, and <code>no-such-gcc</code>. All of these end up using <code>/usr/bin/[g]cc</code>, not sure which is called yet.</p>
<p>Some Go distributions behave differently. Alpine's go package has <code>go build</code> dynamically linking against musl, while Debian/Ubuntu's golang package has <code>go build</code> statically linking with the GNU/Linux kernel.</p>
<p>Even more confusing, Alpine's <code>go build</code> default coniguration can be overridden with the traditional <code>go build --ldflags '-linkmode external -extldflags "-static"'</code>, in order to produce completely static binaries that bundle musl. While Debian/Ubuntu's <code>go build</code> can't easily disable static linking, at least not with flags I've played with.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传