# Docs
For the rules definitions, see [defs.md](./defs.md).
For examples on how to use this repository, see the [examples](../examples).
## Pure C
For targets that contain C-only code, they don't require linking against `libstdc++`. This can be
done by adding `features = ["no_libstdcxx"]` to `cc_library` or `cc_binary`. By default,
`libstdc++.so` will be linked to all `cc_library` and `cc_binary` targets as it's expected by the
Bazel ecosystem.
## Static libstdc++
If you want to link `libstdc++` statically, pass `--features static_libstdcxx` to `bazel build` and
`bazel test`. It's often a good idea to add it to your `.bazelrc` to enforce the behaviour to the
whole project.
## Using this toolchain with RBE
Add the following to your `.bazelrc`, replacing `@<gcc_toolchain_workspace>` with the name given to
the `http_archive` when importing this repository:
```shell
build --host_platform=@<gcc_toolchain_workspace>//platforms:x86_64_linux_remote
build --extra_execution_platforms=@<gcc_toolchain_workspace>//platforms:x86_64_linux_remote
build --strategy=remote
build --genrule_strategy=remote
build --spawn_strategy=remote
```
## Running sanitizers
If you want to run automated tests with the sanitizers enabled, see how we do testing under
`//tests/sanitizers`, and how we call them from CI.
For running the binaries with the sanitizers enabled, check the following topics.
### Address Sanitizer (asan)
Add the following to your `.bazelrc`:
```shell
build:asan --features asan
build:asan --strip never
build:asan --action_env ASAN_OPTIONS=detect_leaks=0:color=always
```
Then run:
```shell
bazel run --config asan //<your_binary>
```
### Leak Sanitizer (lsan)
Add the following to your `.bazelrc`:
```shell
build:lsan --features lsan
build:lsan --strip never
build:lsan --action_env LSAN_OPTIONS=verbosity=1:log_threads=1:report_objects=1
```
Then run:
```shell
bazel run --config lsan //<your_binary>
```
### Thread Sanitizer (tsan)
Add the following to your `.bazelrc`:
```shell
build:tsan --features tsan
build:tsan --strip never
build:tsan --action_env TSAN_OPTIONS=halt_on_error=1:second_deadlock_stack=1
```
Then run:
```shell
bazel run --config tsan //<your_binary>
```
### Undefined Behaviour Sanitizer (ubsan)
Add the following to your `.bazelrc`:
```shell
build:ubsan --features ubsan
build:ubsan --strip never
build:ubsan --action_env UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1
```
Then run:
```shell
bazel run --config ubsan //<your_binary>
```
没有合适的资源?快使用搜索试试~ 我知道了~
aspect-gcc-toolchain-0.4.2
需积分: 0 0 下载量 65 浏览量
2024-04-03
16:06:00
上传
评论
收藏 30KB GZ 举报
温馨提示
共62个文件
bazel:18个
bzl:9个
sh:7个
aspect-gcc-toolchain-0.4.2
资源推荐
资源详情
资源评论
收起资源包目录
gcc-toolchain-0.4.2.tar.gz (62个子文件)
gcc-toolchain-0.4.2
BUILD.bazel 0B
sysroot
BUILD.bazel 683B
build_kernel.sh 1KB
configure.sh 3KB
create_symlinks.sh 1KB
Dockerfile 13KB
flags.bzl 3KB
.gitignore 16B
README.md 816B
build.sh 2KB
rules_fortran
BUILD.bazel 653B
defs.bzl 11KB
WORKSPACE 2KB
.github
workflows
buildbuddy.sh 270B
.bazelrc.ci 1KB
engflow.sh 620B
default.yaml 4KB
renovate.json 41B
.gitattributes 34B
LICENSE 11KB
tests
sanitizers
BUILD.bazel 3KB
ubsan.c 754B
tsan.cc 1KB
asan.cc 779B
lsan.cc 758B
sanitizer_test.sh 872B
toolchain
BUILD.bazel 1KB
fortran
BUILD.bazel 1KB
action_names.bzl 1KB
defs.bzl 1KB
wrapper.sh.tpl 2KB
cc_toolchain_config.bzl 19KB
repositories.bzl 2KB
defs.bzl 22KB
examples
openssl
BUILD.bazel 2KB
hello_world_c
BUILD.bazel 1KB
main.c 747B
protobuf
BUILD.bazel 2KB
hello_world.proto 733B
avl
BUILD.bazel 702B
avl.BUILD.bazel 4KB
tabulate_fortran
BUILD.bazel 2KB
functions.f90 819B
tabulate.f90 1020B
lapack
BUILD.bazel 2KB
patches.bzl 1KB
hello_world_cpp
BUILD.bazel 2KB
names.txt 10B
main.cpp 1003B
README.md 109B
hello_world_fortran
BUILD.bazel 2KB
main.f90 728B
internal.bzl 3KB
docs
BUILD.bazel 841B
defs.md 5KB
README.md 2KB
platforms
BUILD.bazel 2KB
config
BUILD.bazel 1KB
.bazelrc 2KB
.gitignore 34B
README.md 270B
.bazelversion 6B
共 62 条
- 1
资源评论
liuzubing
- 粉丝: 48
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功