Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch upb for clang-16 #183

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading