.bazelrc 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 --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 --cxxopt="-std=c++17"
  12. build:macos --cxxopt="-std=c++17"
  13. build:clang-cl --cxxopt="-std=c++17"
  14. build:msvc-cl --cxxopt="/std:c++17"
  15. build:windows --cxxopt="/std:c++17"
  16. # This workaround is needed to prevent Bazel from compiling the same file twice (once PIC and once not).
  17. build:linux --force_pic
  18. build:macos --force_pic
  19. build:clang-cl --compiler=clang-cl
  20. build:msvc-cl --compiler=msvc-cl
  21. # `LC_ALL` and `LANG` is needed for cpp worker tests, because they will call "ray start".
  22. # If we don't add them, python's `click` library will raise an error.
  23. build --action_env=LC_ALL
  24. build --action_env=LANG
  25. # Allow C++ worker tests to execute "ray start" with the correct version of Python.
  26. build --action_env=VIRTUAL_ENV
  27. build --action_env=PYENV_VIRTUAL_ENV
  28. build --action_env=PYENV_VERSION
  29. build --action_env=PYENV_SHELL
  30. # This is needed for some core tests to run correctly
  31. build:windows --enable_runfiles
  32. # TODO(mehrdadn): Revert the "-\\.(asm|S)$" exclusion when this Bazel bug
  33. # for compiling assembly files is fixed on Windows:
  34. # https://github.com/bazelbuild/bazel/issues/8924
  35. # Warnings should be errors
  36. build:linux --per_file_copt="-\\.(asm|S)$@-Werror"
  37. build:macos --per_file_copt="-\\.(asm|S)$@-Werror"
  38. build:clang-cl --per_file_copt="-\\.(asm|S)$@-Werror"
  39. build:msvc-cl --per_file_copt="-\\.(asm|S)$@-WX"
  40. # Ignore warnings for protobuf generated files and external projects.
  41. build --per_file_copt="\\.pb\\.cc$@-w"
  42. build --per_file_copt="-\\.(asm|S)$,external/.*@-w"
  43. #build --per_file_copt="external/.*@-Wno-unused-result"
  44. # Ignore minor warnings for host tools, which we generally can't control
  45. build:clang-cl --host_copt="-Wno-inconsistent-missing-override"
  46. build:clang-cl --host_copt="-Wno-microsoft-unqualified-friend"
  47. # This workaround is needed due to https://github.com/bazelbuild/bazel/issues/4341
  48. build --per_file_copt="-\\.(asm|S)$,external/com_github_grpc_grpc/.*@-DGRPC_BAZEL_BUILD"
  49. # Don't generate warnings about kernel features we don't need https://github.com/ray-project/ray/issues/6832
  50. build:linux --per_file_copt="-\\.(asm|S)$,external/com_github_grpc_grpc/.*@-DGPR_MANYLINUX1"
  51. # Ignore wchar_t -> char conversion warning on MSVC
  52. build:msvc-cl --per_file_copt="external/boost/libs/regex/src/wc_regex_traits\\.cpp@-wd4244"
  53. build --http_timeout_scaling=5.0
  54. build --verbose_failures
  55. build:iwyu --experimental_action_listener=//:iwyu_cpp
  56. # Print relative paths when possible
  57. build:windows --attempt_to_print_relative_paths
  58. # Save disk space by hardlinking cache hits instead of copying
  59. build:windows --experimental_repository_cache_hardlinks
  60. # Clean the environment before building, to make builds more deterministic
  61. build:windows --incompatible_strict_action_env
  62. # For colored output (seems necessary on Windows)
  63. build:windows --color=yes
  64. # For compiler colored output (seems necessary on Windows)
  65. build:clang-cl --per_file_copt="-\\.(asm|S)$@-fansi-escape-codes"
  66. build:clang-cl --per_file_copt="-\\.(asm|S)$@-fcolor-diagnostics"
  67. build:manylinux2010 --copt="-Wno-unused-result"
  68. build:manylinux2010 --linkopt="-lrt"
  69. # Debug build flags. Uncomment in '-c dbg' builds to enable checks in the C++ standard library:
  70. #build:linux --cxxopt="-D_GLIBCXX_DEBUG=1"
  71. #build:linux --cxxopt="-D_GLIBCXX_DEBUG_PEDANTIC=1"
  72. #build:linux --cxxopt="-D_LIBCPP_DEBUG=1"
  73. #build:macos --cxxopt="-D_GLIBCXX_DEBUG=1"
  74. #build:macos --cxxopt="-D_GLIBCXX_DEBUG_PEDANTIC=1"
  75. #build:windows --cxxopt="-D_ITERATOR_DEBUG_LEVEL=2"
  76. # LLVM (clang & libc++) build flags common across Linux installations and systems.
  77. # On Ubuntu, the remaining configurations can be generated by running ci/travis/install-llvm-binaries.sh
  78. build:llvm --action_env=CXXFLAGS=-stdlib=libc++
  79. build:llvm --action_env=LDFLAGS=-stdlib=libc++
  80. build:llvm --action_env=BAZEL_CXXOPTS=-stdlib=libc++
  81. build:llvm --action_env=BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a
  82. build:llvm --action_env=BAZEL_LINKOPTS=-lm:-pthread
  83. build:llvm --define force_libcpp=enabled
  84. # Thread sanitizer configuration:
  85. build:tsan --strip=never
  86. build:tsan --copt -fsanitize=thread
  87. build:tsan --copt -DTHREAD_SANITIZER
  88. build:tsan --copt -O2
  89. build:tsan --copt -g
  90. build:tsan --copt -fno-omit-frame-pointer
  91. build:tsan --copt -Wno-uninitialized
  92. build:tsan --linkopt -fsanitize=thread
  93. # This config is only for running TSAN with LLVM toolchain on Linux.
  94. build:tsan-clang --config=tsan
  95. build:tsan-clang --config=llvm
  96. test:tsan --test_env=TSAN_OPTIONS="report_atomic_races=0"
  97. # Memory sanitizer configuration
  98. build:asan --strip=never
  99. build:asan --copt -g
  100. build:asan --copt -fsanitize=address
  101. build:asan --copt -DADDRESS_SANITIZER
  102. build:asan --copt -fno-omit-frame-pointer
  103. build:asan --linkopt -fsanitize=address
  104. test:asan --jobs=1
  105. test:asan --test_env=ASAN_OPTIONS="detect_leaks=0"
  106. # This config is only for running ASAN with LLVM toolchain on Linux.
  107. # https://github.com/google/sanitizers/issues/1017
  108. build:asan-clang --config=asan
  109. build:asan-clang --config=llvm
  110. build:asan-clang --copt -mllvm
  111. build:asan-clang --copt -asan-use-private-alias=1
  112. build:asan-build --strip=never
  113. build:asan-build -c dbg
  114. build:asan-build --copt -fsanitize=address
  115. build:asan-build --copt -DADDRESS_SANITIZER
  116. build:asan-build --copt -O1
  117. build:asan-build --copt -g
  118. build:asan-build --copt -fno-omit-frame-pointer
  119. build:asan-build --copt -static-libasan
  120. build:asan-build --linkopt -fsanitize=address
  121. build:asan-build --linkopt -static-libasan
  122. # For example, for Ubuntu 18.04 libasan can be found here:
  123. # test:asan --test_env=LD_PRELOAD="/usr/lib/gcc/x86_64-linux-gnu/7/libasan.so"
  124. test:asan-buildkite --test_env=LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libasan.so.5"
  125. # CI configuration:
  126. aquery:ci --color=no
  127. aquery:ci --noshow_progress
  128. build:ci --color=yes
  129. build:ci --curses=no
  130. build:ci --keep_going
  131. build:ci --progress_report_interval=100
  132. build:ci --show_progress_rate_limit=15
  133. build:ci --show_task_finish
  134. build:ci --ui_actions_shown=1024
  135. build:ci --show_timestamps
  136. build:ci-travis --disk_cache=~/ray-bazel-cache
  137. build:ci-travis --remote_cache="https://storage.googleapis.com/ray-bazel-cache"
  138. build:ci-github --experimental_repository_cache_hardlinks # GitHub Actions has low disk space, so prefer hardlinks there.
  139. build:ci-github --disk_cache=~/ray-bazel-cache
  140. build:ci-github --remote_cache="https://storage.googleapis.com/ray-bazel-cache"
  141. test:ci --flaky_test_attempts=3
  142. # Disable test result caching because py_test under Bazel can import from outside of sandbox, but Bazel only looks at
  143. # declared dependencies to determine if a result should be cached. More details at:
  144. # https://github.com/bazelbuild/bazel/issues/7091, https://github.com/bazelbuild/rules_python/issues/382
  145. test:ci --nocache_test_results
  146. test:ci --spawn_strategy=local
  147. test:ci --test_output=errors
  148. test:ci --test_verbose_timeout_warnings
  149. test:ci-debug -c dbg
  150. test:ci-debug --copt="-g"
  151. test:ci-debug --flaky_test_attempts=3
  152. # Disable test result caching for the same reason above.
  153. test:ci-debug --nocache_test_results
  154. test:ci-debug --spawn_strategy=local
  155. test:ci-debug --test_output=errors
  156. test:ci-debug --test_verbose_timeout_warnings
  157. aquery:get-toolchain --include_commandline=false
  158. aquery:get-toolchain --noimplicit_deps
  159. # [Linux] Uncomment this line (or use --config) to print a stack trace on exit.
  160. #test:linux --config=strace
  161. 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' -"
  162. # [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.)
  163. #test:linux --config=segfault
  164. 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 && \"$@\"' -"
  165. # Debug build:
  166. build:debug -c dbg
  167. build:debug --copt="-g"
  168. build:debug --strip="never"
  169. # Undefined Behavior Sanitizer
  170. build:ubsan --strip=never
  171. build:ubsan --copt -fsanitize=undefined
  172. build:ubsan --copt -fno-sanitize=vptr
  173. build:ubsan --copt -fno-sanitize-recover=all
  174. build:ubsan --copt -g
  175. build:ubsan --linkopt -fsanitize=undefined
  176. build:ubsan --linkopt -fno-sanitize-recover=all
  177. # Import local specific llvm config options, which can be generated by
  178. # ci/travis/install-llvm-dependencies.sh
  179. try-import %workspace%/.llvm-local.bazelrc