Drew Macrae | 78a5887 | 2021-09-07 20:52:19 +0000 | [diff] [blame] | 1 | # Copyright lowRISC contributors. |
| 2 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | |
Drew Macrae | 7ac1efb | 2021-09-22 16:08:28 +0000 | [diff] [blame] | 5 | # https://docs.opentitan.org/doc/rm/c_cpp_coding_style/#cxx-version specifies |
Chris Frantz | 5093115 | 2022-09-01 00:52:57 +0000 | [diff] [blame] | 6 | build --action_env=BAZEL_CXXOPTS="-std=gnu++14" |
Chris Frantz | db5ae4d | 2022-06-21 18:32:47 -0700 | [diff] [blame] | 7 | build --cxxopt='-std=gnu++14' |
| 8 | build --conlyopt='-std=gnu11' |
Drew Macrae | 7ac1efb | 2021-09-22 16:08:28 +0000 | [diff] [blame] | 9 | |
Alphan Ulusoy | 883d3a9 | 2022-06-09 16:42:08 -0400 | [diff] [blame] | 10 | # Never strip debugging information so that we can produce annotated |
| 11 | # disassemblies when compilation mode is fastbuild. |
| 12 | build --strip='never' |
| 13 | |
Drew Macrae | 3f2e231 | 2021-12-02 21:56:00 +0000 | [diff] [blame] | 14 | # Bazel embedded enables the following feature which along with -std=c11 and |
| 15 | # our codebase generates a lot of warnings by setting the -Wpedantic flag |
| 16 | build --features=-all_warnings |
| 17 | |
Drew Macrae | 7ac1efb | 2021-09-22 16:08:28 +0000 | [diff] [blame] | 18 | # Enable toolchain resolution with cc |
| 19 | build --incompatible_enable_cc_toolchain_resolution |
Drew Macrae | 399af40 | 2021-11-01 18:15:09 +0000 | [diff] [blame] | 20 | |
Drew Macrae | 3f2e231 | 2021-12-02 21:56:00 +0000 | [diff] [blame] | 21 | # This lets us generate key/value pairs for the workspace which can be |
Drew Macrae | 399af40 | 2021-11-01 18:15:09 +0000 | [diff] [blame] | 22 | # accessed like we do in util/BUILD |
| 23 | build --workspace_status_command=util/get_workspace_status.sh |
Chris Frantz | b231f11 | 2021-12-02 15:42:10 -0800 | [diff] [blame] | 24 | |
Drew Macrae | 7e86702 | 2022-07-14 13:09:22 -0400 | [diff] [blame] | 25 | # This enables convenient building for opentitan targets with the argument |
| 26 | # --config=riscv32 |
Timothy Trippel | aaf5e53 | 2022-08-29 20:19:28 -0700 | [diff] [blame] | 27 | build:riscv32 --platforms=@crt//platforms/riscv32:opentitan |
Drew Macrae | 7e86702 | 2022-07-14 13:09:22 -0400 | [diff] [blame] | 28 | |
Alphan Ulusoy | 221eeab | 2022-12-28 13:45:40 -0500 | [diff] [blame] | 29 | # Shared configuration for clang's source-based coverage instrumentation. |
| 30 | # Bazel seems to support this only partially, thus we have to perform some |
| 31 | # additional processing. See |
Alphan Ulusoy | 5377dba | 2022-12-14 08:33:21 -0500 | [diff] [blame] | 32 | # https://github.com/bazelbuild/bazel/commit/21b5eb627d78c09d47c4de957e9e6b56a9ae6fad |
| 33 | # and `util/coverage/coverage_off_target.py`. |
Alphan Ulusoy | 221eeab | 2022-12-28 13:45:40 -0500 | [diff] [blame] | 34 | build:ot_coverage --repo_env='CC=clang' |
| 35 | build:ot_coverage --repo_env='BAZEL_USE_LLVM_NATIVE_COVERAGE=1' |
| 36 | build:ot_coverage --java_runtime_version='remotejdk_11' |
| 37 | # Docs state that bazel will fail to create coverage information if tests have |
| 38 | # been cached previously. See |
| 39 | # https://bazel.build/configure/coverage?hl=en#remote-execution |
| 40 | coverage:ot_coverage --nocache_test_results |
| 41 | |
| 42 | # Configuration for measuring off-target coverage. Enable with |
| 43 | # `--config=ot_coverage_off_target`. |
| 44 | build:ot_coverage_off_target --config='ot_coverage' |
| 45 | build:ot_coverage_off_target --collect_code_coverage |
| 46 | coverage:ot_coverage_off_target --repo_env='GCOV=/usr/bin/llvm-profdata' |
| 47 | coverage:ot_coverage_off_target --repo_env='BAZEL_LLVM_COV=/usr/bin/llvm-cov' |
Drew Macrae | d5536ef | 2021-12-12 19:33:59 -0800 | [diff] [blame] | 48 | |
Alphan Ulusoy | 56a5dce | 2022-12-28 13:46:01 -0500 | [diff] [blame] | 49 | # Configuration for measuring on-target coverage. Enable with |
| 50 | # `--config=ot_coverage_on_target`. |
| 51 | build:ot_coverage_on_target --config='ot_coverage' |
| 52 | build:ot_coverage_on_target --platforms="@crt//platforms/riscv32:opentitan" |
| 53 | build:ot_coverage_on_target --define='measure_coverage_on_target=true' |
| 54 | # Instrument selectively to limit size overhead when measuring on-target coverage. |
| 55 | # Note: We have to disable optimizations until the corresponding item in #16761 is |
| 56 | # resolved. |
| 57 | build:ot_coverage_on_target --per_file_copt='//sw/device/silicon_creator[/:].*,//sw/device/lib/base:.*@-fprofile-instr-generate,-fcoverage-mapping,-O0' |
| 58 | # Needed to be able to build host binaries while collecting coverage. |
| 59 | coverage:ot_coverage_on_target --platforms="" |
| 60 | |
Drew Macrae | 5603629 | 2022-12-21 12:51:40 -0500 | [diff] [blame] | 61 | # Configuration to override resource constrained test |
| 62 | # scheduling. Enable with `--config=local_test_jobs_per_cpus` |
| 63 | test:local_test_jobs_per_cpus --local_test_jobs=HOST_CPUS*0.22 |
| 64 | # Verilator is built for 4 cores, but requires a harness and additional overhead. |
| 65 | # Empirically 72 cores can support 16 simultaneous tests, but not 17. Setting |
| 66 | # this will ignore tags like "cpu:5" |
Dan McArdle | 0d212ce | 2022-07-20 13:12:16 -0400 | [diff] [blame] | 67 | |
Drew Macrae | 5d72101 | 2022-12-10 21:55:00 -0500 | [diff] [blame] | 68 | # We have verilator tests that take more than an hour to complete |
| 69 | test --test_timeout=60,300,1500,7200 |
| 70 | |
Dan McArdle | 0d212ce | 2022-07-20 13:12:16 -0400 | [diff] [blame] | 71 | # AddressSanitizer (ASan) catches runtime out-of-bounds accesses to globals, the |
| 72 | # stack, and (less importantly for OpenTitan) the heap. ASan instruments |
| 73 | # programs at compile time and also requires a runtime library. |
| 74 | # |
| 75 | # ASan documentation: https://clang.llvm.org/docs/AddressSanitizer.html |
| 76 | # |
| 77 | # Enable ASan with --config=asan. |
| 78 | build:asan --copt -fsanitize=address |
| 79 | build:asan --copt -g |
| 80 | build:asan --strip=never |
| 81 | build:asan --copt -fno-omit-frame-pointer |
| 82 | build:asan --linkopt -fsanitize=address |
| 83 | |
| 84 | # UndefinedBehaviorSanitizer (UBSan) catches C/C++ undefined behavior at |
| 85 | # runtime, e.g. signed integer overflow. UBSan instruments programs at compile |
| 86 | # time and also requires a runtime library. |
| 87 | # |
| 88 | # UBSan documentation: |
| 89 | # https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html |
| 90 | # |
| 91 | # Enable UBSan with --config=ubsan. |
| 92 | build:ubsan --copt -fsanitize=undefined |
| 93 | build:ubsan --copt -g |
| 94 | build:ubsan --strip=never |
| 95 | build:ubsan --copt -fno-omit-frame-pointer |
| 96 | build:ubsan --linkopt -fsanitize=undefined |
Martin Lueker-Boden | 7e3bb0a | 2022-09-05 14:38:50 -0700 | [diff] [blame] | 97 | |
Chris Frantz | 1045061 | 2022-10-12 10:03:48 -0700 | [diff] [blame] | 98 | # Enable the rust 'clippy' linter. |
| 99 | build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect |
| 100 | build --output_groups=+clippy_checks |
| 101 | |
Martin Lueker-Boden | 7e3bb0a | 2022-09-05 14:38:50 -0700 | [diff] [blame] | 102 | # Import site-specific configuration. |
| 103 | try-import .bazelrc-site |