1*da0073e9SAndroid Build Coastguard Workerbuild --cxxopt=--std=c++17 2*da0073e9SAndroid Build Coastguard Workerbuild --copt=-I. 3*da0073e9SAndroid Build Coastguard Worker# Bazel does not support including its cc_library targets as system 4*da0073e9SAndroid Build Coastguard Worker# headers. We work around this for generated code 5*da0073e9SAndroid Build Coastguard Worker# (e.g. c10/macros/cmake_macros.h) by making the generated directory a 6*da0073e9SAndroid Build Coastguard Worker# system include path. 7*da0073e9SAndroid Build Coastguard Workerbuild --copt=-isystem --copt bazel-out/k8-fastbuild/bin 8*da0073e9SAndroid Build Coastguard Workerbuild --copt=-isystem --copt bazel-out/darwin-fastbuild/bin 9*da0073e9SAndroid Build Coastguard Workerbuild --experimental_ui_max_stdouterr_bytes=2048576 10*da0073e9SAndroid Build Coastguard Worker 11*da0073e9SAndroid Build Coastguard Worker# Configuration to disable tty features for environments like CI 12*da0073e9SAndroid Build Coastguard Workerbuild:no-tty --curses no 13*da0073e9SAndroid Build Coastguard Workerbuild:no-tty --progress_report_interval 10 14*da0073e9SAndroid Build Coastguard Workerbuild:no-tty --show_progress_rate_limit 10 15*da0073e9SAndroid Build Coastguard Worker 16*da0073e9SAndroid Build Coastguard Worker# Build with GPU support by default. 17*da0073e9SAndroid Build Coastguard Workerbuild --define=cuda=true 18*da0073e9SAndroid Build Coastguard Worker# rules_cuda configuration 19*da0073e9SAndroid Build Coastguard Workerbuild --@rules_cuda//cuda:enable_cuda 20*da0073e9SAndroid Build Coastguard Workerbuild --@rules_cuda//cuda:cuda_targets=sm_52 21*da0073e9SAndroid Build Coastguard Workerbuild --@rules_cuda//cuda:compiler=nvcc 22*da0073e9SAndroid Build Coastguard Workerbuild --repo_env=CUDA_PATH=/usr/local/cuda 23*da0073e9SAndroid Build Coastguard Worker 24*da0073e9SAndroid Build Coastguard Worker# Configuration to build without GPU support 25*da0073e9SAndroid Build Coastguard Workerbuild:cpu-only --define=cuda=false 26*da0073e9SAndroid Build Coastguard Worker# define a separate build folder for faster switching between configs 27*da0073e9SAndroid Build Coastguard Workerbuild:cpu-only --platform_suffix=-cpu-only 28*da0073e9SAndroid Build Coastguard Worker# See the note on the config-less build for details about why we are 29*da0073e9SAndroid Build Coastguard Worker# doing this. We must also do it for the "-cpu-only" platform suffix. 30*da0073e9SAndroid Build Coastguard Workerbuild --copt=-isystem --copt=bazel-out/k8-fastbuild-cpu-only/bin 31*da0073e9SAndroid Build Coastguard Worker# rules_cuda configuration 32*da0073e9SAndroid Build Coastguard Workerbuild:cpu-only --@rules_cuda//cuda:enable_cuda=False 33*da0073e9SAndroid Build Coastguard Worker 34*da0073e9SAndroid Build Coastguard Worker# Definition of --config=shell 35*da0073e9SAndroid Build Coastguard Worker# interactive shell immediately before execution 36*da0073e9SAndroid Build Coastguard Workerbuild:shell --run_under="//tools/bazel_tools:shellwrap" 37*da0073e9SAndroid Build Coastguard Worker 38*da0073e9SAndroid Build Coastguard Worker# Disable all warnings for external repositories. We don't care about 39*da0073e9SAndroid Build Coastguard Worker# their warnings. 40*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt=^external/@-w 41*da0073e9SAndroid Build Coastguard Worker 42*da0073e9SAndroid Build Coastguard Worker# Set additional warnings to error level. 43*da0073e9SAndroid Build Coastguard Worker# 44*da0073e9SAndroid Build Coastguard Worker# Implementation notes: 45*da0073e9SAndroid Build Coastguard Worker# * we use file extensions to determine if we are using the C++ 46*da0073e9SAndroid Build Coastguard Worker# compiler or the cuda compiler 47*da0073e9SAndroid Build Coastguard Worker# * we use ^// at the start of the regex to only permit matching 48*da0073e9SAndroid Build Coastguard Worker# PyTorch files. This excludes external repos. 49*da0073e9SAndroid Build Coastguard Worker# 50*da0073e9SAndroid Build Coastguard Worker# Note that because this is logically a command-line flag, it is 51*da0073e9SAndroid Build Coastguard Worker# considered the word on what warnings are enabled. This has the 52*da0073e9SAndroid Build Coastguard Worker# unfortunate consequence of preventing us from disabling an error at 53*da0073e9SAndroid Build Coastguard Worker# the target level because those flags will come before these flags in 54*da0073e9SAndroid Build Coastguard Worker# the action invocation. Instead we provide per-file exceptions after 55*da0073e9SAndroid Build Coastguard Worker# this. 56*da0073e9SAndroid Build Coastguard Worker# 57*da0073e9SAndroid Build Coastguard Worker# On the bright side, this means we don't have to more broadly apply 58*da0073e9SAndroid Build Coastguard Worker# the exceptions to an entire target. 59*da0073e9SAndroid Build Coastguard Worker# 60*da0073e9SAndroid Build Coastguard Worker# Looking for CUDA flags? We have a cu_library macro that we can edit 61*da0073e9SAndroid Build Coastguard Worker# directly. Look in //tools/rules:cu.bzl for details. Editing the 62*da0073e9SAndroid Build Coastguard Worker# macro over this has the following advantages: 63*da0073e9SAndroid Build Coastguard Worker# * making changes does not require discarding the Bazel analysis 64*da0073e9SAndroid Build Coastguard Worker# cache 65*da0073e9SAndroid Build Coastguard Worker# * it allows for selective overrides on individual targets since the 66*da0073e9SAndroid Build Coastguard Worker# macro-level opts will come earlier than target level overrides 67*da0073e9SAndroid Build Coastguard Worker 68*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='^//.*\.(cpp|cc)$'@-Werror=all 69*da0073e9SAndroid Build Coastguard Worker# The following warnings come from -Wall. We downgrade them from error 70*da0073e9SAndroid Build Coastguard Worker# to warnings here. 71*da0073e9SAndroid Build Coastguard Worker# 72*da0073e9SAndroid Build Coastguard Worker# We intentionally use #pragma unroll, which is compiler specific. 73*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-error=unknown-pragmas 74*da0073e9SAndroid Build Coastguard Worker 75*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='^//.*\.(cpp|cc)$'@-Werror=extra 76*da0073e9SAndroid Build Coastguard Worker# The following warnings come from -Wextra. We downgrade them from error 77*da0073e9SAndroid Build Coastguard Worker# to warnings here. 78*da0073e9SAndroid Build Coastguard Worker# 79*da0073e9SAndroid Build Coastguard Worker# unused-parameter-compare has a tremendous amount of violations in the 80*da0073e9SAndroid Build Coastguard Worker# codebase. It will be a lot of work to fix them, just disable it for 81*da0073e9SAndroid Build Coastguard Worker# now. 82*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-unused-parameter 83*da0073e9SAndroid Build Coastguard Worker# missing-field-parameters has both a large number of violations in 84*da0073e9SAndroid Build Coastguard Worker# the codebase, but it also is used pervasively in the Python C 85*da0073e9SAndroid Build Coastguard Worker# API. There are a couple of catches though: 86*da0073e9SAndroid Build Coastguard Worker# * we use multiple versions of the Python API and hence have 87*da0073e9SAndroid Build Coastguard Worker# potentially multiple different versions of each relevant 88*da0073e9SAndroid Build Coastguard Worker# struct. They may have different numbers of fields. It will be 89*da0073e9SAndroid Build Coastguard Worker# unwieldy to support multiple versions in the same source file. 90*da0073e9SAndroid Build Coastguard Worker# * Python itself for many of these structs recommends only 91*da0073e9SAndroid Build Coastguard Worker# initializing a subset of the fields. We should respect the API 92*da0073e9SAndroid Build Coastguard Worker# usage conventions of our dependencies. 93*da0073e9SAndroid Build Coastguard Worker# 94*da0073e9SAndroid Build Coastguard Worker# Hence, we just disable this warning altogether. We may want to clean 95*da0073e9SAndroid Build Coastguard Worker# up some of the clear-cut cases that could be risky, but we still 96*da0073e9SAndroid Build Coastguard Worker# likely want to have this disabled for the most part. 97*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-missing-field-initializers 98*da0073e9SAndroid Build Coastguard Worker 99*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-unused-function 100*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-unused-variable 101*da0073e9SAndroid Build Coastguard Worker 102*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterCompositeExplicitAutograd\.cpp$'@-Wno-error=unused-function 103*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterCompositeImplicitAutograd\.cpp$'@-Wno-error=unused-function 104*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterMkldnnCPU\.cpp$'@-Wno-error=unused-function 105*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterNestedTensorCPU\.cpp$'@-Wno-error=unused-function 106*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterQuantizedCPU\.cpp$'@-Wno-error=unused-function 107*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterSparseCPU\.cpp$'@-Wno-error=unused-function 108*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterSparseCsrCPU\.cpp$'@-Wno-error=unused-function 109*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterNestedTensorMeta\.cpp$'@-Wno-error=unused-function 110*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterSparseMeta\.cpp$'@-Wno-error=unused-function 111*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterQuantizedMeta\.cpp$'@-Wno-error=unused-function 112*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:aten/src/ATen/RegisterZeroTensor\.cpp$'@-Wno-error=unused-function 113*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:torch/csrc/lazy/generated/RegisterAutogradLazy\.cpp$'@-Wno-error=unused-function 114*da0073e9SAndroid Build Coastguard Workerbuild --per_file_copt='//:torch/csrc/lazy/generated/RegisterLazy\.cpp$'@-Wno-error=unused-function 115