blob: da1702592fec886ef0750127c99968e7644cb697 [file] [log] [blame]
Stella Laurenzo1178c122019-10-11 10:43:07 -07001# Required bazel flags for building IREE.
2
Stella Laurenzo1178c122019-10-11 10:43:07 -07003# Disable warnings we don't care about.
4build --copt=-Wno-unused-local-typedef
5
6# C++14 standard version is required.
7build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
8
9# Default to an optimized build.
10# Override via: "-c dbg" or --compilation_mode=dbg
11build --compilation_mode=opt
12
13# Disable visibility checks (works around some private deps in TensorFlow that
14# are being unbundled soon anyway).
15build --nocheck_visibility
16
17# Enable some default cpu flags for x86 optimization.
18build:x86opt --copt=-mavx2
Stella Laurenzoaa854a12019-10-14 10:54:03 -070019
20# Experimental config for building on Windows via clang-cl.
21# As an aspiration, it may eventually not be required to manually
22# activate this config, but for now, it is a place to store the
23# set of flags and tweaks needed to get the Windows build working.
24# Note that this is intended to work with clang-cl, not the Visual
25# Studio compiler. The following must be performed prior to invoking
26# Bazel:
27# * Install Visual Studio Build Tools
28# * export USE_CLANG_CL=1
29# * export BAZEL_LLVM=C:/Users/$USER/scoop/apps/llvm/current
30# (or actual LLVM install location)
31# Then one can build with:
32# bazel build --config=windows {targets...}
33
34# Works around __TIME__ __DATE__, etc redefinitions and -std=c++14
35# warnings.
Stella Laurenzoc941ae42019-10-15 19:06:54 -070036build:windows --copt=-Wno-builtin-macro-redefined --host_copt=-Wno-builtin-macro-redefined
37build:windows --copt=-Wno-unknown-argument --host_copt=-Wno-unknown-argument
Stella Laurenzoaa854a12019-10-14 10:54:03 -070038
39# Disables windows headers from pulling in GDI, which does a lot of terrible
40# things (such as defining the ERROR macro, which breaks the world).
Stella Laurenzoc941ae42019-10-15 19:06:54 -070041build:windows --copt=-DNOGDI --host_copt=-DNOGDI
Stella Laurenzoaa854a12019-10-14 10:54:03 -070042
43# Enables unix-style runfiles link trees (requires symlink permission).
44# See: https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/
45# Generally: Enable Developer Mode in the Developer Settings page of the
46# system settings.
47build:windows --experimental_enable_runfiles
48
Stella Laurenzo3eecf142019-10-25 10:22:21 -070049###############################################################################
50# Flags to make tensorflow build.
51# Some of these are also of general use and fine to enable globally for windows.
52build:windows --copt=/arch:AVX
53# Host and target are the same in windows so don't waste time building both.
54build:windows --distinct_host_configuration=false
55# Avoids incompatible versions of winsock and other badness.
56build:windows --copt=/DWIN32_LEAN_AND_MEAN --host_copt=/DWIN32_LEAN_AND_MEAN
57# That is one way to have less warnings :(
58build:windows --per_file_copt=tensorflow@-w
59# This is used a lot and shouldn't be an error.
60build:windows --per_file_copt=tensorflow@-Wno-microsoft-unqualified-friend
61# Why are min/max macros? No one knows.
62build:windows --copt=/DNOMINMAX --host_copt=/DNOMINMAX
63# Yay for security warnings. Boo for non-standard.
64build:windows --copt=/D_CRT_SECURE_NO_WARNINGS --host_copt=/D_CRT_SECURE_NO_WARNINGS
65# TensorFlow requires the "monolithic" build mode for now on Windows.
66build:windows --define framework_shared_object=false
67# TODO(laurenzo): Clang uses runtime functions for 128bit math that require the
68# rt library and there is not a convenient way to link it. Figure out how to
69# do the following:
70# See: http://clang-developers.42468.n3.nabble.com/Issue-with-Clang-on-Windows-and-compiler-rt-builtins-td4059230.html
71build:windows --linkopt=/DEFAULTLIB:clang_rt.builtins-x86_64.lib
Stella Laurenzoa7991a92019-10-25 12:09:08 -070072build:windows --linkopt=/DEFAULTLIB:ws2_32.lib
Stella Laurenzo3eecf142019-10-25 10:22:21 -070073###############################################################################
74
Stella Laurenzo7ff35e62019-10-16 12:44:31 -070075# The user.bazelrc file is not checked in but available for local mods.
76# Always keep this at the end of the file so that user flags override.
Stella Laurenzo9fb164c2019-10-23 13:36:22 -070077try-import %workspace%/user.bazelrc
Stella Laurenzo7ff35e62019-10-16 12:44:31 -070078