是否可以使用 buildroot 静态构建 gcc?
我正在使用 buildroot 在专用机器上构建一个新的 gcc 交叉编译器。
它工作正常,但我现在需要从另一台机器运行这个 gcc,在这台机器上我没有相同的 libc 版本:-(。当然 gcc 然后崩溃了。
是否可以使用 buildroot 静态构建 gcc ?
I am using buildroot to build a fresh gcc cross-compiler on a dedicated machine.
It worked fine, but I now need to run this gcc from another machine, on which I have not the same libc version :-(. Of course gcc then crashed.
Is it possible to build gcc statically using buildroot ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试将 -static 传递给链接器(通过 LDFLAGS),但请注意 glibc 不再支持完全静态链接(或者它需要支持静态链接的 glibc 版本)。
这是因为 nss 库(名称服务器开关)将动态加载(除非您编译自己的 glibc - 但这违背了 nss 的目的)。然而,这可能足以减少对系统库的依赖。
但我可以假设静态链接的 gcc 相当大 - 这可能会导致启动时间很长。
You could try passing -static to the linker (via LDFLAGS), but be aware that full static linking is not supported by glibc anymore (resp. it needs a glibc build which supports static linking).
This is due to the fact that nss libraries (name server switch) will be loaded dynamically (unless you compile your own glibc - but that defeats the purpose of nss). This might be enough for you however to reduce dependencies against system libraries.
But I could assume that a statically linked gcc is fairly huge - this might result in long startup times.
如果您的目标只是制作一个可重定位的工具链,那么与 expat、gmp、mpfr 和 mpc 静态链接就足够了。您只需应用 https://patchwork.ozlabs.org/patch/359841/
If your objective is only to make a relocatable toolchain, statically link with expat, gmp, mpfr and mpc should enough. You can simply apply https://patchwork.ozlabs.org/patch/359841/