From 0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6 Mon Sep 17 00:00:00 2001 From: Phillipp Schoppmann Date: Tue, 12 May 2020 17:36:55 -0700 Subject: [PATCH] Fix build for Emscripten (#546) Add back config_setting for WASM (no HAVE_SYSCALL_H) Since there is no config_setting for Linux (https://github.com/bazelbuild/bazel/issues/11107), Linux needs to be the default case. --- bazel/glog.bzl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bazel/glog.bzl b/bazel/glog.bzl index 172875886..a46e2d148 100644 --- a/bazel/glog.bzl +++ b/bazel/glog.bzl @@ -18,6 +18,12 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): gendir = "$(GENDIR)" src_windows = "src/windows" + # Config setting for WebAssembly target. + native.config_setting( + name = "wasm", + values = {"cpu": "wasm"}, + ) + common_copts = [ "-DGLOG_BAZEL_BUILD", "-DHAVE_STDINT_H", @@ -25,7 +31,7 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): "-DHAVE_UNWIND_H", ] + (["-DHAVE_LIB_GFLAGS"] if with_gflags else []) - linux_or_darwin_copts = [ + wasm_copts = [ # Disable warnings that exists in glog. "-Wno-sign-compare", "-Wno-unused-function", @@ -38,7 +44,6 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): # Allows src/logging.cc to determine the host name. "-DHAVE_SYS_UTSNAME_H", # For src/utilities.cc. - "-DHAVE_SYS_SYSCALL_H", "-DHAVE_SYS_TIME_H", # Enable dumping stacktrace upon sigaction. "-DHAVE_SIGACTION", @@ -48,6 +53,11 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): "-I%s/glog_internal" % gendir, ] + linux_or_darwin_copts = wasm_copts + [ + # For src/utilities.cc. + "-DHAVE_SYS_SYSCALL_H", + ] + freebsd_only_copts = [ # Enable declaration of _Unwind_Backtrace "-D_GNU_SOURCE", @@ -105,6 +115,7 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): "@bazel_tools//src/conditions:windows": common_copts + windows_only_copts, "@bazel_tools//src/conditions:darwin": common_copts + linux_or_darwin_copts + darwin_only_copts, "@bazel_tools//src/conditions:freebsd": common_copts + linux_or_darwin_copts + freebsd_only_copts, + ":wasm": common_copts + wasm_copts, "//conditions:default": common_copts + linux_or_darwin_copts, }), deps = [