Skip to content
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

Add extra_compiler_files attribute to make ignorelist files available to sanitizers during compilation #245

Merged
merged 4 commits into from
Mar 13, 2024

Conversation

lalten
Copy link
Contributor

@lalten lalten commented Jan 12, 2024

I'm adding sanitizers into our build and I need the compilation action to have access to the sanitizer blacklist.

# In MODULE.bazel
llvm.toolchain(
    name = "llvm_toolchain",
    (...)
    extra_compiler_files = "@@//tools/sanitizers:compiletime_ignorelist.txt",
)
# In .bazelrc
build:sanitizers --copt -fsanitize-ignorelist=tools/sanitizers/compiletime_ignorelist.txt

The compiletime_ignorelist.txt is a https://releases.llvm.org/17.0.1/tools/clang/docs/SanitizerSpecialCaseList.html

I'd like to hear feedback if you think this is a good idea, maybe there are better alternatives?

@lalten lalten marked this pull request as ready for review January 12, 2024 13:31
@lalten lalten changed the title Add extra_compiler_files attribute to make suppression files available to sanitizers during compilation Add extra_compiler_files attribute to make ignorelist files available to sanitizers during compilation Jan 13, 2024
@siddharthab siddharthab merged commit dd35164 into bazel-contrib:master Mar 13, 2024
35 checks passed
@siddharthab
Copy link
Contributor

Thanks for the contribution.

@lalten lalten deleted the extra_compiler_files branch March 13, 2024 08:31
jez pushed a commit to sorbet/bazel-toolchain that referenced this pull request May 28, 2024
This helps inject files into the compiler action sandbox. The files can then be used in the compiler command line, e.g. the sanitizer ignore list.

---------

Co-authored-by: Siddhartha Bagaria <starsid@gmail.com>
@myrrc
Copy link

myrrc commented Jul 10, 2024

Hey @lalten. Does this work with legacy non-MODULE builds? I've tried integrating it into our codebase, but having this file in project root, bazel complains about

ERROR: no such package '@@llvm_toolchain//sanitizer_ignore.txt': BUILD file not found in directory 'sanitizer_ignore.txt' of external repository @@llvm_toolchain. Add a BUILD file to a directory to mark it as a package.
ERROR: /home/myrrc/.cache/bazel/_bazel_myrrc/7a4fea5dac5e95bf5e0bf58faa801eff/external/llvm_toolchain/BUILD.bazel:114:10: no such package '@@llvm_toolchain//sanitizer_ignore.txt': BUILD file not found in directory 'sanitizer_ignore.txt' of external repository @@llvm_toolchain. Add a BUILD file to a directory to mark it as a package. and referenced by '@@llvm_toolchain//:compiler-components-x86_64-linux'

i.e. it tries to find the file in the external repository rather than in the project.

Specifying the repository explicitly e.g. @@myrepo//:sanitizer_ignore.txt leads to a loop.

@lalten
Copy link
Contributor Author

lalten commented Jul 24, 2024

Hey @lalten. Does this work with legacy non-MODULE builds? I've tried integrating it into our codebase, but having this file in project root, bazel complains about

ERROR: no such package '@@llvm_toolchain//sanitizer_ignore.txt': BUILD file not found in directory 'sanitizer_ignore.txt' of external repository @@llvm_toolchain. Add a BUILD file to a directory to mark it as a package.
ERROR: /home/myrrc/.cache/bazel/_bazel_myrrc/7a4fea5dac5e95bf5e0bf58faa801eff/external/llvm_toolchain/BUILD.bazel:114:10: no such package '@@llvm_toolchain//sanitizer_ignore.txt': BUILD file not found in directory 'sanitizer_ignore.txt' of external repository @@llvm_toolchain. Add a BUILD file to a directory to mark it as a package. and referenced by '@@llvm_toolchain//:compiler-components-x86_64-linux'

i.e. it tries to find the file in the external repository rather than in the project.

Specifying the repository explicitly e.g. @@myrepo//:sanitizer_ignore.txt leads to a loop.

I have not tried using this on WORKSPACE :/
Did you find a solution?

@myrrc
Copy link

myrrc commented Jul 24, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants