添加链接器选项以增强 HPUX 上的构建

发布于 2024-08-03 19:52:26 字数 1813 浏览 10 评论 0原文

在 HPUX 上,我需要使用 +h 链接选项来获取 boost 1.39.0 共享库以包含正确的路径。

-Wl,+h$(SPACE)-Wl,$(<[-1]:D=) 

(来自 http://www.nabble.com/HPUX-aCC:-Howto-avoid-building-boost-libraries-containing-absolute-library-path-references-when-calling- bjam-install-td17619511.html

我已经通过破解 gcc.jam 工具集文件测试了这一点:

796c796
<     "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" "$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" $(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) -shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
---
>     "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,+h$(SPACE)-Wl,$(<[-1]:D=) -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" "$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" $(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) -shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)

但现在我想要一个永久的解决方案,但我不知道如何实现。

首先,我尝试将 bjam 条件放入 actions link.dll 部分,但该部分包含 shell 命令。

然后我尝试将额外的部分添加到这些目标的 OPTIONS 变量中。但这似乎对链接没有任何影响。

最后,我尝试创建一个单独的工具集作为 gcc.jam (hpuxgcc.jam) 的副本,但我根本无法让它工作。我想还有更多地方需要更改变量名称,但 Jam 语法超出了我的理解范围。

有谁有更好的想法如何让它发挥作用?或者我应该在构建 Boost 之前将 hacky 版本转换为我运行的补丁?当然有更好的方法吗?

我猜问题是:

a)如何(在平台上有条件)将文本添加到 gcc.jam 中的链接器命令中

或者:

b)如何创建基于 gcc.jam< 的新工具集/代码>?

哪个更容易...

On HPUX I need to use the +h link option to get the boost 1.39.0 shared libraries to contain correct paths.

-Wl,+h$(SPACE)-Wl,$(<[-1]:D=) 

(From http://www.nabble.com/HPUX-aCC:-Howto-avoid-building-boost-libraries-containing-absolute-library-path-references-when-calling-bjam-install-td17619511.html)

I've tested that this works by hacking the gcc.jam toolset file:

796c796
<     "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" "$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" $(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) -shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
---
>     "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,+h$(SPACE)-Wl,$(<[-1]:D=) -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" "$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" $(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) -shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)

But now I want a permanent solution, and I can't work out how.

First I tried putting a bjam conditional in the actions link.dll section, but that section contains shell commands.

Then I tried adding the extra section to the OPTIONS variable for those targets. But that didn't seem to have any effect on the link.

Finally I tried creating a separate toolset as a copy of gcc.jam (hpuxgcc.jam), but I couldn't get that to work at all. I guess there are more places I need to change variable names, but the Jam syntax is beyond what I understand.

Does anyone have some better idea how to get this to work? Or should I just convert the hacky version into a patch I run before building Boost? Surely there's a better way?

Are guess the question is either:

a) How do I (conditional on the platform) add the text to the linker command in the gcc.jam

Or:

b) How do I create a new toolset based on gcc.jam?

Which ever is easier...

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

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

发布评论

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

评论(1

冷血 2024-08-10 19:52:26

-h 选项有什么作用?它设置了“soname”吗?如果是这样,请注意同一操作中使用的 HAVE_SONAME 和 SONAME_OPTION。然后,记下 gcc.jam 中设置的代码块:

if [ os.name ] != NT && [ os.name ] != OSF && [ os.name ] != HPUX && [ os.name ] != AIX
{
    # OSF does have an option called -soname but it does not seem to work as
    # expected, therefore it has been disabled.
    HAVE_SONAME   = "" ;
    SONAME_OPTION = -h ;
}

您可以根据您的平台进行调整。

我建议您在[email protected]上跟进此内容,这很重要Boost.Build 问题比堆栈溢出更好的地方。

What does -h option do? Does it set the "soname"? If so, note the HAVE_SONAME and SONAME_OPTION use in the same action. Then, note the block of code in gcc.jam where it is set:

if [ os.name ] != NT && [ os.name ] != OSF && [ os.name ] != HPUX && [ os.name ] != AIX
{
    # OSF does have an option called -soname but it does not seem to work as
    # expected, therefore it has been disabled.
    HAVE_SONAME   = "" ;
    SONAME_OPTION = -h ;
}

You can tweak this according to your platform.

I suggest you follow up with this on [email protected], which is much better place for Boost.Build questions than stack overflow.

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