1 # This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2 # See https://llvm.org/LICENSE.txt for license information.
3 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 ###############################################################################
6 # Common flags that apply to all configurations.
7 # Use sparingly for things common to all compilers and platforms.
8 ###############################################################################
9 # Prevent invalid caching if input files are modified during a build.
10 build --experimental_guard_against_concurrent_changes
12 ###############################################################################
13 # Options to select different strategies for linking potential dependent
14 # libraries. The default leaves it disabled.
15 ###############################################################################
17 build:zlib_external --repo_env=BAZEL_LLVM_ZLIB_STRATEGY=external
18 build:zlib_system --repo_env=BAZEL_LLVM_ZLIB_STRATEGY=system
20 build:terminfo_external --repo_env=BAZEL_LLVM_TERMINFO_STRATEGY=external
21 build:terminfo_system --repo_env=BAZEL_LLVM_TERMINFO_STRATEGY=system
23 ###############################################################################
24 # Options for "generic_clang" builds: these options should generally apply to
25 # builds using a Clang-based compiler, and default to the `clang` executable on
26 # the `PATH`. While these are provided for convenience and may serve as a
27 # reference, it would be preferable for users to configure an explicit C++
28 # toolchain instead of relying on `.bazelrc` files.
29 ###############################################################################
31 # Set the default compiler to the `clang` binary on the `PATH`.
32 build:generic_clang --repo_env=CC=clang
34 # C++14 standard version is required.
35 build:generic_clang --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
37 # The Clang available on MacOS has a warning that isn't clean on MLIR code. The
38 # warning doesn't show up with more recent Clangs, so just disable for now.
39 build:generic_clang --cxxopt=-Wno-range-loop-analysis --host_cxxopt=-Wno-range-loop-analysis
41 # Use `-Wall` and `-Werror` for Clang.
42 build:generic_clang --copt=-Wall --copt=-Werror --host_copt=-Wall --host_copt=-Werror
43 # This doesn't appear to be enforced by any upstream bot.
44 build:generic_clang --copt=-Wno-unused --host_copt=-Wno-unused
46 ###############################################################################
47 # Options for "generic_gcc" builds: these options should generally apply to
48 # builds using a GCC-based compiler, and default to the `gcc` executable on
49 # the `PATH`. While these are provided for convenience and may serve as a
50 # reference, it would be preferable for users to configure an explicit C++
51 # toolchain instead of relying on `.bazelrc` files.
52 ###############################################################################
54 # Set the default compiler to the `gcc` binary on the `PATH`.
55 build:generic_gcc --repo_env=CC=gcc
57 # C++14 standard version is required.
58 build:generic_gcc --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
60 # Disable GCC warnings that are noisy and/or false positives on LLVM code.
61 # These need to be global as some code triggering these is in header files.
62 build:generic_gcc --copt=-Wno-unused-parameter --host_copt=-Wno-unused-parameter
63 build:generic_gcc --copt=-Wno-comment --host_copt=-Wno-comment
64 build:generic_gcc --cxxopt=-Wno-class-memaccess --host_cxxopt=-Wno-class-memaccess
65 build:generic_gcc --copt=-Wno-maybe-uninitialized --host_copt=-Wno-maybe-uninitialized
66 build:generic_gcc --copt=-Wno-misleading-indentation --host_copt=-Wno-misleading-indentation
68 # Use `-Werror` for GCC to make sure warnings don't slip past.
69 build:generic_gcc --copt=-Werror --host_copt=-Werror
71 ###############################################################################
72 # Windows specific flags for building with VC.
73 ###############################################################################
75 build:msvc --copt=/WX --host_copt=/WX # Treat warnings as errors...
76 # ...but disable the ones that are violated
77 build:msvc --copt=/wd4141 --host_copt=/wd4141 # inline used more than once
78 build:msvc --copt=/wd4244 --host_copt=/wd4244 # conversion type -> type
79 build:msvc --copt=/wd4267 --host_copt=/wd4267 # conversion size_t -> type
80 build:msvc --copt=/wd4273 --host_copt=/wd4273 # multiple definitions with different dllimport
81 build:msvc --copt=/wd4319 --host_copt=/wd4319 # zero-extending after complement
82 build:msvc --copt=/wd4624 --host_copt=/wd4624 # destructor was implicitly defined as deleted
83 build:msvc --copt=/wd4804 --host_copt=/wd4804 # comparisons between bool and int
84 build:msvc --copt=/wd4805 --host_copt=/wd4805 # comparisons between bool and int
86 build:msvc --linkopt=/WX --host_linkopt=/WX # Treat warnings as errors...
87 # ...but disable the ones that are violated.
88 build:msvc --linkopt=/IGNORE:4001 --host_linkopt=/IGNORE:4001 # no object files
90 # Yay for security warnings. Boo for non-standard.
91 build:msvc --copt=/D_CRT_SECURE_NO_WARNINGS --host_copt=/D_CRT_SECURE_NO_WARNINGS
93 ###############################################################################
95 ###############################################################################
96 # Configuration for building remotely using Remote Build Execution (RBE)
97 # Based on https://github.com/bazelbuild/bazel-toolchains/blob/master/bazelrc/bazel-1.0.0.bazelrc
98 ###############################################################################
100 build:rbe --remote_instance_name=projects/llvm-bazel/instances/default_instance
102 # Depending on how many machines are in the remote execution instance, setting
103 # this higher can make builds faster by allowing more jobs to run in parallel.
104 # Setting it too high can result in jobs that timeout, however, while waiting
105 # for a remote machine to execute them.
108 # Set several flags related to specifying the platform, toolchain and java
110 # These flags should only be used as is for the rbe-ubuntu16-04 container
111 # and need to be adapted to work with other toolchain containers.
112 build:rbe --host_javabase=@rbe_default//java:jdk
113 build:rbe --javabase=@rbe_default//java:jdk
114 build:rbe --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
115 build:rbe --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
116 build:rbe --crosstool_top=@rbe_default//cc:toolchain
117 build:rbe --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
119 # The toolchain container used for execution is defined in the target indicated
120 # by "extra_execution_platforms", "host_platform" and "platforms".
121 # More about platforms: https://docs.bazel.build/versions/master/platforms.html
122 build:rbe --extra_toolchains=@rbe_default//config:cc-toolchain
123 build:rbe --extra_execution_platforms=@rbe_default//config:platform
124 build:rbe --host_platform=@rbe_default//config:platform
125 build:rbe --platforms=@rbe_default//config:platform
127 build:rbe --define=EXECUTOR=remote
129 # Enable remote execution so actions are performed on the remote systems.
130 build:rbe --remote_executor=grpcs://remotebuildexecution.googleapis.com
132 # Enforce stricter environment rules, which eliminates some non-hermetic
133 # behavior and therefore improves both the remote cache hit rate and the
134 # correctness and repeatability of the build.
135 build:rbe --incompatible_strict_action_env=true
137 # Set a higher timeout value, just in case.
138 build:rbe --remote_timeout=3600
140 # Local disk cache is incompatible with remote execution (for obvious reasons).
141 build:rbe --disk_cache=""
143 # Enable authentication. This will pick up application default credentials by
144 # default. You can use --google_credentials=some_file.json to use a service
145 # account credential instead.
146 build:rbe --google_default_credentials=true
148 # The user.bazelrc file is not checked in but available for local mods.
149 # Always keep this at the end of the file so that user flags override.
150 try-import %workspace%/user.bazelrc