From 24745e1a6d2b33fefb7303fe322d92a006425b1b Mon Sep 17 00:00:00 2001 From: Shuhei Takahashi Date: Tue, 17 Jul 2018 23:19:51 +0900 Subject: [PATCH] Fix stacktrace on bazel build. We need at least following defs to be set to print stacktrace in failure signal handler. - HAVE_UNWIND_H: on Linux and macOS. unwind.h is usually present by default on those OSes. - HAVE_DLADDR: on macOS. Windows is not cared because glog can not be built with bazel on Windows today. --- bazel/glog.bzl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/glog.bzl b/bazel/glog.bzl index f9b33d470..4a1bc6c53 100644 --- a/bazel/glog.bzl +++ b/bazel/glog.bzl @@ -73,7 +73,16 @@ def glog_library(namespace='google', with_gflags=1, **kwargs): # Include generated header files. '-I%s/glog_internal' % gendir, - ] + ([ + ] + select({ + # For stacktrace. + '@bazel_tools//src/conditions:darwin': [ + '-DHAVE_UNWIND_H', + '-DHAVE_DLADDR', + ], + '//conditions:default': [ + '-DHAVE_UNWIND_H', + ], + }) + ([ # Use gflags to parse CLI arguments. '-DHAVE_LIB_GFLAGS', ] if with_gflags else []),