Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/695a2b27-bfe4-8005-959b-536ec4f485aa
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Assistant: 用 features + actionconfig 或 自定义 toolchain,不要直接在 ccbinary/cclibrary 里硬塞 copts,因为 ignorelist 属于 sanitizer 的 toolchain-lev… === 用 <code>features</code> + <code>action_config</code> 或 自定义 toolchain,不要直接在 cc_binary/cc_library 里硬塞 copts,因为 ignorelist 属于 sanitizer 的 toolchain-level flag。 最简洁可用的方式如下: ==== 如果你所有构建都需要同样的 ignorelist: ==== <syntaxhighlight>build --copt=-fsanitize-ignorelist=path/to/ignore.txt build --linkopt=-fsanitize-ignorelist=path/to/ignore.txt </syntaxhighlight> Clang 要求编译和链接都要加一次。 ==== <syntaxhighlight>cc_binary( ==== name = "app", srcs = ["main.cc"], copts = ["-fsanitize-ignorelist=path/to/ignore.txt"], linkopts = ["-fsanitize-ignorelist=path/to/ignore.txt"], ) </syntaxhighlight> 这是“能用但不优雅”的方式,因为 sanitizer normally 是由 --config=asan 驱动。 ==== 假设你依赖: ==== <syntaxhighlight>build --config=asan </syntaxhighlight> 你可以做一个: ===== <syntaxhighlight>build:asan --copt=-fsanitize-ignorelist=path/to/ignore.txt ===== build:asan --linkopt=-fsanitize-ignorelist=path/to/ignore.txt </syntaxhighlight> 然后: <syntaxhighlight>bazel build --config=asan //... </syntaxhighlight> ==== 如果你已经有一个 clang wrapper(比如把 ASan、UBSan flags 都封进去),加: ==== <syntaxhighlight lang="bash">export CFLAGS="$CFLAGS -fsanitize-ignorelist=path/to/ignore.txt" export CXXFLAGS="$CXXFLAGS -fsanitize-ignorelist=path/to/ignore.txt" </syntaxhighlight> Bazel 会把 wrapper 作为 compiler 调用。 ==== 如果你是用自定义 Clang toolchain(cc_toolchain_suite),你更正式的写法是: ==== <syntaxhighlight>action_config { action_name: "c-compile" flag_set { flag_group { flag: "-fsanitize-ignorelist=path/to/ignore.txt" } } } </syntaxhighlight> 但除非你已经在维护自己的 toolchain,否则没必要这么做。 ==== 如果你只是想“在 ASan 情况下自动加 ignorelist”,用: ==== ===== <syntaxhighlight>build:asan --copt=-fsanitize-ignorelist=ignore.txt ===== build:asan --linkopt=-fsanitize-ignorelist=ignore.txt </syntaxhighlight> 即可。 如果你告诉我你的当前 sanitizer 方式(--config=asan?自定义 config?还是 clang-wrapper?),我可以给你更具体的配置。
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)