yna*_*ame 6 c++ address-sanitizer bazel
我在 bazel 中有一个项目,具有非常简单的 bulid 规则
cc_binary(
name = "search",
srcs = [
"iterator_range.h",
"main.cpp",
"parse.cpp",
"parse.h",
"search_server.cpp",
"search_server.h",
"test_runner.h",
"profile.h",
]
)
Run Code Online (Sandbox Code Playgroud)
我越来越Segmentation fault 11
我尝试使用此配置但出现错误
every rule of type cc_binary implicitly depends upon the target '//tools/lrte:toolchain', but this target coul
d not be found because of: no such package 'tools/lrte': BUILD file not found in any of the following directories
Run Code Online (Sandbox Code Playgroud)
我尝试添加BUILD文件,tools/lrte但它导致了更多错误,例如no such attribute 'dynamic_runtime_libs' in 'cc_toolchain' rule.
文档说:
默认情况下,Bazel 会自动为您的构建配置 CcToolchainConfigInfo,但您可以选择手动配置它
由于我不想手动进行工具链配置(我认为),我尝试build:asan --crosstool_top //tools/lrte:toolchain从.bazelrc. 然后我还必须删除有关编译器的第二行,它起作用了。所以我的最终.bazelrc(.bazelrc应该在同一个目录中WORKSPACE)配置如下所示:
build:asan --strip=never
build:asan --copt -fsanitize=address
build:asan --copt -DADDRESS_SANITIZER
build:asan --copt -O1
build:asan --copt -g
build:asan --copt -fno-omit-frame-pointer
build:asan --linkopt -fsanitize=address
Run Code Online (Sandbox Code Playgroud)
使用地址清理程序运行 bazel 的方法:
bazel build -c dbg --config=asan path/to/module:target
bazel run -c dbg --config=asan path/to/module:target
Run Code Online (Sandbox Code Playgroud)