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 cel-cpp to not break build #31894

Closed
wants to merge 1 commit into from
Closed
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
44 changes: 44 additions & 0 deletions bazel/cel-cpp-memory.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 09a072b4bb5a75e1df15beba29a9f13b1948ff8b Mon Sep 17 00:00:00 2001
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we dont want the commit header - just the diff

From: Ivan Prisyazhnyy <[email protected]>
Date: Thu, 18 Jan 2024 13:55:29 +0000
Subject: [PATCH] Fix: use of sized deallocation in base/memory.h wo check

Dependant projects that do not use `-fsized-deallocation`
would not compile with the call to delete(void*, size_t, align).

There are other places that already check for
`defined(__cpp_sized_deallocation)` and this patch just shares
this practice.

Testing:

// fix .bazelrc to have:
build --cxxopt=-fno-sized-deallocation

$ bazel build --verbose_failures //base:\*

Signed-off-by: Ivan Prisyazhnyy <[email protected]>
---
base/memory.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/base/memory.h b/base/memory.h
index 3552e19a..c310128a 100644
--- a/base/memory.h
+++ b/base/memory.h
@@ -89,8 +89,14 @@ class Allocator {

void deallocate(pointer p, size_type n) {
if (!allocation_only_) {
- ::operator delete(static_cast<void*>(p), n * sizeof(T),
+#if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L
+ ::operator delete(static_cast<void *>(p), n * sizeof(T),
static_cast<std::align_val_t>(alignof(T)));
+#else
+ ::operator delete(static_cast<void *>(p),
+ static_cast<std::align_val_t>(alignof(T)));
+ static_cast<void>(n); // unused
+#endif
}
}

5 changes: 4 additions & 1 deletion bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,10 @@ def _com_github_facebook_zstd():
def _com_google_cel_cpp():
external_http_archive(
"com_google_cel_cpp",
patches = ["@envoy//bazel:cel-cpp.patch"],
patches = [
"@envoy//bazel:cel-cpp.patch",
"@envoy//bazel:cel-cpp-memory.patch",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets just use existing patch - no?

],
patch_args = ["-p1"],
)

Expand Down