Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_packages 和 add_deps 之间无法控制链接顺序 #605

Closed
fasiondog opened this issue Oct 25, 2019 · 6 comments
Closed

add_packages 和 add_deps 之间无法控制链接顺序 #605

fasiondog opened this issue Oct 25, 2019 · 6 comments
Milestone

Comments

@fasiondog
Copy link
Contributor

1、假设某库 my.so,其中 add_packags("a"), 库a以静态方式链接进so。
2、某可执行程序 test,依赖库 my.so, 但同时又要链接库 a (add_packages("a))
3、此时,add_depts 链接时总数被放在了前面,即: -lmy -la
此种情况,在某些场合可能会导致问题

@fasiondog
Copy link
Contributor Author

建议顺序:
Object files
All static libraries
libgcc
All shared libraries
And the usual prolog

@waruqi
Copy link
Member

waruqi commented Oct 25, 2019

估计是你lib.a里面默认全部default visibility编译,导致link到my.so后,所有a里面的symbols都被导出了,所以会跟后面的-la有冲突

即使按照你建议的顺序调整,也许其他用户有些场景还是需要-lmy -a的顺序需求

我先想想吧,提供个用户可自由调整 deps packages links之间顺序的方式 目前的版本还不支持。。

目前的临时解决办法是

  1. 设置默认hidden编译liba,仅对my.so里面实际需要导出的接口设置default就行了,不会冲突
  2. 或者add_deps里面设置 inherit = false禁用默认继承-lmy,然后自己手动 add_links a my 就可以了

@fasiondog
Copy link
Contributor Author

好的,这个不急

@waruqi waruqi added this to the v2.3.0 milestone Dec 20, 2019
@waruqi waruqi modified the milestones: v2.3.0, todo Feb 21, 2020
@waruqi waruqi modified the milestones: todo, v2.3.4 Apr 28, 2020
@waruqi waruqi modified the milestones: v2.3.4, v2.3.5 Jun 4, 2020
@waruqi waruqi modified the milestones: v2.3.5, v2.3.6 Jun 25, 2020
@waruqi waruqi modified the milestones: v2.3.6, todo Jul 28, 2020
@waruqi waruqi modified the milestones: todo, v2.5.2 Feb 24, 2021
@waruqi
Copy link
Member

waruqi commented Feb 25, 2021

我 dev 上改进了这个问题,会优先使用当前 target 下的 links ,最后再使用 deps 里面的。。

@waruqi
Copy link
Member

waruqi commented Sep 29, 2023

初步改进了下,试试 #1452 (comment)

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Initial improvements, try #1452 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants