mirror of
https://github.com/vale981/ray
synced 2025-03-04 17:41:43 -05:00
Bazel selects compiler flags based on compiler (#9313)
Co-authored-by: Mehrdad <noreply@github.com>
This commit is contained in:
parent
c7714ca575
commit
3d65682e62
7 changed files with 53 additions and 27 deletions
26
.bazelrc
26
.bazelrc
|
@ -1,7 +1,7 @@
|
|||
# Must be first. Enables build:windows, build:linux, build:macos, build:freebsd, build:openbsd
|
||||
build --enable_platform_specific_config
|
||||
###############################################################################
|
||||
# On Windows, provide: CC=clang, BAZEL_LLVM, BAZEL_SH
|
||||
# On Windows, provide: BAZEL_SH, and BAZEL_LLVM (if using clang-cl)
|
||||
# On all platforms, provide: PYTHON3_BIN_PATH=python
|
||||
###############################################################################
|
||||
build --action_env=PATH
|
||||
|
@ -17,14 +17,13 @@ build:msvc --compiler=msvc-cl
|
|||
# for compiling assembly files is fixed on Windows:
|
||||
# https://github.com/bazelbuild/bazel/issues/8924
|
||||
# Warnings should be errors
|
||||
build:linux --per_file_copt="-\\.(asm|S)$,-.*/arrow/util/logging\\.cc@-Werror"
|
||||
build:macos --per_file_copt="-\\.(asm|S)$,-.*/arrow/util/logging\\.cc@-Werror"
|
||||
build:clang-cl --per_file_copt="-\\.(asm|S)$,-.*/arrow/util/logging\\.cc@-Werror"
|
||||
build:msvc --per_file_copt="-\\.(asm|S)$,-.*/arrow/util/logging\\.cc@-WX"
|
||||
build:linux --per_file_copt="-\\.(asm|S)$@-Werror"
|
||||
build:macos --per_file_copt="-\\.(asm|S)$@-Werror"
|
||||
build:clang-cl --per_file_copt="-\\.(asm|S)$@-Werror"
|
||||
build:msvc --per_file_copt="-\\.(asm|S)$@-WX"
|
||||
# Ignore warnings for protobuf generated files and external projects.
|
||||
build --per_file_copt="\\.pb\\.cc$@-w"
|
||||
build --per_file_copt="-\\.(asm|S)$,external/.*@-w"
|
||||
# Enable some C warnings that really should be errors (e.g. implicit void* <-> int conversion)
|
||||
# Ignore minor warnings for host tools, which we generally can't control
|
||||
build:clang-cl --host_copt="-Wno-inconsistent-missing-override"
|
||||
build:clang-cl --host_copt="-Wno-microsoft-unqualified-friend"
|
||||
|
@ -81,6 +80,8 @@ test:asan --test_env=LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libasan.so.2 /usr/lib
|
|||
# test:asan --test_env=LD_PRELOAD="/usr/lib/gcc/x86_64-linux-gnu/7/libasan.so"
|
||||
|
||||
# CI configuration:
|
||||
aquery:ci --color=no
|
||||
aquery:ci --noshow_progress
|
||||
build:ci --color=yes
|
||||
build:ci --curses=no
|
||||
build:ci --disk_cache=~/ray-bazel-cache
|
||||
|
@ -98,7 +99,12 @@ test:ci --spawn_strategy=local
|
|||
test:ci --test_output=errors
|
||||
test:ci --test_verbose_timeout_warnings
|
||||
|
||||
# [Linux] Uncomment this line to print a stack trace on exit.
|
||||
#test:linux --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' -"
|
||||
# [Linux] Uncomment this line to preload libSegFault.so if available, to print a stack trace on aborts and segfault. (Note: This doesn't always work.)
|
||||
#test:linux --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 && \"$@\"' -"
|
||||
aquery:get-toolchain --include_commandline=false
|
||||
aquery:get-toolchain --noimplicit_deps
|
||||
|
||||
# [Linux] Uncomment this line (or use --config) to print a stack trace on exit.
|
||||
#test:linux --config=strace
|
||||
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' -"
|
||||
# [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.)
|
||||
#test:linux --config=segfault
|
||||
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 && \"$@\"' -"
|
||||
|
|
10
BUILD.bazel
10
BUILD.bazel
|
@ -11,13 +11,13 @@ load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
|
|||
load("//bazel:ray.bzl", "COPTS", "PYX_COPTS", "PYX_SRCS", "copy_to_workspace")
|
||||
|
||||
config_setting(
|
||||
name = "windows_msvc-cl",
|
||||
values = {"compiler": "msvc-cl"},
|
||||
name = "msvc-cl",
|
||||
flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc-cl"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "windows_clang-cl",
|
||||
values = {"compiler": "clang-cl"},
|
||||
name = "clang-cl",
|
||||
flag_values = {"@bazel_tools//tools/cpp:compiler": "clang-cl"},
|
||||
)
|
||||
|
||||
# === Begin of protobuf definitions ===
|
||||
|
@ -846,7 +846,7 @@ cc_test(
|
|||
name = "reconstruction_policy_test",
|
||||
srcs = ["src/ray/raylet/reconstruction_policy_test.cc"],
|
||||
copts = COPTS + select({
|
||||
"//:windows_msvc-cl": [
|
||||
"//:msvc-cl": [
|
||||
],
|
||||
"//conditions:default": [
|
||||
# Ignore this warning since it's impractical to fix in the relevant headers
|
||||
|
|
|
@ -4,6 +4,13 @@ COPTS = [] + select({
|
|||
],
|
||||
"//conditions:default": [
|
||||
],
|
||||
}) + select({
|
||||
"@//:msvc-cl": [
|
||||
],
|
||||
"//conditions:default": [
|
||||
# Old versions of GCC (e.g. 4.9.2) can fail to compile Redis's C without this.
|
||||
"-std=c99",
|
||||
],
|
||||
})
|
||||
|
||||
# This library is for internal hiredis use, because hiredis assumes a
|
||||
|
|
|
@ -2,24 +2,24 @@ load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_library_publ
|
|||
load("@com_github_checkstyle_java//checkstyle:checkstyle.bzl", "checkstyle_test")
|
||||
load("@bazel_common//tools/maven:pom_file.bzl", "pom_file")
|
||||
|
||||
WINDOWS_COPTS = [
|
||||
# TODO(mehrdadn): (How to) support dynamic linking?
|
||||
"-DRAY_STATIC",
|
||||
]
|
||||
|
||||
COPTS = ["-DRAY_USE_GLOG"] + select({
|
||||
"//:windows_msvc-cl": [
|
||||
] + WINDOWS_COPTS,
|
||||
"//:windows_clang-cl": [
|
||||
"@bazel_tools//src/conditions:windows": [
|
||||
# TODO(mehrdadn): (How to) support dynamic linking?
|
||||
"-DRAY_STATIC",
|
||||
],
|
||||
"//conditions:default": [
|
||||
],
|
||||
}) + select({
|
||||
"//:clang-cl": [
|
||||
"-Wno-builtin-macro-redefined", # To get rid of warnings caused by deterministic build macros (e.g. #define __DATE__ "redacted")
|
||||
"-Wno-microsoft-unqualified-friend", # This shouldn't normally be enabled, but otherwise we get: google/protobuf/map_field.h: warning: unqualified friend declaration referring to type outside of the nearest enclosing namespace is a Microsoft extension; add a nested name specifier (for: friend class DynamicMessage)
|
||||
] + WINDOWS_COPTS,
|
||||
],
|
||||
"//conditions:default": [
|
||||
],
|
||||
})
|
||||
|
||||
PYX_COPTS = select({
|
||||
"//:windows_msvc-cl": [
|
||||
"//:msvc-cl": [
|
||||
],
|
||||
"//conditions:default": [
|
||||
# Ignore this warning since CPython and Cython have issue removing deprecated tp_print on MacOS
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
(
|
||||
set -euo pipefail
|
||||
bazel aquery --color=no --show_progress=no --output=textproto \
|
||||
bazel aquery --output=textproto \
|
||||
"mnemonic(\"Genrule\", deps(${1-//:*}))" | awk '
|
||||
{
|
||||
body = 0;
|
||||
|
|
|
@ -202,6 +202,7 @@ install_toolchains() {
|
|||
install_dependencies() {
|
||||
|
||||
install_bazel
|
||||
|
||||
install_base
|
||||
install_toolchains
|
||||
install_nvm
|
||||
|
|
|
@ -50,4 +50,16 @@ install_clang() {
|
|||
"${cc}" --version
|
||||
}
|
||||
|
||||
install_clang "$@"
|
||||
install_toolchains() {
|
||||
local uses_clang=1 some_lightweight_target="//:sha256"
|
||||
if bazel aquery --config=get-toolchain --output=textproto "${some_lightweight_target}" |
|
||||
grep "external_Slocal_Uconfig_Ucc_Cmsvc_Ucompiler_Ufiles" > /dev/null; then
|
||||
# We detected that we use MSVC, not Clang
|
||||
uses_clang=0
|
||||
fi
|
||||
if [ 0 -ne "${uses_clang}" ]; then
|
||||
install_clang "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
install_toolchains "$@"
|
||||
|
|
Loading…
Add table
Reference in a new issue