Skip to content

Commit

Permalink
devel/bazel: fix build on powerpc*
Browse files Browse the repository at this point in the history
bazel uses a bundled abseil. To build on powerpc*, abseil requires a trivial
patch.

In file included from external/com_google_absl/absl/base/internal/unscaledcycleclock.cc:27:
/usr/include/sys/sysctl.h:1185:25: error: unknown type name 'u_int'
int     sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
                            ^
external/com_google_absl/absl/base/internal/unscaledcycleclock.cc:91:10: error: unknown type name 'once_flag'
  static once_flag init_timebase_frequency_once;
         ^
external/com_google_absl/absl/base/internal/unscaledcycleclock.cc:93:18: error: no member named 'LowLevelCallOnce' in namespace 'absl::lts_2020_02_25::base_internal'
  base_internal::LowLevelCallOnce(&init_timebase_frequency_once, [&]() {
  ~~~~~~~~~~~~~~~^

PR:	259056
Approved by:	[email protected] (maintainer)
  • Loading branch information
pkubaj committed Oct 12, 2021
1 parent e140c1e commit 8abf3fd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions devel/bazel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ FINALRC= 2
EXTRA_PATCHES+= ${FILESDIR}/extra-i386_tools_cpp_BUILD.static.bsd
.endif

pre-patch:
@${CP} ${FILESDIR}/extra-patch-absl_base_internal_unscaledcycleclock.cc \
${FILESDIR}/extra-patch-bazel_grpc__deps.bzl \
${WRKSRC}/third_party/grpc/

# Have the location of the system-wide rc file reside ${ETCDIR}.
# Also adapt the sample file to disable persistent java workers as they
# do not work reliably on FreeBSD.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- absl/base/internal/unscaledcycleclock.cc.orig 2020-08-09 20:09:49 UTC
+++ absl/base/internal/unscaledcycleclock.cc
@@ -24,8 +24,10 @@
#ifdef __GLIBC__
#include <sys/platform/ppc.h>
#elif defined(__FreeBSD__)
-#include <sys/sysctl.h>
+#include "absl/base/call_once.h"
#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <threads.h>
#endif
#endif

10 changes: 10 additions & 0 deletions devel/bazel/files/extra-patch-bazel_grpc__deps.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/bazel/grpc_deps.bzl.orig 2021-10-11 15:54:07.083144000 +0200
+++ b/bazel/grpc_deps.bzl 2021-10-11 16:02:48.722952000 +0200
@@ -239,6 +239,7 @@
if "com_google_absl" not in native.existing_rules():
http_archive(
name = "com_google_absl",
+ patches = ["//third_party/grpc:extra-patch-absl_base_internal_unscaledcycleclock.cc"],
sha256 = "f368a8476f4e2e0eccf8a7318b98dafbe30b2600f4e3cf52636e5eb145aba06a",
strip_prefix = "abseil-cpp-df3ea785d8c30a9503321a3d35ee7d35808f190d",
urls = [
14 changes: 14 additions & 0 deletions devel/bazel/files/patch-WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- WORKSPACE.orig 2021-10-11 09:54:26 UTC
+++ WORKSPACE
@@ -1232,7 +1232,10 @@ register_toolchains("//src/main/res:empty_rc_toolchain
http_archive(
name = "com_github_grpc_grpc",
patch_args = ["-p1"],
- patches = ["//third_party/grpc:grpc_1.33.1.patch"],
+ patches = [
+ "//third_party/grpc:grpc_1.33.1.patch",
+ "//third_party/grpc:extra-patch-bazel_grpc__deps.bzl",
+ ],
sha256 = "58eaee5c0f1bd0b92ebe1fa0606ec8f14798500620e7444726afcaf65041cb63",
strip_prefix = "grpc-1.33.1",
urls = [

0 comments on commit 8abf3fd

Please sign in to comment.