替代“完整存档".淡褐色 [英] Alternate to "`--whole-archive`" in bazel

查看:32
本文介绍了替代“完整存档".淡褐色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在基于bazel的c ++项目之一中链接外部静态库.我需要"whole-archive"选项来链接类似gcc或g ++ build的库:

I want to link an external static lib in one of my bazel based c++ project. I need "whole-archive" option for linking the library like gcc or g++ build:

g++ main.cc -Wl,--whole-archive -lhttp -Wl,--no-whole-archive

有人可以建议bazel中"--whole-archive"的替代内容是什么吗?

Can anybody suggest what is the alternate to "--whole-archive" in bazel?

推荐答案

遗憾的是,Alwayslink不适用于预编译的库,仅适用于由Bazel编译和链接的cc_library.有一个未记录的hack(我想我只是在这里提到它来记录它),并且它是将.a文件重命名为.lo文件.然后Bazel会将其链接为整个存档.

Sadly, alwayslink doesn't work with precompiled libraries, only with cc_library compiled and linked by Bazel. There is one undocumented hack (I guess I'm just documenting it by mentioning it here), and it's to rename .a file to .lo file. Then Bazel will link it as whole archive.

请注意,这是一种黑客行为,它将在没有警告的情况下停止工作.我们已经针对该用例制定了cc_import规则的某些变体的计划,以便将预编译的二进制文件导入到工作区中,并可以在其上设置整个存档.还不在那里.

Beware that this is a hack, and will stop working without warning. We have plans for some variation of cc_import rule exactly for this use case, to import a precompiled binary into the workspace with the ability to set whole archiveness on it. It's just not there yet.

这篇关于替代“完整存档".淡褐色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆