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