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 | db5ae4d | 2022-06-21 18:32:47 -0700 | [diff] [blame] | 6 | build --cxxopt='-std=gnu++14' |
| 7 | build --conlyopt='-std=gnu11' |
Drew Macrae | 7ac1efb | 2021-09-22 16:08:28 +0000 | [diff] [blame] | 8 | |
Alphan Ulusoy | 883d3a9 | 2022-06-09 16:42:08 -0400 | [diff] [blame] | 9 | # Never strip debugging information so that we can produce annotated |
| 10 | # disassemblies when compilation mode is fastbuild. |
| 11 | build --strip='never' |
| 12 | |
Drew Macrae | 3f2e231 | 2021-12-02 21:56:00 +0000 | [diff] [blame] | 13 | # Bazel embedded enables the following feature which along with -std=c11 and |
| 14 | # our codebase generates a lot of warnings by setting the -Wpedantic flag |
| 15 | build --features=-all_warnings |
| 16 | |
Drew Macrae | 7ac1efb | 2021-09-22 16:08:28 +0000 | [diff] [blame] | 17 | # Enable toolchain resolution with cc |
| 18 | build --incompatible_enable_cc_toolchain_resolution |
Drew Macrae | 399af40 | 2021-11-01 18:15:09 +0000 | [diff] [blame] | 19 | |
Drew Macrae | 3f2e231 | 2021-12-02 21:56:00 +0000 | [diff] [blame] | 20 | # 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] | 21 | # accessed like we do in util/BUILD |
| 22 | build --workspace_status_command=util/get_workspace_status.sh |
Chris Frantz | b231f11 | 2021-12-02 15:42:10 -0800 | [diff] [blame] | 23 | |
Drew Macrae | 7e86702 | 2022-07-14 13:09:22 -0400 | [diff] [blame] | 24 | # This enables convenient building for opentitan targets with the argument |
| 25 | # --config=riscv32 |
Timothy Trippel | aaf5e53 | 2022-08-29 20:19:28 -0700 | [diff] [blame] | 26 | build:riscv32 --platforms=@crt//platforms/riscv32:opentitan |
Drew Macrae | 7e86702 | 2022-07-14 13:09:22 -0400 | [diff] [blame] | 27 | |
Chris Frantz | b231f11 | 2021-12-02 15:42:10 -0800 | [diff] [blame] | 28 | # Generate coverage in lcov format, which can be post-processed by lcov |
| 29 | # into html-formatted reports. |
| 30 | coverage --combined_report=lcov --instrument_test_targets --experimental_cc_coverage |
Drew Macrae | d5536ef | 2021-12-12 19:33:59 -0800 | [diff] [blame] | 31 | |
| 32 | # Verilator is built for 4 cores and can time out if bazel is running more |
| 33 | # than 1 test per four cores. |
| 34 | # Until we get the built-in tag "cpu:4" to work for verilator tests, we can run |
| 35 | # 1 test per 4 cores to avoid verilator performance falloff and timeouts we'd |
| 36 | # otherwise see on machines with fewer than 40 cores. |
| 37 | test --local_test_jobs=HOST_CPUS*0.25 |
Dan McArdle | 0d212ce | 2022-07-20 13:12:16 -0400 | [diff] [blame] | 38 | |
| 39 | # AddressSanitizer (ASan) catches runtime out-of-bounds accesses to globals, the |
| 40 | # stack, and (less importantly for OpenTitan) the heap. ASan instruments |
| 41 | # programs at compile time and also requires a runtime library. |
| 42 | # |
| 43 | # ASan documentation: https://clang.llvm.org/docs/AddressSanitizer.html |
| 44 | # |
| 45 | # Enable ASan with --config=asan. |
| 46 | build:asan --copt -fsanitize=address |
| 47 | build:asan --copt -g |
| 48 | build:asan --strip=never |
| 49 | build:asan --copt -fno-omit-frame-pointer |
| 50 | build:asan --linkopt -fsanitize=address |
| 51 | |
| 52 | # UndefinedBehaviorSanitizer (UBSan) catches C/C++ undefined behavior at |
| 53 | # runtime, e.g. signed integer overflow. UBSan instruments programs at compile |
| 54 | # time and also requires a runtime library. |
| 55 | # |
| 56 | # UBSan documentation: |
| 57 | # https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html |
| 58 | # |
| 59 | # Enable UBSan with --config=ubsan. |
| 60 | build:ubsan --copt -fsanitize=undefined |
| 61 | build:ubsan --copt -g |
| 62 | build:ubsan --strip=never |
| 63 | build:ubsan --copt -fno-omit-frame-pointer |
| 64 | build:ubsan --linkopt -fsanitize=undefined |
Martin Lueker-Boden | 7e3bb0a | 2022-09-05 14:38:50 -0700 | [diff] [blame] | 65 | |
Chris Frantz | 1045061 | 2022-10-12 10:03:48 -0700 | [diff] [blame] | 66 | # Enable the rust 'clippy' linter. |
| 67 | build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect |
| 68 | build --output_groups=+clippy_checks |
| 69 | |
Martin Lueker-Boden | 7e3bb0a | 2022-09-05 14:38:50 -0700 | [diff] [blame] | 70 | # Import site-specific configuration. |
| 71 | try-import .bazelrc-site |