是否可以使用 buildroot 静态构建 gcc?

发布于 2024-12-09 05:01:34 字数 155 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

短暂陪伴 2024-12-16 05:01:34

您可以尝试将 -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.

柏拉图鍀咏恒 2024-12-16 05:01:34

如果您的目标只是制作一个可重定位的工具链,那么与 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文