.bazelrc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. # Must be first. Enables build:windows, build:linux, build:macos, build:freebsd, build:openbsd
  2. build --enable_platform_specific_config
  3. ###############################################################################
  4. # On Windows, provide: BAZEL_SH, and BAZEL_LLVM (if using clang-cl)
  5. # On all platforms, provide: PYTHON3_BIN_PATH=python
  6. ###############################################################################
  7. build:windows --action_env=PATH
  8. # For --compilation_mode=dbg, consider enabling checks in the standard library as well (below).
  9. build --compilation_mode=opt
  10. # Using C++ 17 on all platforms.
  11. build:linux --host_cxxopt="-std=c++17"
  12. build:macos --host_cxxopt="-std=c++17"
  13. build:clang-cl --host_cxxopt="-std=c++17"
  14. build:msvc-cl --host_cxxopt="/std:c++17"
  15. build:windows --host_cxxopt="/std:c++17"
  16. build:linux --cxxopt="-std=c++17"
  17. build:macos --cxxopt="-std=c++17"
  18. build:clang-cl --cxxopt="-std=c++17"
  19. build:msvc-cl --cxxopt="/std:c++17"
  20. build:windows --cxxopt="/std:c++17"
  21. # This workaround is needed to prevent Bazel from compiling the same file twice (once PIC and once not).
  22. build:linux --copt="-fPIC"
  23. build:macos --copt="-fPIC"
  24. build:clang-cl --compiler=clang-cl
  25. build:msvc-cl --compiler=msvc-cl
  26. # `LC_ALL` and `LANG` is needed for cpp worker tests, because they will call "ray start".
  27. # If we don't add them, python's `click` library will raise an error.
  28. test --test_env=LC_ALL
  29. test --test_env=LANG
  30. # Allow C++ worker tests to execute "ray start" with the correct version of Python.
  31. test --test_env=VIRTUAL_ENV
  32. test --test_env=PYENV_VIRTUAL_ENV
  33. test --test_env=PYENV_VERSION
  34. test --test_env=PYENV_SHELL
  35. # Do not send usage stats to the server for tests
  36. test --test_env=RAY_USAGE_STATS_REPORT_URL="http://127.0.0.1:8000"
  37. # Enable cluster mode for OSX and Windows. By default, Ray
  38. # will not allow multinode OSX and Windows clusters.
  39. test --test_env=RAY_ENABLE_WINDOWS_OR_OSX_CLUSTER="1"
  40. # This is needed for some core tests to run correctly
  41. build:windows --enable_runfiles
  42. # TODO(mehrdadn): Revert the "-\\.(asm|S)$" exclusion when this Bazel bug
  43. # for compiling assembly files is fixed on Windows:
  44. # https://github.com/bazelbuild/bazel/issues/8924
  45. # Warnings should be errors
  46. build:linux --per_file_copt="-\\.(asm|S)$@-Werror"
  47. build:macos --per_file_copt="-\\.(asm|S)$@-Werror"
  48. build:clang-cl --per_file_copt="-\\.(asm|S)$@-Werror"
  49. build:msvc-cl --per_file_copt="-\\.(asm|S)$@-WX"
  50. # Ignore warnings for protobuf generated files and external projects.
  51. build --per_file_copt="\\.pb\\.cc$@-w"
  52. build:linux --per_file_copt="-\\.(asm|S)$,external/.*@-w,-Wno-error=implicit-function-declaration"
  53. build:macos --per_file_copt="-\\.(asm|S)$,external/.*@-w,-Wno-error=implicit-function-declaration"
  54. # Ignore warnings for host tools, which we generally can't control.
  55. # Ideally we only want to ignore warnings for external project
  56. # but the current bazel version doesn't support host_per_file_copt yet.
  57. build:macos --host_copt="-w"
  58. build:clang-cl --host_copt="-Wno-inconsistent-missing-override"
  59. build:clang-cl --host_copt="-Wno-microsoft-unqualified-friend"
  60. # This workaround is needed due to https://github.com/bazelbuild/bazel/issues/4341
  61. build --per_file_copt="-\\.(asm|S)$,external/com_github_grpc_grpc/.*@-DGRPC_BAZEL_BUILD"
  62. # Don't generate warnings about kernel features we don't need https://github.com/ray-project/ray/issues/6832
  63. build:linux --per_file_copt="-\\.(asm|S)$,external/com_github_grpc_grpc/.*@-DGPR_MANYLINUX1"
  64. # Ignore wchar_t -> char conversion warning on MSVC
  65. build:msvc-cl --per_file_copt="external/boost/libs/regex/src/wc_regex_traits\\.cpp@-wd4244"
  66. build --http_timeout_scaling=5.0
  67. build --verbose_failures
  68. build:iwyu --experimental_action_listener=//:iwyu_cpp
  69. # Print relative paths when possible
  70. build:windows --attempt_to_print_relative_paths
  71. # Save disk space by hardlinking cache hits instead of copying
  72. build:windows --experimental_repository_cache_hardlinks
  73. # Clean the environment before building, to make builds more deterministic
  74. build:windows --incompatible_strict_action_env
  75. # For colored output (seems necessary on Windows)
  76. build:windows --color=yes
  77. # For compiler colored output (seems necessary on Windows)
  78. build:clang-cl --per_file_copt="-\\.(asm|S)$@-fansi-escape-codes"
  79. build:clang-cl --per_file_copt="-\\.(asm|S)$@-fcolor-diagnostics"
  80. # Debug build flags. Uncomment in '-c dbg' builds to enable checks in the C++ standard library:
  81. build:linux-debug --config linux
  82. build:linux-debug --cxxopt="-D_GLIBCXX_DEBUG=1"
  83. build:linux-debug --cxxopt="-D_GLIBCXX_DEBUG_PEDANTIC=1"
  84. build:linux-debug --cxxopt="-D_LIBCPP_DEBUG=1"
  85. build:macos-debug --config macos
  86. build:macos-debug --cxxopt="-D_GLIBCXX_DEBUG=1"
  87. build:macos-debug --cxxopt="-D_GLIBCXX_DEBUG_PEDANTIC=1"
  88. build:windows-debug --config windows
  89. build:windows-debug --cxxopt="-D_ITERATOR_DEBUG_LEVEL=2"
  90. # LLVM (clang & libc++) build flags common across Linux installations and systems.
  91. # On Ubuntu, the remaining configurations can be generated by running ci/env/install-llvm-binaries.sh
  92. build:llvm --action_env=CXXFLAGS=-stdlib=libc++
  93. build:llvm --action_env=LDFLAGS=-stdlib=libc++
  94. build:llvm --action_env=BAZEL_CXXOPTS=-stdlib=libc++
  95. build:llvm --action_env=BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a
  96. build:llvm --action_env=BAZEL_LINKOPTS=-lm:-pthread
  97. build:llvm --define force_libcpp=enabled
  98. # Thread sanitizer configuration:
  99. build:tsan --per_file_copt="-bazel-ray/external/com_github_antirez_redis/.*$@-fsanitize=thread"
  100. build:tsan --per_file_copt="-bazel-ray/external/com_github_antirez_redis/.*$@-DTHREAD_SANITIZER"
  101. build:tsan --strip=never
  102. build:tsan --copt -O2
  103. build:tsan --copt -g
  104. build:tsan --copt -fno-omit-frame-pointer
  105. build:tsan --copt -Wno-uninitialized
  106. build:tsan --linkopt -fsanitize=thread
  107. build:tsan --cxxopt="-D_RAY_TSAN_BUILD"
  108. build:tsan --no//:jemalloc_flag
  109. # This config is only for running TSAN with LLVM toolchain on Linux.
  110. build:tsan-clang --config=tsan
  111. build:tsan-clang --config=llvm
  112. test:tsan --test_env=TSAN_OPTIONS="report_atomic_races=0"
  113. # Memory sanitizer configuration
  114. build:asan --strip=never
  115. build:asan --copt -g
  116. build:asan --copt -fsanitize=address
  117. build:asan --copt -DADDRESS_SANITIZER
  118. build:asan --copt -fno-omit-frame-pointer
  119. build:asan --linkopt -fsanitize=address
  120. build:asan --no//:jemalloc_flag
  121. test:asan --jobs=1
  122. test:asan --test_env=ASAN_OPTIONS="detect_leaks=0"
  123. # This config is only for running ASAN with LLVM toolchain on Linux.
  124. # https://github.com/google/sanitizers/issues/1017
  125. build:asan-clang --config=asan
  126. build:asan-clang --config=llvm
  127. build:asan-clang --copt -mllvm
  128. build:asan-clang --copt -asan-use-private-alias=1
  129. build:asan-build --strip=never
  130. build:asan-build -c dbg
  131. build:asan-build --copt -fsanitize=address
  132. build:asan-build --copt -DADDRESS_SANITIZER
  133. build:asan-build --copt -O1
  134. build:asan-build --copt -g
  135. build:asan-build --copt -fno-omit-frame-pointer
  136. build:asan-build --copt -static-libasan
  137. build:asan-build --linkopt -fsanitize=address
  138. build:asan-build --linkopt -static-libasan
  139. # For example, for Ubuntu 18.04 libasan can be found here:
  140. # test:asan --test_env=LD_PRELOAD="/usr/lib/gcc/x86_64-linux-gnu/7/libasan.so"
  141. test:asan-buildkite --test_env=LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libasan.so.5"
  142. # CI configuration:
  143. aquery:ci --color=no
  144. aquery:ci --noshow_progress
  145. build:ci --color=yes
  146. build:ci --curses=no
  147. build:ci --keep_going
  148. build:ci --progress_report_interval=100
  149. build:ci --show_progress_rate_limit=15
  150. build:ci --ui_actions_shown=1024
  151. build:ci --show_timestamps
  152. build:ci-travis --disk_cache=~/ray-bazel-cache
  153. build:ci-github --experimental_repository_cache_hardlinks # GitHub Actions has low disk space, so prefer hardlinks there.
  154. build:ci-github --disk_cache=~/ray-bazel-cache
  155. test:ci --flaky_test_attempts=3
  156. # Disable test result caching because py_test under Bazel can import from outside of sandbox, but Bazel only looks at
  157. # declared dependencies to determine if a result should be cached. More details at:
  158. # https://github.com/bazelbuild/bazel/issues/7091, https://github.com/bazelbuild/rules_python/issues/382
  159. test:ci --nocache_test_results
  160. test:ci --spawn_strategy=local
  161. test:ci --test_output=errors
  162. test:ci --experimental_ui_max_stdouterr_bytes=-1
  163. test:ci --test_verbose_timeout_warnings
  164. test:ci-debug -c dbg
  165. test:ci-debug --copt="-g"
  166. test:ci-debug --flaky_test_attempts=3
  167. # Disable test result caching for the same reason above.
  168. test:ci-debug --nocache_test_results
  169. test:ci-debug --spawn_strategy=local
  170. test:ci-debug --test_output=errors
  171. test:ci-debug --test_verbose_timeout_warnings
  172. aquery:get-toolchain --include_commandline=false
  173. aquery:get-toolchain --noimplicit_deps
  174. # [Linux] Uncomment this line (or use --config) to print a stack trace on exit.
  175. #test:linux --config=strace
  176. test:strace --run_under="bash -c 'if command -v strace >/dev/null && strace -qq -k -e exit true 2>/dev/null; then strace -qq -k -e exit -e trace=\"!all\" -s 32768 -f -o >(awk \"/^[0-9]+ / { y = \\$3 != \\\"SIGCHLD\\\" && \\$3 != \\\"SIGTERM\\\" && \\$5 != \\\"SIGTERM\\\" && \\$5 != \\\"SIGKILL2\\\"; } y { print; }\" 1>&2 && cat 1>&2) -- \"$@\"; else \"$@\"; fi' -"
  177. # [Linux] Uncomment this line (or use --config) to preload libSegFault.so if available, to print a stack trace on aborts and segfault. (Note: This doesn't always work.)
  178. #test:linux --config=segfault
  179. test:segfault --run_under="bash -c 'unset GREP_OPTIONS && if ! grep -q -o Microsoft /proc/version 2>/dev/null; then libs=\"$(command -v ldconfig >/dev/null && ldconfig -p | grep -F -o -e \"libSegFault.so\" | uniq | tr \"\\\\n\" :)\" && if [ -n \"${libs%:}\" ]; then export SEGFAULT_SIGNALS=\"abrt segv\" LD_PRELOAD=\"${libs}${LD_PRELOAD-}\"; fi; fi && \"$@\"' -"
  180. # Debug build:
  181. build:debug -c dbg
  182. build:debug --copt="-g"
  183. build:debug --copt -fno-omit-frame-pointer
  184. build:debug --strip="never"
  185. # Undefined Behavior Sanitizer
  186. build:ubsan --strip=never
  187. build:ubsan --copt -fno-sanitize=vptr
  188. build:ubsan --copt -fno-sanitize-recover=all
  189. build:ubsan --copt -g
  190. build:ubsan --linkopt -fsanitize=undefined
  191. build:ubsan --linkopt -fno-sanitize-recover=all
  192. build:ubsan --per_file_copt="-external/com_github_grpc_grpc/.*@-fsanitize=undefined"
  193. # Import local specific llvm config options, which can be generated by
  194. # ci/env/install-llvm-dependencies.sh
  195. try-import %workspace%/.llvm-local.bazelrc
  196. # Even with sandbox mode bazel prioritizes system headers over the ones in the sandbox.
  197. # It picks up the system headers when someone has protobuf installed via Homebrew.
  198. # Work around for https://github.com/bazelbuild/bazel/issues/8053
  199. build:macos --sandbox_block_path=/usr/local/
  200. # This option controls whether javac checks for missing direct dependencies.
  201. build --experimental_strict_java_deps=off