部分文章内容为公开资料查询整理,原文出处可能未标注,如有侵权,请联系我,谢谢。邮箱地址:gnivor@163.com ►►►需要气球么?请点击我吧!

bazel笔记-一些debug相关的编译选项的使用

参考资料
https://zhulao.gitee.io/blog/2019/04/05/编译构建工具-bazel/index.html

bazel build ... --compilation_mode=dbg
bazel build ... --copt -g --strip=never


bazel build ...
并且 .bazelrc 内增加以下配置

build --strip=never
build --copt=-g
build --copt=-ggdb

解释
调试与符号信息的去除
--strip (always|never|sometimes) 指定是否从二进制文件和共享库文件中去除调试信息

# 默认是 sometimes, 当语义项 --compilation_mode=fastbuild 时
bazel build --strip=always //main:hello-world

注:

  1. 即使使用了--strip=never 也不会保留 debug 信息, 如果想要得到完整符号库, 需指定使用 -c dbg 或者 --copt -g--copt -ggdb 方可
    只使用 --copt -g--copt -ggdb 是无效的,需要与--strip=never一起组合使用
bazel build -c dbg --strip=never //main:hello-world

.bazelrc内配置也一样

  1. --strip 项默认是 –strip-debug, 如果不只是想去除 debug 信息, 而是去除所有符号信息, 则需指定链接项 --strip-all
bazel build --strip=always --linkopt=-Wl,--strip-all //main:hello-world
posted @ 2022-06-10 22:40  流了个火  阅读(5082)  评论(0)    收藏  举报
►►►需要气球么?请点击我吧!►►►
View My Stats