How to specify toolchain if multiple are installed (e.g. glibc and musl)?

agolangf · · 495 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<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&#39;s go package has <code>go build</code> dynamically linking against musl, while Debian/Ubuntu&#39;s golang package has <code>go build</code> statically linking with the GNU/Linux kernel.</p> <p>Even more confusing, Alpine&#39;s <code>go build</code> default coniguration can be overridden with the traditional <code>go build --ldflags &#39;-linkmode external -extldflags &#34;-static&#34;&#39;</code>, in order to produce completely static binaries that bundle musl. While Debian/Ubuntu&#39;s <code>go build</code> can&#39;t easily disable static linking, at least not with flags I&#39;ve played with.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

495 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传