Stella Laurenzo | 1178c12 | 2019-10-11 10:43:07 -0700 | [diff] [blame] | 1 | # Required bazel flags for building IREE. |
| 2 | |
Stella Laurenzo | 1178c12 | 2019-10-11 10:43:07 -0700 | [diff] [blame] | 3 | # Disable warnings we don't care about. |
| 4 | build --copt=-Wno-unused-local-typedef |
| 5 | |
| 6 | # C++14 standard version is required. |
| 7 | build --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 |
| 11 | build --compilation_mode=opt |
| 12 | |
| 13 | # Disable visibility checks (works around some private deps in TensorFlow that |
| 14 | # are being unbundled soon anyway). |
| 15 | build --nocheck_visibility |
| 16 | |
| 17 | # Enable some default cpu flags for x86 optimization. |
| 18 | build:x86opt --copt=-mavx2 |
Stella Laurenzo | aa854a1 | 2019-10-14 10:54:03 -0700 | [diff] [blame] | 19 | |
| 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 Laurenzo | c941ae4 | 2019-10-15 19:06:54 -0700 | [diff] [blame] | 36 | build:windows --copt=-Wno-builtin-macro-redefined --host_copt=-Wno-builtin-macro-redefined |
| 37 | build:windows --copt=-Wno-unknown-argument --host_copt=-Wno-unknown-argument |
Stella Laurenzo | aa854a1 | 2019-10-14 10:54:03 -0700 | [diff] [blame] | 38 | |
| 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 Laurenzo | c941ae4 | 2019-10-15 19:06:54 -0700 | [diff] [blame] | 41 | build:windows --copt=-DNOGDI --host_copt=-DNOGDI |
Stella Laurenzo | aa854a1 | 2019-10-14 10:54:03 -0700 | [diff] [blame] | 42 | |
| 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. |
| 47 | build:windows --experimental_enable_runfiles |
| 48 | |
Stella Laurenzo | 3eecf14 | 2019-10-25 10:22:21 -0700 | [diff] [blame] | 49 | ############################################################################### |
| 50 | # Flags to make tensorflow build. |
| 51 | # Some of these are also of general use and fine to enable globally for windows. |
| 52 | build:windows --copt=/arch:AVX |
| 53 | # Host and target are the same in windows so don't waste time building both. |
| 54 | build:windows --distinct_host_configuration=false |
| 55 | # Avoids incompatible versions of winsock and other badness. |
| 56 | build:windows --copt=/DWIN32_LEAN_AND_MEAN --host_copt=/DWIN32_LEAN_AND_MEAN |
| 57 | # That is one way to have less warnings :( |
| 58 | build:windows --per_file_copt=tensorflow@-w |
| 59 | # This is used a lot and shouldn't be an error. |
| 60 | build:windows --per_file_copt=tensorflow@-Wno-microsoft-unqualified-friend |
| 61 | # Why are min/max macros? No one knows. |
| 62 | build:windows --copt=/DNOMINMAX --host_copt=/DNOMINMAX |
| 63 | # Yay for security warnings. Boo for non-standard. |
| 64 | build: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. |
| 66 | build: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 |
| 71 | build:windows --linkopt=/DEFAULTLIB:clang_rt.builtins-x86_64.lib |
Stella Laurenzo | a7991a9 | 2019-10-25 12:09:08 -0700 | [diff] [blame] | 72 | build:windows --linkopt=/DEFAULTLIB:ws2_32.lib |
Stella Laurenzo | 3eecf14 | 2019-10-25 10:22:21 -0700 | [diff] [blame] | 73 | ############################################################################### |
| 74 | |
Stella Laurenzo | 7ff35e6 | 2019-10-16 12:44:31 -0700 | [diff] [blame] | 75 | # 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 Laurenzo | 9fb164c | 2019-10-23 13:36:22 -0700 | [diff] [blame] | 77 | try-import %workspace%/user.bazelrc |
Stella Laurenzo | 7ff35e6 | 2019-10-16 12:44:31 -0700 | [diff] [blame] | 78 | |