blob: 58282602d4c256d1e8a57088bf5dce0604ddf05f [file] [log] [blame]
Drew Macrae78a58872021-09-07 20:52:19 +00001# 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 Macrae7ac1efb2021-09-22 16:08:28 +00005# https://docs.opentitan.org/doc/rm/c_cpp_coding_style/#cxx-version specifies
Chris Frantzdb5ae4d2022-06-21 18:32:47 -07006build --cxxopt='-std=gnu++14'
7build --conlyopt='-std=gnu11'
Drew Macrae7ac1efb2021-09-22 16:08:28 +00008
Alphan Ulusoy883d3a92022-06-09 16:42:08 -04009# Never strip debugging information so that we can produce annotated
10# disassemblies when compilation mode is fastbuild.
11build --strip='never'
12
Drew Macrae3f2e2312021-12-02 21:56:00 +000013# 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
15build --features=-all_warnings
16
Drew Macrae7ac1efb2021-09-22 16:08:28 +000017# Enable toolchain resolution with cc
18build --incompatible_enable_cc_toolchain_resolution
Drew Macrae399af402021-11-01 18:15:09 +000019
Drew Macrae3f2e2312021-12-02 21:56:00 +000020# This lets us generate key/value pairs for the workspace which can be
Drew Macrae399af402021-11-01 18:15:09 +000021# accessed like we do in util/BUILD
22build --workspace_status_command=util/get_workspace_status.sh
Chris Frantzb231f112021-12-02 15:42:10 -080023
Drew Macrae7e867022022-07-14 13:09:22 -040024# This enables convenient building for opentitan targets with the argument
25# --config=riscv32
Timothy Trippelaaf5e532022-08-29 20:19:28 -070026build:riscv32 --platforms=@crt//platforms/riscv32:opentitan
Drew Macrae7e867022022-07-14 13:09:22 -040027
Chris Frantzb231f112021-12-02 15:42:10 -080028# Generate coverage in lcov format, which can be post-processed by lcov
29# into html-formatted reports.
30coverage --combined_report=lcov --instrument_test_targets --experimental_cc_coverage
Drew Macraed5536ef2021-12-12 19:33:59 -080031
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.
37test --local_test_jobs=HOST_CPUS*0.25
Dan McArdle0d212ce2022-07-20 13:12:16 -040038
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.
46build:asan --copt -fsanitize=address
47build:asan --copt -g
48build:asan --strip=never
49build:asan --copt -fno-omit-frame-pointer
50build: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.
60build:ubsan --copt -fsanitize=undefined
61build:ubsan --copt -g
62build:ubsan --strip=never
63build:ubsan --copt -fno-omit-frame-pointer
64build:ubsan --linkopt -fsanitize=undefined
Martin Lueker-Boden7e3bb0a2022-09-05 14:38:50 -070065
Chris Frantz10450612022-10-12 10:03:48 -070066# Enable the rust 'clippy' linter.
67build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
68build --output_groups=+clippy_checks
69
Martin Lueker-Boden7e3bb0a2022-09-05 14:38:50 -070070# Import site-specific configuration.
71try-import .bazelrc-site