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
flto 对静态库使用时出错 #5015
Comments
Title: flto Error when using static library |
try it again. |
|
加了 |
👌 |
add |
我把环境清理了下 然后链接又报错了
stack traceback: |
再试下, #5024 xmake update -s dev |
Try again xmake update -s dev |
这下可以了👌 |
It’s okay now 👌 |
用 gcc-ar 也有很多问题,会 break 其他用户的一些项目。。#5051 |
另外一种方案就是用回 ar ,然后参考 gcc-ar 的实现,当开启 lto 时候,xmake 内部自己找 liblto_plugin.so 然后传入 ar 中去。 但不知道对高版本是否兼容,你可以先手动测试验证下,如果ok,我可以尝试这么改下 ar rcsT --plugin /usr/libexec/gcc/x86_64-redhat-linux/5.3.1/liblto_plugin.so library.a library.o |
Another solution is to use ar, and then refer to the implementation of gcc-ar. When lto is turned on, xmake internally finds liblto_plugin.so and passes it to ar. ar rcsT --plugin /usr/libexec/gcc/x86_64-redhat-linux/5.3.1/liblto_plugin.so library.a library.o |
手动加可以的 生成是正常的 就是这个库找起来麻烦 |
You can add it manually. The generation is normal. It’s just that this library is troublesome to find. |
还有一点不太确定是cmake类型的包 怎么去传递这个 |
路径是能找到了,你可以试试 #5087 不过目前只能对 target 生效,不支持 package 和 ranlib 。。还得想办法再改进 |
能传,得包里面处理,不过暂时还没空弄 |
target 是正常的 如果没时间弄 package那就先把 package 的 -flto传递关掉 不然package会出问题
|
Another thing I'm not sure about is the cmake type package. How to pass this |
The path can be found, you can try #5087 However, it currently only takes effect on target, and package and ranlib are not supported. . We still have to think of ways to improve it. |
It can be transferred, but it needs to be processed in the package, but I haven’t had time to do it yet. |
你能确定是哪个版本以下才开始有这个问题的么。 |
Can you determine which version this problem started to occur from? |
手里的arm-none-linux-eabihf 从5.4 到10.3版本都不行... 手里没有更高版本了 |
The arm-none-linux-eabihf in my hand does not work with versions 5.4 to 10.3... There is no updated version in my hand. |
现在这个 patch 应该差不多了。。#5087 |
试过了 可以package都正常了 |
I tried it and the package works fine. |
Xmake 版本
v2.8.5+master
操作系统版本和架构
ubuntu23.10
描述问题
使用老版本gcc工具并且开启 set_policy("build.optimization.lto", true)时编译静态库时链接出错 而高版本gcc没有这个问题
期待的结果
1.如果手动执行ar -cr 会得到警告
/home/wangyang/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar -cr build/linux/x86_64/release/libtest.a build/.objs/test/linux/x86_64/release/test.cpp.o
/home/wangyang/toolchain/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar: build/.objs/test/linux/x86_64/release/test.cpp.o: plugin needed to handle lto object
2.这里的ar应该用gcc-ar替代
https://stackoverflow.com/questions/48777554/what-is-the-difference-between-ar-nm-and-gcc-ar-gcc-nm
老版本的ar对flto有问题需 要用gcc-ar替代 ranlib应该用gcc-ranlib替代
工程配置
wine.tar.gz
附加信息和错误日志
The text was updated successfully, but these errors were encountered: