Skip to content

Commit

Permalink
Patch upb for clang-16 (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinxc committed Sep 19, 2024
1 parent 3ea2f49 commit de90da1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions bazel/patches/upb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/bazel/build_defs.bzl b/bazel/build_defs.bzl
index b5bc64f0..dc30a75f 100644
--- a/bazel/build_defs.bzl
+++ b/bazel/build_defs.bzl
@@ -38,7 +38,7 @@ _DEFAULT_CPPOPTS.extend([
"-Wno-long-long",
])
_DEFAULT_COPTS.extend([
- "-std=c99",
+ "-std=c11",
"-pedantic",
"-Werror=pedantic",
"-Wall",
diff --git a/upb/port_def.inc b/upb/port_def.inc
index 92e4bf24..e355ace7 100644
--- a/upb/port_def.inc
+++ b/upb/port_def.inc
@@ -92,7 +92,11 @@
#define UPB_ALIGN_UP(size, align) (((size) + (align) - 1) / (align) * (align))
#define UPB_ALIGN_DOWN(size, align) ((size) / (align) * (align))
#define UPB_ALIGN_MALLOC(size) UPB_ALIGN_UP(size, UPB_MALLOC_ALIGN)
+#ifdef __clang__
+#define UPB_ALIGN_OF(type) _Alignof(type)
+#else
#define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member)
+#endif

/* Hints to the compiler about likely/unlikely branches. */
#if defined (__GNUC__) || defined(__clang__)
4 changes: 4 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def _upb():
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz",
"https://github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz",
],
patch_args = ["-p1"],
patches = [
"@psi//bazel:patches/upb.patch",
],
)

def _com_github_emptoolkit_emp_tool():
Expand Down

0 comments on commit de90da1

Please sign in to comment.