如何将目标文件添加到每个链接

发布于 2024-12-06 10:49:33 字数 637 浏览 0 评论 0原文

RHEL5 的 gcc-4.3.2 中有一个bug,我们被困住了。作为解决方法,我们提取了丢失的对象并将其放入对象文件中。将此目标文件添加到每个链接可以使问题消失。

虽然将其直接添加到LDFLAGS似乎是一个很好的解决方案,但这不起作用,因为例如libtool无法处理其中的非la文件。

一个稍微更便携的解决方案似乎是直接修补 gcc 规范以将其添加到每个链接。我想出了

*startfile:
+ %{shared-libgcc:%{O*:%{!O0:/PATH/TO/ostream-inst.o}}}

在编译带有优化的共享库时将 ostream-inst.o 添加到链接中使用的启动文件列表中的情况。

尝试使用此规范编译 boost 会出现一些错误,因为它的构建直接使用 ld--startgroup/--endgroup 设置一些对象。

我应该如何更新该规范以涵盖这种情况,甚至更好地涵盖所有情况?

There is a bug in RHEL5's gcc-4.3.2 with which we are stuck. As a work-around we have extracted the missing object and put it in an object file. Adding this object file to every link makes the problem go away.

While adding it directly to LDFLAGS seems like a good solution, this doesn't work since e.g. libtool cannot cope with non-la files in there.

A slightly more portable solution seems to be to directly patch the gcc spec to add this to every link. I came up with

*startfile:
+ %{shared-libgcc:%{O*:%{!O0:/PATH/TO/ostream-inst.o}}}

where ostream-inst.o is added to the list of startfiles used in the link when compiling a shared library with optimizations.

Trying to compile boost with this spec gives some errors though since its build directly sets some objects with ld's --startgroup/--endgroup.

How should I update that spec to cover that case as well, or even better, all cases?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

才能让你更想念 2024-12-13 10:49:33

通过此 URL 指定子进程和开关传递给他们GCC 命令选项

如果这对您有帮助,那就太好了。

Go through this URL Specifying subprocesses and the switches to pass to them and GCC Command Options

If this help you, thats great.

比忠 2024-12-13 10:49:33

我知道这不是您想听到的答案(因为您在问题中另有指定),但是您在这里遇到了麻烦,并且可能会遇到更多麻烦,因为您的编译器有错误。您应该找到一种方法来替换它,因为下次出现一些晦涩难懂的构建系统时,您会发现自己编写了更多的解决方法代码。那里不仅有 bjam。

抱歉我帮不了你更多。您可以尝试简单地手动编写一个 .lo 文件(毕竟它是一个两行文件)并将其插入到您的 LDFLAGS 中。

I know this is not the answer you want to hear (since you specified otherwise in your question), but you are running into trouble here and are likely to run into more since your compiler is buggy. You should find a way of replacing it, since you'll find yourself writing even more work-around code the next time some obscure build system comes along. There's not only bjam out there.

Sorry I can't help you more. You might try simply writing a .lo file by hand (it's a two-liner, after all) and insert it into your LDFLAGS.

影子的影子 2024-12-13 10:49:33

如果这是 GCC 4.3 的错误,您是否尝试构建(通过从源代码编译)并使用更新的 GCC。 GCC 4.6.2 即将推出。您考虑过使用它吗?

If it is a bug of GCC 4.3, did you try to build (by compiling from sources) and use a newer GCC. GCC 4.6.2 is coming right now. Did you consider using it?

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