bazel build --compilation_mode=debug (#6457)

This commit is contained in:
mehrdadn
2020-06-05 14:36:10 +02:00
committed by GitHub
parent 4a6c4003fd
commit d78757623d
5 changed files with 58 additions and 3 deletions
+9
View File
@@ -5,6 +5,7 @@ build --enable_platform_specific_config
# On all platforms, provide: PYTHON3_BIN_PATH=python
###############################################################################
build --action_env=PATH
# For --compilation_mode=dbg, consider enabling checks in the standard library as well (below).
build --compilation_mode=opt
# This workaround is needed to prevent Bazel from compiling the same file twice (once PIC and once not).
build:linux --force_pic
@@ -45,6 +46,14 @@ build:windows --color=yes
build:windows --per_file_copt="-\\.(asm|S)$@-fansi-escape-codes"
build:windows --per_file_copt="-\\.(asm|S)$@-fcolor-diagnostics"
# Debug build flags. Uncomment in '-c dbg' builds to enable checks in the C++ standard library:
#build:linux --cxxopt="-D_GLIBCXX_DEBUG=1"
#build:linux --cxxopt="-D_GLIBCXX_DEBUG_PEDANTIC=1"
#build:linux --cxxopt="-D_LIBCPP_DEBUG=1"
#build:macos --cxxopt="-D_GLIBCXX_DEBUG=1"
#build:macos --cxxopt="-D_GLIBCXX_DEBUG_PEDANTIC=1"
#build:windows --cxxopt="-D_ITERATOR_DEBUG_LEVEL=2"
# Thread sanitizer configuration:
build:tsan --strip=never
build:tsan --copt -fsanitize=thread
+5 -3
View File
@@ -7,7 +7,7 @@ load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@com_github_grpc_grpc//bazel:cython_library.bzl", "pyx_library")
load("@rules_proto_grpc//python:defs.bzl", "python_grpc_compile")
load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
load("//bazel:ray.bzl", "COPTS")
load("//bazel:ray.bzl", "COPTS", "PYX_COPTS", "PYX_SRCS")
# === Begin of protobuf definitions ===
@@ -1598,7 +1598,8 @@ pyx_library(
# We need to dlopen this lib with RTLD_GLOBAL to use ABI in this
# shared lib, see python/ray/__init__.py.
cc_kwargs = dict(
copts = COPTS,
srcs = PYX_SRCS,
copts = COPTS + PYX_COPTS,
# see https://github.com/tensorflow/tensorflow/blob/r2.1/tensorflow/lite/BUILD#L444
linkopts = select({
"@bazel_tools//src/conditions:darwin": [
@@ -1636,7 +1637,8 @@ pyx_library(
"python/ray/streaming/includes/*.pxi",
]),
cc_kwargs = dict(
copts = COPTS,
srcs = PYX_SRCS,
copts = COPTS + PYX_COPTS,
),
deps = [
"//streaming:streaming_lib",
+16
View File
@@ -13,6 +13,22 @@ COPTS = ["-DRAY_USE_GLOG"] + select({
],
})
PYX_COPTS = [] + select({
"@bazel_tools//src/conditions:windows": [
"/FI" + "src/shims/windows/python-nondebug.h",
],
"//conditions:default": [
],
})
PYX_SRCS = [] + select({
"@bazel_tools//src/conditions:windows": [
"src/shims/windows/python-nondebug.h",
],
"//conditions:default": [
],
})
def flatbuffer_py_library(name, srcs, outs, out_prefix, includes = [], include_paths = []):
flatbuffer_library_public(
name = name,
+10
View File
@@ -33,6 +33,16 @@
enum { ERROR = 0 };
#endif
#endif
#if defined(DEBUG) && DEBUG == 1
// Bazel defines the DEBUG macro for historical reasons:
// https://github.com/bazelbuild/bazel/issues/3513#issuecomment-323829248
// Undefine the DEBUG macro to prevent conflicts with our usage below
#undef DEBUG
// Redefine DEBUG as itself to allow any '#ifdef DEBUG' to keep working regardless
#define DEBUG DEBUG
#endif
namespace ray {
enum class RayLogLevel { DEBUG = -1, INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3 };
+18
View File
@@ -0,0 +1,18 @@
// This is to avoid depending on the debug version of the Python library on Windows,
// which requires separate library files and linking.
#if defined(_WIN32) && defined(_DEBUG)
#ifdef Py_PYTHON_H
#error Python.h should not have been included at this point.
#endif
// Ensure some headers included before messing with macro
#include <io.h>
#include <stdio.h>
#ifdef Py_CONFIG_H
#error pyconfig.h should not have been included at this point.
#endif
#include "patchlevel.h"
#pragma push_macro("_DEBUG")
#undef _DEBUG
#include "pyconfig.h"
#pragma pop_macro("_DEBUG")
#endif