1*b16991f9SAndroid Build Coastguard Worker# This file is based on tensorflow's (v2.2.0) .bazelrc found here: 2*b16991f9SAndroid Build Coastguard Worker# https://github.com/tensorflow/tensorflow/blob/v2.2.0/.bazelrc 3*b16991f9SAndroid Build Coastguard Worker 4*b16991f9SAndroid Build Coastguard Worker# Sets the default Apple platform to macOS. 5*b16991f9SAndroid Build Coastguard Worker 6*b16991f9SAndroid Build Coastguard Workerbuild --apple_platform_type=macos 7*b16991f9SAndroid Build Coastguard Worker 8*b16991f9SAndroid Build Coastguard Worker# Enable using platform specific build settings 9*b16991f9SAndroid Build Coastguard Workerbuild --enable_platform_specific_config 10*b16991f9SAndroid Build Coastguard Worker 11*b16991f9SAndroid Build Coastguard Worker# Flag to enable remote config. Required starting from TF 2.2. 12*b16991f9SAndroid Build Coastguard Workercommon --experimental_repo_remote_exec 13*b16991f9SAndroid Build Coastguard Worker 14*b16991f9SAndroid Build Coastguard Worker# For workaround https://github.com/bazelbuild/bazel/issues/8772 with Bazel >= 0.29.1 15*b16991f9SAndroid Build Coastguard Workerbuild --java_toolchain=//third_party/toolchains/java:tf_java_toolchain 16*b16991f9SAndroid Build Coastguard Workerbuild --host_java_toolchain=//third_party/toolchains/java:tf_java_toolchain 17*b16991f9SAndroid Build Coastguard Worker 18*b16991f9SAndroid Build Coastguard Worker# Suppress C++ compiler warnings, otherwise build logs become 10s of MBs. 19*b16991f9SAndroid Build Coastguard Workerbuild:android --copt=-w 20*b16991f9SAndroid Build Coastguard Workerbuild:linux --copt=-w 21*b16991f9SAndroid Build Coastguard Workerbuild:macos --copt=-w 22*b16991f9SAndroid Build Coastguard Workerbuild:windows --copt=/w 23*b16991f9SAndroid Build Coastguard Worker 24*b16991f9SAndroid Build Coastguard Worker# Android workspace configurations. Should be replaced by an interative configure in the future. 25*b16991f9SAndroid Build Coastguard Workerbuild --action_env ANDROID_NDK_HOME 26*b16991f9SAndroid Build Coastguard Workerbuild --action_env ANDROID_NDK_API_LEVEL 27*b16991f9SAndroid Build Coastguard Workerbuild --action_env ANDROID_BUILD_TOOLS_VERSION 28*b16991f9SAndroid Build Coastguard Workerbuild --action_env ANDROID_SDK_API_LEVEL 29*b16991f9SAndroid Build Coastguard Workerbuild --action_env ANDROID_SDK_HOME 30*b16991f9SAndroid Build Coastguard Worker 31*b16991f9SAndroid Build Coastguard Worker# Android configs. Bazel needs to have --cpu and --fat_apk_cpu both set to the 32*b16991f9SAndroid Build Coastguard Worker# target CPU to build transient dependencies correctly. See 33*b16991f9SAndroid Build Coastguard Worker# https://docs.bazel.build/versions/master/user-manual.html#flag--fat_apk_cpu 34*b16991f9SAndroid Build Coastguard Worker 35*b16991f9SAndroid Build Coastguard Workerbuild:android --crosstool_top=//external:android/crosstool 36*b16991f9SAndroid Build Coastguard Workerbuild:android --host_crosstool_top=@bazel_tools//tools/cpp:toolchain 37*b16991f9SAndroid Build Coastguard Workerbuild:android_arm --config=android 38*b16991f9SAndroid Build Coastguard Workerbuild:android_arm --cpu=armeabi-v7a 39*b16991f9SAndroid Build Coastguard Workerbuild:android_arm --fat_apk_cpu=armeabi-v7a 40*b16991f9SAndroid Build Coastguard Workerbuild:android_arm64 --config=android 41*b16991f9SAndroid Build Coastguard Workerbuild:android_arm64 --cpu=arm64-v8a 42*b16991f9SAndroid Build Coastguard Workerbuild:android_arm64 --fat_apk_cpu=arm64-v8a 43*b16991f9SAndroid Build Coastguard Workerbuild:android_x86 --config=android 44*b16991f9SAndroid Build Coastguard Workerbuild:android_x86 --cpu=x86 45*b16991f9SAndroid Build Coastguard Workerbuild:android_x86 --fat_apk_cpu=x86 46*b16991f9SAndroid Build Coastguard Workerbuild:android_x86_64 --config=android 47*b16991f9SAndroid Build Coastguard Workerbuild:android_x86_64 --cpu=x86_64 48*b16991f9SAndroid Build Coastguard Workerbuild:android_x86_64 --fat_apk_cpu=x86_64 49*b16991f9SAndroid Build Coastguard Worker 50*b16991f9SAndroid Build Coastguard Worker# iOS configs for each architecture and the fat binary builds. 51*b16991f9SAndroid Build Coastguard Workerbuild:ios --apple_platform_type=ios 52*b16991f9SAndroid Build Coastguard Workerbuild:ios --apple_bitcode=embedded --copt=-fembed-bitcode 53*b16991f9SAndroid Build Coastguard Workerbuild:ios --copt=-Wno-c++11-narrowing 54*b16991f9SAndroid Build Coastguard Workerbuild:ios_armv7 --config=ios 55*b16991f9SAndroid Build Coastguard Workerbuild:ios_armv7 --cpu=ios_armv7 56*b16991f9SAndroid Build Coastguard Workerbuild:ios_arm64 --config=ios 57*b16991f9SAndroid Build Coastguard Workerbuild:ios_arm64 --cpu=ios_arm64 58*b16991f9SAndroid Build Coastguard Workerbuild:ios_x86_64 --config=ios 59*b16991f9SAndroid Build Coastguard Workerbuild:ios_x86_64 --cpu=ios_x86_64 60*b16991f9SAndroid Build Coastguard Workerbuild:ios_fat --config=ios 61*b16991f9SAndroid Build Coastguard Workerbuild:ios_fat --ios_multi_cpus=armv7,arm64,x86_64 62*b16991f9SAndroid Build Coastguard Worker 63*b16991f9SAndroid Build Coastguard Worker# By default, build TF in C++ 14 mode. 64*b16991f9SAndroid Build Coastguard Workerbuild:android --cxxopt=-std=c++14 65*b16991f9SAndroid Build Coastguard Workerbuild:android --host_cxxopt=-std=c++14 66*b16991f9SAndroid Build Coastguard Workerbuild:ios --cxxopt=-std=c++14 67*b16991f9SAndroid Build Coastguard Workerbuild:ios --host_cxxopt=-std=c++14 68*b16991f9SAndroid Build Coastguard Workerbuild:linux --cxxopt=-std=c++14 69*b16991f9SAndroid Build Coastguard Workerbuild:linux --host_cxxopt=-std=c++14 70*b16991f9SAndroid Build Coastguard Workerbuild:macos --cxxopt=-std=c++14 71*b16991f9SAndroid Build Coastguard Workerbuild:macos --host_cxxopt=-std=c++14 72*b16991f9SAndroid Build Coastguard Workerbuild:windows --cxxopt=/std:c++14 73*b16991f9SAndroid Build Coastguard Workerbuild:windows --host_cxxopt=/std:c++14 74*b16991f9SAndroid Build Coastguard Worker 75*b16991f9SAndroid Build Coastguard Worker# Config to use a mostly-static build and disable modular op registration 76*b16991f9SAndroid Build Coastguard Worker# support (this will revert to loading TensorFlow with RTLD_GLOBAL in Python). 77*b16991f9SAndroid Build Coastguard Worker# By default, TensorFlow will build with a dependence on 78*b16991f9SAndroid Build Coastguard Worker# //tensorflow:libtensorflow_framework.so. 79*b16991f9SAndroid Build Coastguard Workerbuild:monolithic --define framework_shared_object=false 80*b16991f9SAndroid Build Coastguard Worker 81*b16991f9SAndroid Build Coastguard Worker# For projects which use TensorFlow as part of a Bazel build process, putting 82*b16991f9SAndroid Build Coastguard Worker# nothing in a bazelrc will default to a monolithic build. The following line 83*b16991f9SAndroid Build Coastguard Worker# opts in to modular op registration support by default. 84*b16991f9SAndroid Build Coastguard Workerbuild --define framework_shared_object=true 85*b16991f9SAndroid Build Coastguard Worker 86*b16991f9SAndroid Build Coastguard Worker# ASAN build 87*b16991f9SAndroid Build Coastguard Workerbuild:asan --strip=never 88*b16991f9SAndroid Build Coastguard Workerbuild:asan --copt -fsanitize=address 89*b16991f9SAndroid Build Coastguard Workerbuild:asan --copt -DADDRESS_SANITIZER 90*b16991f9SAndroid Build Coastguard Workerbuild:asan --copt -O1 91*b16991f9SAndroid Build Coastguard Workerbuild:asan --copt -g 92*b16991f9SAndroid Build Coastguard Workerbuild:asan --copt -fno-omit-frame-pointer 93*b16991f9SAndroid Build Coastguard Workerbuild:asan --linkopt -fsanitize=address 94*b16991f9SAndroid Build Coastguard Worker 95*b16991f9SAndroid Build Coastguard Worker# Flags for open source build, always set to be true. 96*b16991f9SAndroid Build Coastguard Workerbuild --define open_source_build=true 97*b16991f9SAndroid Build Coastguard Workertest --define open_source_build=true 98*b16991f9SAndroid Build Coastguard Worker 99*b16991f9SAndroid Build Coastguard Worker# dbg config, as a shorthand for '--config=opt -c dbg' 100*b16991f9SAndroid Build Coastguard Workerbuild:dbg --config=opt -c dbg 101*b16991f9SAndroid Build Coastguard Worker# for now, disable arm_neon. see: https://github.com/tensorflow/tensorflow/issues/33360 102*b16991f9SAndroid Build Coastguard Workerbuild:dbg --cxxopt -DTF_LITE_DISABLE_X86_NEON 103*b16991f9SAndroid Build Coastguard Worker# AWS SDK must be compiled in release mode. see: https://github.com/tensorflow/tensorflow/issues/37498 104*b16991f9SAndroid Build Coastguard Workerbuild:dbg --copt -DDEBUG_BUILD 105*b16991f9SAndroid Build Coastguard Worker 106*b16991f9SAndroid Build Coastguard Workerbuild --define=use_fast_cpp_protos=true 107*b16991f9SAndroid Build Coastguard Workerbuild --define=allow_oversize_protos=true 108*b16991f9SAndroid Build Coastguard Worker 109*b16991f9SAndroid Build Coastguard Workerbuild --spawn_strategy=standalone 110*b16991f9SAndroid Build Coastguard Workerbuild -c opt 111*b16991f9SAndroid Build Coastguard Worker 112*b16991f9SAndroid Build Coastguard Worker# Adding "--cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0" creates parity with TF 113*b16991f9SAndroid Build Coastguard Worker# compilation options. It also addresses memory use due to 114*b16991f9SAndroid Build Coastguard Worker# copy-on-write semantics of std::strings of the older ABI. 115*b16991f9SAndroid Build Coastguard Workerbuild --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0 116*b16991f9SAndroid Build Coastguard Worker 117*b16991f9SAndroid Build Coastguard Worker# Make Bazel print out all options from rc files. 118*b16991f9SAndroid Build Coastguard Workerbuild --announce_rc 119*b16991f9SAndroid Build Coastguard Worker 120*b16991f9SAndroid Build Coastguard Worker# Other build flags. 121*b16991f9SAndroid Build Coastguard Workerbuild --define=grpc_no_ares=true 122*b16991f9SAndroid Build Coastguard Worker 123*b16991f9SAndroid Build Coastguard Worker# See https://github.com/bazelbuild/bazel/issues/7362 for information on what 124*b16991f9SAndroid Build Coastguard Worker# --incompatible_remove_legacy_whole_archive flag does. 125*b16991f9SAndroid Build Coastguard Worker# This flag is set to true in Bazel 1.0 and newer versions. We tried to migrate 126*b16991f9SAndroid Build Coastguard Worker# Tensorflow to the default, however test coverage wasn't enough to catch the 127*b16991f9SAndroid Build Coastguard Worker# errors. 128*b16991f9SAndroid Build Coastguard Worker# There is ongoing work on Bazel team's side to provide support for transitive 129*b16991f9SAndroid Build Coastguard Worker# shared libraries. As part of migrating to transitive shared libraries, we 130*b16991f9SAndroid Build Coastguard Worker# hope to provide a better mechanism for control over symbol exporting, and 131*b16991f9SAndroid Build Coastguard Worker# then tackle this issue again. 132*b16991f9SAndroid Build Coastguard Worker# 133*b16991f9SAndroid Build Coastguard Worker# TODO: Remove this line once TF doesn't depend on Bazel wrapping all library 134*b16991f9SAndroid Build Coastguard Worker# archives in -whole_archive -no_whole_archive. 135*b16991f9SAndroid Build Coastguard Workerbuild --noincompatible_remove_legacy_whole_archive 136*b16991f9SAndroid Build Coastguard Worker 137*b16991f9SAndroid Build Coastguard Worker# These are bazel 2.0's incompatible flags. Tensorflow needs to use bazel 2.0.0 138*b16991f9SAndroid Build Coastguard Worker# to use cc_shared_library, as part of the Tensorflow Build Improvements RFC: 139*b16991f9SAndroid Build Coastguard Worker# https://github.com/tensorflow/community/pull/179 140*b16991f9SAndroid Build Coastguard Workerbuild --noincompatible_prohibit_aapt1 141*b16991f9SAndroid Build Coastguard Worker 142*b16991f9SAndroid Build Coastguard Worker# Build TF with C++ 17 features. 143*b16991f9SAndroid Build Coastguard Workerbuild:c++17 --cxxopt=-std=c++1z 144*b16991f9SAndroid Build Coastguard Workerbuild:c++17 --cxxopt=-stdlib=libc++ 145*b16991f9SAndroid Build Coastguard Workerbuild:c++1z --config=c++17 146*b16991f9SAndroid Build Coastguard Worker 147*b16991f9SAndroid Build Coastguard Worker# Enable using platform specific build settings, except when cross-compiling for 148*b16991f9SAndroid Build Coastguard Worker# mobile platforms. 149*b16991f9SAndroid Build Coastguard Workerbuild --enable_platform_specific_config 150*b16991f9SAndroid Build Coastguard Workerbuild:android --noenable_platform_specific_config 151*b16991f9SAndroid Build Coastguard Workerbuild:ios --noenable_platform_specific_config 152*b16991f9SAndroid Build Coastguard Worker 153*b16991f9SAndroid Build Coastguard Worker# Suppress all warning messages. 154*b16991f9SAndroid Build Coastguard Workerbuild:short_logs --output_filter=DONT_MATCH_ANYTHING 155*b16991f9SAndroid Build Coastguard Workerbuild:verbose_logs --output_filter= 156*b16991f9SAndroid Build Coastguard Workerbuild --config=short_logs 157*b16991f9SAndroid Build Coastguard Worker 158*b16991f9SAndroid Build Coastguard Worker# Options to build TensorFlow 1.x or 2.x. 159*b16991f9SAndroid Build Coastguard Workerbuild:v1 --define=tf_api_version=1 160*b16991f9SAndroid Build Coastguard Workerbuild:v2 --define=tf_api_version=2 161*b16991f9SAndroid Build Coastguard Workerbuild:v1 --action_env=TF2_BEHAVIOR=0 162*b16991f9SAndroid Build Coastguard Workerbuild:v2 --action_env=TF2_BEHAVIOR=1 163*b16991f9SAndroid Build Coastguard Workerbuild --config=v2 164*b16991f9SAndroid Build Coastguard Workertest --config=v2 165*b16991f9SAndroid Build Coastguard Worker 166*b16991f9SAndroid Build Coastguard Worker# Options from ./configure 167*b16991f9SAndroid Build Coastguard Workertry-import %workspace%/.tf_configure.bazelrc 168*b16991f9SAndroid Build Coastguard Worker 169*b16991f9SAndroid Build Coastguard Worker# Put user-specific options in .bazelrc.user 170*b16991f9SAndroid Build Coastguard Workertry-import %workspace%/.bazelrc.user 171