* [meta-oe][PATCH v2] protobuf: 4.25.5 -> 4.30.0
@ 2025-03-11 8:41 Hongxu Jia
2025-03-11 23:31 ` [oe] " Khem Raj
0 siblings, 1 reply; 5+ messages in thread
From: Hongxu Jia @ 2025-03-11 8:41 UTC (permalink / raw)
To: openembedded-devel
Refresh local patches
- 0001-Fix-build-on-mips-clang.patch
- 0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
Drop the fix for gold linker build
Changelog:
https://github.com/protocolbuffers/protobuf/releases/tag/v30.0
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
.../0001-Fix-build-on-mips-clang.patch | 26 ++++++++-----
...e-respect-CXX-LDFLAGS-variables-fix-.patch | 37 ++++++-------------
...{protobuf_4.25.5.bb => protobuf_4.30.0.bb} | 4 +-
3 files changed, 31 insertions(+), 36 deletions(-)
rename meta-oe/recipes-devtools/protobuf/{protobuf_4.25.5.bb => protobuf_4.30.0.bb} (98%)
diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch
index 9f6116c4c4..6db22c26d3 100644
--- a/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch
+++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch
@@ -1,6 +1,6 @@
-From 08e46feb6553af670754e65d94c3bb6fcd4e0cf9 Mon Sep 17 00:00:00 2001
+From fd5a966a6385165506a1b84298465cbb9f44222d Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
-Date: Sun, 31 Oct 2021 23:39:44 -0700
+Date: Mon, 10 Mar 2025 19:59:19 -0700
Subject: [PATCH] Fix build on mips/clang
clang13 crashes on mips, until its fixed upstream disable tailcall on
@@ -10,17 +10,25 @@ https://bugs.llvm.org/show_bug.cgi?id=52367
Upstream-Status: Inappropriate [Clang workaround]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+Rebase to v4.30.0
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
- src/google/protobuf/port_def.inc | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
+ src/google/protobuf/port_def.inc | 1 +
+ 1 file changed, 1 insertion(+)
+diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
+index 35f49afb4..e9597af0d 100644
--- a/src/google/protobuf/port_def.inc
+++ b/src/google/protobuf/port_def.inc
-@@ -255,6 +255,7 @@
+@@ -222,6 +222,7 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
#error PROTOBUF_TAILCALL was previously defined
#endif
- #if __has_cpp_attribute(clang::musttail) && !defined(__arm__) && \
+ #if ABSL_HAVE_CPP_ATTRIBUTE(clang::musttail) && !defined(__arm__) && \
+ !defined(__mips__) && \
- !defined(_ARCH_PPC) && !defined(__wasm__) && \
- !(defined(_MSC_VER) && defined(_M_IX86)) && \
- !(defined(__NDK_MAJOR__) && __NDK_MAJOR <= 24)
+ !defined(_ARCH_PPC) && !defined(__wasm__) && \
+ !(defined(_MSC_VER) && defined(_M_IX86)) && !defined(__i386__)
+ // Compilation fails on ARM32: b/195943306
+--
+2.25.1
+
diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
index 7c4bf260eb..5457d0d6bc 100644
--- a/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
+++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
@@ -1,36 +1,23 @@
-From e3fa241637ab5a7fa78c0d474802134cff75f91e Mon Sep 17 00:00:00 2001
+From 88d4e5afb2c3b56933c529216cd8b733e10a5b7b Mon Sep 17 00:00:00 2001
From: Martin Jansa <Martin.Jansa@gmail.com>
-Date: Fri, 28 Jun 2019 13:50:52 +0000
-Subject: [PATCH] examples/Makefile: respect CXX,LDFLAGS variables, fix build
- with gold
+Date: Tue, 11 Mar 2025 16:35:39 +0800
+Subject: [PATCH] examples/Makefile: respect CXX,LDFLAGS variables
* move pkg-config call to separate variable, so that the final version
of the whole command so it's shown in log.do_compile_ptest_base
-* add ../src/google/protobuf/.libs/timestamp.pb.o when linking
- add_person_cpp otherwise it fails to link with gold:
- i686-oe-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=core2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
- /tmp/cccjSJQs.o:addressbook.pb.cc:scc_info_Person_addressbook_2eproto: error: undefined reference to 'scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto'
- /tmp/cccjSJQs.o:addressbook.pb.cc:descriptor_table_addressbook_2eproto_deps: error: undefined reference to 'descriptor_table_google_2fprotobuf_2ftimestamp_2eproto'
- collect2: error: ld returned 1 exit status
- Makefile:43: recipe for target 'add_person_cpp' failed
-
-* and the same with list_people_cpp this time with pkg-config already through the variable:
- i686-oe-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=core2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -pthread -Icore2-32-oe-linux/protobuf/3.8.0-r0/git/src -Lcore2-32-oe-linux/protobuf/3.8.0-r0/git/src/.libs -Lcore2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot/usr/lib -lprotobuf list_people.cc addressbook.pb.cc -o list_people_cpp
- /tmp/ccpaI5Su.o:addressbook.pb.cc:scc_info_Person_addressbook_2eproto: error: undefined reference to 'scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto'
- /tmp/ccpaI5Su.o:addressbook.pb.cc:descriptor_table_addressbook_2eproto_deps: error: undefined reference to 'descriptor_table_google_2fprotobuf_2ftimestamp_2eproto'
- collect2: error: ld returned 1 exit status
- Makefile:49: recipe for target 'list_people_cpp' failed
Upstream-Status: Pending
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
+Rebase to v4.30.0
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
examples/Makefile | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/examples/Makefile b/examples/Makefile
-index ef7a4ef58..7206e14e1 100644
+index 5290fdb03f..b695b03707 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -2,6 +2,8 @@
@@ -42,20 +29,20 @@ index ef7a4ef58..7206e14e1 100644
all: cpp java python
cpp: add_person_cpp list_people_cpp
-@@ -41,11 +43,11 @@ protoc_middleman_dart: addressbook.proto
+@@ -46,11 +48,11 @@ protoc_middleman_ruby: addressbook.proto
add_person_cpp: add_person.cc protoc_middleman
pkg-config --cflags protobuf # fails if protobuf is not installed
-- c++ -std=c++14 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
-+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp #$(CXX) -std=c++17 $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp
+- c++ add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
++ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp
list_people_cpp: list_people.cc protoc_middleman
pkg-config --cflags protobuf # fails if protobuf is not installed
-- c++ -std=c++14 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
-+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp #$(CXX) -std=c++17 $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp
+- c++ list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
++ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp
add_person_dart: add_person.dart protoc_middleman_dart
---
+--
2.34.1
diff --git a/meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb b/meta-oe/recipes-devtools/protobuf/protobuf_4.30.0.bb
similarity index 98%
rename from meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb
rename to meta-oe/recipes-devtools/protobuf/protobuf_4.30.0.bb
index a470a7c643..f899a1dc07 100644
--- a/meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb
+++ b/meta-oe/recipes-devtools/protobuf/protobuf_4.30.0.bb
@@ -14,9 +14,9 @@ LIC_FILES_CHKSUM = " \
DEPENDS = "zlib abseil-cpp jsoncpp"
DEPENDS:append:class-target = " protobuf-native"
-SRCREV = "9d0ec0f92b5b5fdeeda11f9dcecc1872ff378014"
+SRCREV = "d295af5c3002c08e1bfd9d7f9e175d0a4d015f1e"
-SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=25.x;protocol=https \
+SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=30.x;protocol=https \
file://run-ptest \
file://0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch \
"
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [oe] [meta-oe][PATCH v2] protobuf: 4.25.5 -> 4.30.0
2025-03-11 8:41 [meta-oe][PATCH v2] protobuf: 4.25.5 -> 4.30.0 Hongxu Jia
@ 2025-03-11 23:31 ` Khem Raj
2025-03-12 7:54 ` [meta-oe][PATCH] protobuf-c: 1.5.0 -> 1.5.1 Hongxu Jia
2025-03-12 17:14 ` [oe] [meta-oe][PATCH v2] protobuf: 4.25.5 -> 4.30.0 Khem Raj
0 siblings, 2 replies; 5+ messages in thread
From: Khem Raj @ 2025-03-11 23:31 UTC (permalink / raw)
To: hongxu.jia; +Cc: openembedded-devel
This causes protobuf-c to not build see
https://autobuilder.yoctoproject.org/valkyrie/#/builders/81/builds/446/steps/14/logs/stdio
On Tue, Mar 11, 2025 at 1:41 AM hongxu via lists.openembedded.org
<hongxu.jia=eng.windriver.com@lists.openembedded.org> wrote:
>
> Refresh local patches
> - 0001-Fix-build-on-mips-clang.patch
> - 0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
>
> Drop the fix for gold linker build
>
> Changelog:
> https://github.com/protocolbuffers/protobuf/releases/tag/v30.0
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
> .../0001-Fix-build-on-mips-clang.patch | 26 ++++++++-----
> ...e-respect-CXX-LDFLAGS-variables-fix-.patch | 37 ++++++-------------
> ...{protobuf_4.25.5.bb => protobuf_4.30.0.bb} | 4 +-
> 3 files changed, 31 insertions(+), 36 deletions(-)
> rename meta-oe/recipes-devtools/protobuf/{protobuf_4.25.5.bb => protobuf_4.30.0.bb} (98%)
>
> diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch
> index 9f6116c4c4..6db22c26d3 100644
> --- a/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch
> +++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch
> @@ -1,6 +1,6 @@
> -From 08e46feb6553af670754e65d94c3bb6fcd4e0cf9 Mon Sep 17 00:00:00 2001
> +From fd5a966a6385165506a1b84298465cbb9f44222d Mon Sep 17 00:00:00 2001
> From: Khem Raj <raj.khem@gmail.com>
> -Date: Sun, 31 Oct 2021 23:39:44 -0700
> +Date: Mon, 10 Mar 2025 19:59:19 -0700
> Subject: [PATCH] Fix build on mips/clang
>
> clang13 crashes on mips, until its fixed upstream disable tailcall on
> @@ -10,17 +10,25 @@ https://bugs.llvm.org/show_bug.cgi?id=52367
>
> Upstream-Status: Inappropriate [Clang workaround]
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> +
> +Rebase to v4.30.0
> +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
> - src/google/protobuf/port_def.inc | 2 +-
> - 1 file changed, 1 insertion(+), 1 deletion(-)
> + src/google/protobuf/port_def.inc | 1 +
> + 1 file changed, 1 insertion(+)
>
> +diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
> +index 35f49afb4..e9597af0d 100644
> --- a/src/google/protobuf/port_def.inc
> +++ b/src/google/protobuf/port_def.inc
> -@@ -255,6 +255,7 @@
> +@@ -222,6 +222,7 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
> #error PROTOBUF_TAILCALL was previously defined
> #endif
> - #if __has_cpp_attribute(clang::musttail) && !defined(__arm__) && \
> + #if ABSL_HAVE_CPP_ATTRIBUTE(clang::musttail) && !defined(__arm__) && \
> + !defined(__mips__) && \
> - !defined(_ARCH_PPC) && !defined(__wasm__) && \
> - !(defined(_MSC_VER) && defined(_M_IX86)) && \
> - !(defined(__NDK_MAJOR__) && __NDK_MAJOR <= 24)
> + !defined(_ARCH_PPC) && !defined(__wasm__) && \
> + !(defined(_MSC_VER) && defined(_M_IX86)) && !defined(__i386__)
> + // Compilation fails on ARM32: b/195943306
> +--
> +2.25.1
> +
> diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
> index 7c4bf260eb..5457d0d6bc 100644
> --- a/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
> +++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
> @@ -1,36 +1,23 @@
> -From e3fa241637ab5a7fa78c0d474802134cff75f91e Mon Sep 17 00:00:00 2001
> +From 88d4e5afb2c3b56933c529216cd8b733e10a5b7b Mon Sep 17 00:00:00 2001
> From: Martin Jansa <Martin.Jansa@gmail.com>
> -Date: Fri, 28 Jun 2019 13:50:52 +0000
> -Subject: [PATCH] examples/Makefile: respect CXX,LDFLAGS variables, fix build
> - with gold
> +Date: Tue, 11 Mar 2025 16:35:39 +0800
> +Subject: [PATCH] examples/Makefile: respect CXX,LDFLAGS variables
>
> * move pkg-config call to separate variable, so that the final version
> of the whole command so it's shown in log.do_compile_ptest_base
> -* add ../src/google/protobuf/.libs/timestamp.pb.o when linking
> - add_person_cpp otherwise it fails to link with gold:
> - i686-oe-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=core2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
> - /tmp/cccjSJQs.o:addressbook.pb.cc:scc_info_Person_addressbook_2eproto: error: undefined reference to 'scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto'
> - /tmp/cccjSJQs.o:addressbook.pb.cc:descriptor_table_addressbook_2eproto_deps: error: undefined reference to 'descriptor_table_google_2fprotobuf_2ftimestamp_2eproto'
> - collect2: error: ld returned 1 exit status
> - Makefile:43: recipe for target 'add_person_cpp' failed
> -
> -* and the same with list_people_cpp this time with pkg-config already through the variable:
> - i686-oe-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=core2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -pthread -Icore2-32-oe-linux/protobuf/3.8.0-r0/git/src -Lcore2-32-oe-linux/protobuf/3.8.0-r0/git/src/.libs -Lcore2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot/usr/lib -lprotobuf list_people.cc addressbook.pb.cc -o list_people_cpp
> - /tmp/ccpaI5Su.o:addressbook.pb.cc:scc_info_Person_addressbook_2eproto: error: undefined reference to 'scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto'
> - /tmp/ccpaI5Su.o:addressbook.pb.cc:descriptor_table_addressbook_2eproto_deps: error: undefined reference to 'descriptor_table_google_2fprotobuf_2ftimestamp_2eproto'
> - collect2: error: ld returned 1 exit status
> - Makefile:49: recipe for target 'list_people_cpp' failed
>
> Upstream-Status: Pending
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
>
> +Rebase to v4.30.0
> +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
> examples/Makefile | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/examples/Makefile b/examples/Makefile
> -index ef7a4ef58..7206e14e1 100644
> +index 5290fdb03f..b695b03707 100644
> --- a/examples/Makefile
> +++ b/examples/Makefile
> @@ -2,6 +2,8 @@
> @@ -42,20 +29,20 @@ index ef7a4ef58..7206e14e1 100644
> all: cpp java python
>
> cpp: add_person_cpp list_people_cpp
> -@@ -41,11 +43,11 @@ protoc_middleman_dart: addressbook.proto
> +@@ -46,11 +48,11 @@ protoc_middleman_ruby: addressbook.proto
>
> add_person_cpp: add_person.cc protoc_middleman
> pkg-config --cflags protobuf # fails if protobuf is not installed
> -- c++ -std=c++14 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
> -+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp #$(CXX) -std=c++17 $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp
> +- c++ add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
> ++ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp
>
> list_people_cpp: list_people.cc protoc_middleman
> pkg-config --cflags protobuf # fails if protobuf is not installed
> -- c++ -std=c++14 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
> -+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp #$(CXX) -std=c++17 $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp
> +- c++ list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
> ++ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp
>
> add_person_dart: add_person.dart protoc_middleman_dart
>
> ---
> +--
> 2.34.1
>
> diff --git a/meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb b/meta-oe/recipes-devtools/protobuf/protobuf_4.30.0.bb
> similarity index 98%
> rename from meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb
> rename to meta-oe/recipes-devtools/protobuf/protobuf_4.30.0.bb
> index a470a7c643..f899a1dc07 100644
> --- a/meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb
> +++ b/meta-oe/recipes-devtools/protobuf/protobuf_4.30.0.bb
> @@ -14,9 +14,9 @@ LIC_FILES_CHKSUM = " \
> DEPENDS = "zlib abseil-cpp jsoncpp"
> DEPENDS:append:class-target = " protobuf-native"
>
> -SRCREV = "9d0ec0f92b5b5fdeeda11f9dcecc1872ff378014"
> +SRCREV = "d295af5c3002c08e1bfd9d7f9e175d0a4d015f1e"
>
> -SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=25.x;protocol=https \
> +SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=30.x;protocol=https \
> file://run-ptest \
> file://0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch \
> "
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#115849): https://lists.openembedded.org/g/openembedded-devel/message/115849
> Mute This Topic: https://lists.openembedded.org/mt/111636359/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [meta-oe][PATCH] protobuf-c: 1.5.0 -> 1.5.1
2025-03-11 23:31 ` [oe] " Khem Raj
@ 2025-03-12 7:54 ` Hongxu Jia
2025-03-12 17:14 ` [oe] [meta-oe][PATCH v2] protobuf: 4.25.5 -> 4.30.0 Khem Raj
1 sibling, 0 replies; 5+ messages in thread
From: Hongxu Jia @ 2025-03-12 7:54 UTC (permalink / raw)
To: openembedded-devel, raj.khem
According to [1], protobuf-c 1.5.1 has commits [2] to fix broke with
protobuf 26.0 (4.26.0)
Also port a patch from archlinux [3] to support protobuf 30 (4.30.0)
License-Update: update copyright years to 2025
[1] https://github.com/protobuf-c/protobuf-c/issues/730
[2] https://github.com/protobuf-c/protobuf-c/pull/711/
[3] https://gitlab.archlinux.org/archlinux/packaging/packages/protobuf-c/-/blob/main/protobuf-30.patch
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
...ot-compile-the-code-which-was-genera.patch | 29 +-
.../protobuf/protobuf-c/protobuf-30.patch | 1446 +++++++++++++++++
...rotobuf-c_1.5.0.bb => protobuf-c_1.5.1.bb} | 8 +-
3 files changed, 1467 insertions(+), 16 deletions(-)
create mode 100644 meta-oe/recipes-devtools/protobuf/protobuf-c/protobuf-30.patch
rename meta-oe/recipes-devtools/protobuf/{protobuf-c_1.5.0.bb => protobuf-c_1.5.1.bb} (88%)
diff --git a/meta-oe/recipes-devtools/protobuf/protobuf-c/0001-Makefile.am-do-not-compile-the-code-which-was-genera.patch b/meta-oe/recipes-devtools/protobuf/protobuf-c/0001-Makefile.am-do-not-compile-the-code-which-was-genera.patch
index 896a568e19..cae68e948b 100644
--- a/meta-oe/recipes-devtools/protobuf/protobuf-c/0001-Makefile.am-do-not-compile-the-code-which-was-genera.patch
+++ b/meta-oe/recipes-devtools/protobuf/protobuf-c/0001-Makefile.am-do-not-compile-the-code-which-was-genera.patch
@@ -1,6 +1,6 @@
-From 62b2fd0a150133b6439f6537cb1762d35f5790ee Mon Sep 17 00:00:00 2001
+From ad4d22cd6b0b1237a4d50699736d38cd3c902ace Mon Sep 17 00:00:00 2001
From: Xiangyu Chen <xiangyu.chen@windriver.com>
-Date: Fri, 31 Mar 2023 16:02:50 +0800
+Date: Wed, 12 Mar 2025 00:16:24 -0700
Subject: [PATCH] Makefile.am: do not compile the code which was generated from
test-full.proto in protobuf-c-native
@@ -11,15 +11,18 @@ the test-full.proto with latest version protobuf.
Upstream-Status: Inappropriate [oe specific]
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
+
+Rebase to 1.5.1
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
Makefile.am | 75 -----------------------------------------------------
1 file changed, 75 deletions(-)
diff --git a/Makefile.am b/Makefile.am
-index ff12664..7412aef 100644
+index 77aa9d9..5cdd81a 100644
--- a/Makefile.am
+++ b/Makefile.am
-@@ -136,81 +136,6 @@ else
+@@ -138,81 +138,6 @@ else
LOG_COMPILER = $(VALGRIND)
@@ -72,20 +75,20 @@ index ff12664..7412aef 100644
-t_generated_code2_cxx_generate_packed_data_LDADD = \
- $(protobuf_LIBS)
-
--t/test.pb-c.c t/test.pb-c.h: $(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/test.proto
-- $(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/test.proto
+-t/test.pb-c.c t/test.pb-c.h: $(top_builddir)/protoc-gen-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/test.proto
+- $(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-gen-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/test.proto
-
--t/test-optimized.pb-c.c t/test-optimized.pb-c.h: $(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/test-optimized.proto
-- $(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/test-optimized.proto
+-t/test-optimized.pb-c.c t/test-optimized.pb-c.h: $(top_builddir)/protoc-gen-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/test-optimized.proto
+- $(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-gen-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/test-optimized.proto
-
--t/test-full.pb-c.c t/test-full.pb-c.h: $(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/test-full.proto
-- $(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/test-full.proto
+-t/test-full.pb-c.c t/test-full.pb-c.h: $(top_builddir)/protoc-gen-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/test-full.proto
+- $(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-gen-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/test-full.proto
-
-t/test-full.pb.cc t/test-full.pb.h: @PROTOC@ $(top_srcdir)/t/test-full.proto
- $(AM_V_GEN)@PROTOC@ -I$(top_srcdir) --cpp_out=$(top_builddir) $(top_srcdir)/t/test-full.proto
-
--t/test-proto3.pb-c.c t/test-proto3.pb-c.h: $(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/test-proto3.proto
-- $(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/test-proto3.proto
+-t/test-proto3.pb-c.c t/test-proto3.pb-c.h: $(top_builddir)/protoc-gen-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/test-proto3.proto
+- $(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-gen-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/test-proto3.proto
-
-t/generated-code2/test-full-cxx-output.inc: t/generated-code2/cxx-generate-packed-data$(EXEEXT)
- $(AM_V_GEN)$(top_builddir)/t/generated-code2/cxx-generate-packed-data$(EXEEXT) > $(top_builddir)/t/generated-code2/test-full-cxx-output.inc
@@ -102,5 +105,5 @@ index ff12664..7412aef 100644
t/version/version.c
t_version_version_LDADD = \
--
-2.34.1
+2.25.1
diff --git a/meta-oe/recipes-devtools/protobuf/protobuf-c/protobuf-30.patch b/meta-oe/recipes-devtools/protobuf/protobuf-c/protobuf-30.patch
new file mode 100644
index 0000000000..1aae1f17b0
--- /dev/null
+++ b/meta-oe/recipes-devtools/protobuf/protobuf-c/protobuf-30.patch
@@ -0,0 +1,1446 @@
+From b28683f8027bf1e886b748b5603eb16d203b5a92 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 18:18:33 -0500
+Subject: [PATCH 01/11] protoc-gen-c/c_helpers.h: Move compat defines into new
+ header file compat.h
+
+Upstream-Status: Backport [https://gitlab.archlinux.org/archlinux/packaging/packages/protobuf-c/-/blob/main/protobuf-30.patch]
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ protoc-gen-c/c_field.cc | 1 +
+ protoc-gen-c/c_helpers.cc | 1 +
+ protoc-gen-c/c_helpers.h | 10 -------
+ protoc-gen-c/c_message.cc | 1 +
+ protoc-gen-c/c_primitive_field.cc | 1 +
+ protoc-gen-c/compat.h | 46 +++++++++++++++++++++++++++++++
+ protoc-gen-c/main.cc | 1 +
+ 7 files changed, 51 insertions(+), 10 deletions(-)
+ create mode 100644 protoc-gen-c/compat.h
+
+diff --git a/protoc-gen-c/c_field.cc b/protoc-gen-c/c_field.cc
+index 5e79967b..d6d8597e 100644
+--- a/protoc-gen-c/c_field.cc
++++ b/protoc-gen-c/c_field.cc
+@@ -74,6 +74,7 @@
+ #include "c_message_field.h"
+ #include "c_primitive_field.h"
+ #include "c_string_field.h"
++#include "compat.h"
+
+ namespace protobuf_c {
+
+diff --git a/protoc-gen-c/c_helpers.cc b/protoc-gen-c/c_helpers.cc
+index 5edcf904..c38843f8 100644
+--- a/protoc-gen-c/c_helpers.cc
++++ b/protoc-gen-c/c_helpers.cc
+@@ -73,6 +73,7 @@
+ #include <google/protobuf/stubs/common.h>
+
+ #include "c_helpers.h"
++#include "compat.h"
+
+ namespace protobuf_c {
+
+diff --git a/protoc-gen-c/c_helpers.h b/protoc-gen-c/c_helpers.h
+index 943676e9..e69504bb 100644
+--- a/protoc-gen-c/c_helpers.h
++++ b/protoc-gen-c/c_helpers.h
+@@ -186,16 +186,6 @@ inline int FieldSyntax(const google::protobuf::FieldDescriptor* field) {
+ return 2;
+ }
+
+-// Work around changes in protobuf >= 22.x without breaking compilation against
+-// older protobuf versions.
+-#if GOOGLE_PROTOBUF_VERSION >= 4022000
+-# define GOOGLE_ARRAYSIZE ABSL_ARRAYSIZE
+-# define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
+-# define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
+-# define GOOGLE_DCHECK_GE ABSL_DCHECK_GE
+-# define GOOGLE_LOG ABSL_LOG
+-#endif
+-
+ } // namespace protobuf_c
+
+ #endif // PROTOBUF_C_PROTOC_GEN_C_C_HELPERS_H__
+diff --git a/protoc-gen-c/c_message.cc b/protoc-gen-c/c_message.cc
+index d4a9a01e..46413873 100644
+--- a/protoc-gen-c/c_message.cc
++++ b/protoc-gen-c/c_message.cc
+@@ -78,6 +78,7 @@
+ #include "c_extension.h"
+ #include "c_helpers.h"
+ #include "c_message.h"
++#include "compat.h"
+
+ namespace protobuf_c {
+
+diff --git a/protoc-gen-c/c_primitive_field.cc b/protoc-gen-c/c_primitive_field.cc
+index 253b00bd..588f60e6 100644
+--- a/protoc-gen-c/c_primitive_field.cc
++++ b/protoc-gen-c/c_primitive_field.cc
+@@ -67,6 +67,7 @@
+
+ #include "c_helpers.h"
+ #include "c_primitive_field.h"
++#include "compat.h"
+
+ namespace protobuf_c {
+
+diff --git a/protoc-gen-c/compat.h b/protoc-gen-c/compat.h
+new file mode 100644
+index 00000000..2ee78281
+--- /dev/null
++++ b/protoc-gen-c/compat.h
+@@ -0,0 +1,46 @@
++// Copyright (c) 2008-2025, Dave Benson and the protobuf-c authors.
++// All rights reserved.
++//
++// Redistribution and use in source and binary forms, with or without
++// modification, are permitted provided that the following conditions are
++// met:
++//
++// * Redistributions of source code must retain the above copyright
++// notice, this list of conditions and the following disclaimer.
++//
++// * Redistributions in binary form must reproduce the above
++// copyright notice, this list of conditions and the following disclaimer
++// in the documentation and/or other materials provided with the
++// distribution.
++//
++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++
++#ifndef PROTOBUF_C_PROTOC_GEN_C_COMPAT_H__
++#define PROTOBUF_C_PROTOC_GEN_C_COMPAT_H__
++
++#if GOOGLE_PROTOBUF_VERSION >= 4022000
++# define GOOGLE_ARRAYSIZE ABSL_ARRAYSIZE
++# define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
++# define GOOGLE_DCHECK_GE ABSL_DCHECK_GE
++# define GOOGLE_LOG ABSL_LOG
++#endif
++
++namespace protobuf_c {
++
++namespace compat {
++
++} // namespace compat
++
++} // namespace protobuf_c
++
++#endif // PROTOBUF_C_PROTOC_GEN_C_COMPAT_H__
+diff --git a/protoc-gen-c/main.cc b/protoc-gen-c/main.cc
+index 0656c113..5ab929d3 100644
+--- a/protoc-gen-c/main.cc
++++ b/protoc-gen-c/main.cc
+@@ -32,6 +32,7 @@
+
+ #include "c_generator.h"
+ #include "c_helpers.h"
++#include "compat.h"
+
+ int main(int argc, char* argv[]) {
+ protobuf_c::CGenerator c_generator;
+
+From 1678f1fba6f2d3e5c1db2817495ddcd72bd4e87b Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 20:09:03 -0500
+Subject: [PATCH 02/11] protoc-gen-c/compat.h: Add `compat::StringView` type
+
+protobuf >= 30.x replaces `const std::string&` in various APIs with
+its own string view type that may actually be a `absl::string_view`.
+Introduce our own `compat::StringView` type that we can use instead
+of `const std::string&` in order to support compiling across multiple
+protobuf versions.
+---
+ protoc-gen-c/compat.h | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/protoc-gen-c/compat.h b/protoc-gen-c/compat.h
+index 2ee78281..fe8041b5 100644
+--- a/protoc-gen-c/compat.h
++++ b/protoc-gen-c/compat.h
+@@ -28,6 +28,8 @@
+ #ifndef PROTOBUF_C_PROTOC_GEN_C_COMPAT_H__
+ #define PROTOBUF_C_PROTOC_GEN_C_COMPAT_H__
+
++#include <string>
++
+ #if GOOGLE_PROTOBUF_VERSION >= 4022000
+ # define GOOGLE_ARRAYSIZE ABSL_ARRAYSIZE
+ # define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
+@@ -39,6 +41,12 @@ namespace protobuf_c {
+
+ namespace compat {
+
++#if GOOGLE_PROTOBUF_VERSION >= 6030000
++typedef google::protobuf::internal::DescriptorStringView StringView;
++#else
++typedef const std::string& StringView;
++#endif
++
+ } // namespace compat
+
+ } // namespace protobuf_c
+
+From db5252c131c82fb48ee599179b6989a577b7fbc8 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 20:13:44 -0500
+Subject: [PATCH 03/11] Remove some unused functions
+
+---
+ protoc-gen-c/c_helpers.cc | 64 ---------------------------------------
+ protoc-gen-c/c_helpers.h | 3 --
+ 2 files changed, 67 deletions(-)
+
+diff --git a/protoc-gen-c/c_helpers.cc b/protoc-gen-c/c_helpers.cc
+index c38843f8..bbb4a615 100644
+--- a/protoc-gen-c/c_helpers.cc
++++ b/protoc-gen-c/c_helpers.cc
+@@ -90,14 +90,6 @@ namespace protobuf_c {
+ #pragma warning(disable:4996)
+ #endif
+
+-std::string DotsToUnderscores(const std::string& name) {
+- return StringReplace(name, ".", "_", true);
+-}
+-
+-std::string DotsToColons(const std::string& name) {
+- return StringReplace(name, ".", "::", true);
+-}
+-
+ std::string SimpleFtoa(float f) {
+ char buf[100];
+ snprintf(buf,sizeof(buf),"%.*g", FLT_DIG, f);
+@@ -333,11 +325,6 @@ std::string FilenameIdentifier(const std::string& filename) {
+ return result;
+ }
+
+-// Return the name of the BuildDescriptors() function for a given file.
+-std::string GlobalBuildDescriptorsName(const std::string& filename) {
+- return "proto_BuildDescriptors_" + FilenameIdentifier(filename);
+-}
+-
+ std::string GetLabelName(google::protobuf::FieldDescriptor::Label label) {
+ switch (label) {
+ case google::protobuf::FieldDescriptor::LABEL_OPTIONAL: return "optional";
+@@ -392,57 +379,6 @@ WriteIntRanges(google::protobuf::io::Printer* printer, int n_values, const int *
+ }
+ }
+
+-
+-
+-// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+-// XXXXXXXXX this stuff is copied from strutils.cc !!!! XXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+-// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+-// ----------------------------------------------------------------------
+-// StringReplace()
+-// Replace the "old" pattern with the "new" pattern in a string,
+-// and append the result to "res". If replace_all is false,
+-// it only replaces the first instance of "old."
+-// ----------------------------------------------------------------------
+-
+-void StringReplace(const std::string& s, const std::string& oldsub,
+- const std::string& newsub, bool replace_all,
+- std::string* res) {
+- if (oldsub.empty()) {
+- res->append(s); // if empty, append the given string.
+- return;
+- }
+-
+- std::string::size_type start_pos = 0;
+- std::string::size_type pos;
+- do {
+- pos = s.find(oldsub, start_pos);
+- if (pos == std::string::npos) {
+- break;
+- }
+- res->append(s, start_pos, pos - start_pos);
+- res->append(newsub);
+- start_pos = pos + oldsub.size(); // start searching again after the "old"
+- } while (replace_all);
+- res->append(s, start_pos, s.length() - start_pos);
+-}
+-
+-
+-// ----------------------------------------------------------------------
+-// StringReplace()
+-// Give me a string and two patterns "old" and "new", and I replace
+-// the first instance of "old" in the string with "new", if it
+-// exists. If "global" is true; call this repeatedly until it
+-// fails. RETURN a new string, regardless of whether the replacement
+-// happened or not.
+-// ----------------------------------------------------------------------
+-
+-std::string StringReplace(const std::string& s, const std::string& oldsub,
+- const std::string& newsub, bool replace_all) {
+- std::string ret;
+- StringReplace(s, oldsub, newsub, replace_all, &ret);
+- return ret;
+-}
+-
+ // ----------------------------------------------------------------------
+ // SplitStringUsing()
+ // Split a string using a character delimiter. Append the components
+diff --git a/protoc-gen-c/c_helpers.h b/protoc-gen-c/c_helpers.h
+index e69504bb..377d4272 100644
+--- a/protoc-gen-c/c_helpers.h
++++ b/protoc-gen-c/c_helpers.h
+@@ -150,9 +150,6 @@ const char* DeclaredTypeMethodName(google::protobuf::FieldDescriptor::Type type)
+ // Convert a file name into a valid identifier.
+ std::string FilenameIdentifier(const std::string& filename);
+
+-// Return the name of the BuildDescriptors() function for a given file.
+-std::string GlobalBuildDescriptorsName(const std::string& filename);
+-
+ // return 'required', 'optional', or 'repeated'
+ std::string GetLabelName(google::protobuf::FieldDescriptor::Label label);
+
+
+From bc2cb66d908f016dd3f7082c8a6ad7c58bc03412 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 20:18:05 -0500
+Subject: [PATCH 04/11] Use `compat::StringView` type across various function
+ signatures
+
+---
+ protoc-gen-c/c_helpers.cc | 44 +++++++++++++++++++++------------------
+ protoc-gen-c/c_helpers.h | 36 ++++++++++++++++----------------
+ 2 files changed, 42 insertions(+), 38 deletions(-)
+
+diff --git a/protoc-gen-c/c_helpers.cc b/protoc-gen-c/c_helpers.cc
+index bbb4a615..c759c8c2 100644
+--- a/protoc-gen-c/c_helpers.cc
++++ b/protoc-gen-c/c_helpers.cc
+@@ -96,6 +96,7 @@ std::string SimpleFtoa(float f) {
+ buf[sizeof(buf)-1] = 0; /* should NOT be necessary */
+ return buf;
+ }
++
+ std::string SimpleDtoa(double d) {
+ char buf[100];
+ snprintf(buf,sizeof(buf),"%.*g", DBL_DIG, d);
+@@ -103,7 +104,7 @@ std::string SimpleDtoa(double d) {
+ return buf;
+ }
+
+-std::string CamelToUpper(const std::string &name) {
++std::string CamelToUpper(compat::StringView name) {
+ bool was_upper = true; // suppress initial _
+ std::string rv = "";
+ int len = name.length();
+@@ -120,7 +121,8 @@ std::string CamelToUpper(const std::string &name) {
+ }
+ return rv;
+ }
+-std::string CamelToLower(const std::string &name) {
++
++std::string CamelToLower(compat::StringView name) {
+ bool was_upper = true; // suppress initial _
+ std::string rv = "";
+ int len = name.length();
+@@ -138,8 +140,7 @@ std::string CamelToLower(const std::string &name) {
+ return rv;
+ }
+
+-
+-std::string ToUpper(const std::string &name) {
++std::string ToUpper(compat::StringView name) {
+ std::string rv = "";
+ int len = name.length();
+ for (int i = 0; i < len; i++) {
+@@ -147,7 +148,8 @@ std::string ToUpper(const std::string &name) {
+ }
+ return rv;
+ }
+-std::string ToLower(const std::string &name) {
++
++std::string ToLower(compat::StringView name) {
+ std::string rv = "";
+ int len = name.length();
+ for (int i = 0; i < len; i++) {
+@@ -155,7 +157,8 @@ std::string ToLower(const std::string &name) {
+ }
+ return rv;
+ }
+-std::string ToCamel(const std::string &name) {
++
++std::string ToCamel(compat::StringView name) {
+ std::string rv = "";
+ int len = name.length();
+ bool next_is_upper = true;
+@@ -172,7 +175,7 @@ std::string ToCamel(const std::string &name) {
+ return rv;
+ }
+
+-std::string OverrideFullName(const std::string &full_name, const google::protobuf::FileDescriptor* file) {
++std::string OverrideFullName(compat::StringView full_name, const google::protobuf::FileDescriptor* file) {
+ const ProtobufCFileOptions opt = file->options().GetExtension(pb_c_file);
+ if (!opt.has_c_package())
+ return full_name;
+@@ -184,7 +187,7 @@ std::string OverrideFullName(const std::string &full_name, const google::protobu
+ return new_name + full_name.substr(file->package().length());
+ }
+
+-std::string FullNameToLower(const std::string &full_name, const google::protobuf::FileDescriptor* file) {
++std::string FullNameToLower(compat::StringView full_name, const google::protobuf::FileDescriptor* file) {
+ std::vector<std::string> pieces;
+ SplitStringUsing(OverrideFullName(full_name, file), ".", &pieces);
+ std::string rv = "";
+@@ -195,7 +198,8 @@ std::string FullNameToLower(const std::string &full_name, const google::protobuf
+ }
+ return rv;
+ }
+-std::string FullNameToUpper(const std::string &full_name, const google::protobuf::FileDescriptor* file) {
++
++std::string FullNameToUpper(compat::StringView full_name, const google::protobuf::FileDescriptor* file) {
+ std::vector<std::string> pieces;
+ SplitStringUsing(OverrideFullName(full_name, file), ".", &pieces);
+ std::string rv = "";
+@@ -206,7 +210,8 @@ std::string FullNameToUpper(const std::string &full_name, const google::protobuf
+ }
+ return rv;
+ }
+-std::string FullNameToC(const std::string &full_name, const google::protobuf::FileDescriptor* file) {
++
++std::string FullNameToC(compat::StringView full_name, const google::protobuf::FileDescriptor* file) {
+ std::vector<std::string> pieces;
+ SplitStringUsing(OverrideFullName(full_name, file), ".", &pieces);
+ std::string rv = "";
+@@ -248,7 +253,7 @@ void PrintComment(google::protobuf::io::Printer* printer, std::string comment)
+ }
+ }
+
+-std::string ConvertToSpaces(const std::string &input) {
++std::string ConvertToSpaces(compat::StringView input) {
+ return std::string(input.size(), ' ');
+ }
+
+@@ -259,8 +264,7 @@ int compare_name_indices_by_name(const void *a, const void *b)
+ return strcmp (ni_a->name, ni_b->name);
+ }
+
+-
+-std::string CEscape(const std::string& src);
++std::string CEscape(compat::StringView src);
+
+ const char* const kKeywordList[] = {
+ "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case",
+@@ -300,7 +304,7 @@ std::string FieldDeprecated(const google::protobuf::FieldDescriptor* field) {
+ return "";
+ }
+
+-std::string StripProto(const std::string& filename) {
++std::string StripProto(compat::StringView filename) {
+ if (HasSuffixString(filename, ".protodevel")) {
+ return StripSuffixString(filename, ".protodevel");
+ } else {
+@@ -309,7 +313,7 @@ std::string StripProto(const std::string& filename) {
+ }
+
+ // Convert a file name into a valid identifier.
+-std::string FilenameIdentifier(const std::string& filename) {
++std::string FilenameIdentifier(compat::StringView filename) {
+ std::string result;
+ for (unsigned i = 0; i < filename.size(); i++) {
+ if (isalnum(filename[i])) {
+@@ -335,7 +339,7 @@ std::string GetLabelName(google::protobuf::FieldDescriptor::Label label) {
+ }
+
+ unsigned
+-WriteIntRanges(google::protobuf::io::Printer* printer, int n_values, const int *values, const std::string &name)
++WriteIntRanges(google::protobuf::io::Printer* printer, int n_values, const int *values, compat::StringView name)
+ {
+ std::map<std::string, std::string> vars;
+ vars["name"] = name;
+@@ -389,7 +393,7 @@ WriteIntRanges(google::protobuf::io::Printer* printer, int n_values, const int *
+ // ----------------------------------------------------------------------
+ template <typename ITR>
+ static inline
+-void SplitStringToIteratorUsing(const std::string& full,
++void SplitStringToIteratorUsing(compat::StringView full,
+ const char* delim,
+ ITR& result) {
+ // Optimize the common case where delim is a single character.
+@@ -422,7 +426,7 @@ void SplitStringToIteratorUsing(const std::string& full,
+ }
+ }
+
+-void SplitStringUsing(const std::string& full,
++void SplitStringUsing(compat::StringView full,
+ const char* delim,
+ std::vector<std::string>* result) {
+ std::back_insert_iterator< std::vector<std::string> > it(*result);
+@@ -435,7 +439,6 @@ char* FastHexToBuffer(int i, char* buffer)
+ return buffer;
+ }
+
+-
+ static int CEscapeInternal(const char* src, int src_len, char* dest,
+ int dest_len, bool use_hex) {
+ const char* src_end = src + src_len;
+@@ -478,7 +481,8 @@ static int CEscapeInternal(const char* src, int src_len, char* dest,
+ dest[used] = '\0'; // doesn't count towards return value though
+ return used;
+ }
+-std::string CEscape(const std::string& src) {
++
++std::string CEscape(compat::StringView src) {
+ const int dest_length = src.size() * 4 + 1; // Maximum possible expansion
+ std::unique_ptr<char[]> dest(new char[dest_length]);
+ const int len = CEscapeInternal(src.data(), src.size(),
+diff --git a/protoc-gen-c/c_helpers.h b/protoc-gen-c/c_helpers.h
+index 377d4272..ccd39ca2 100644
+--- a/protoc-gen-c/c_helpers.h
++++ b/protoc-gen-c/c_helpers.h
+@@ -73,6 +73,8 @@
+
+ #include <protobuf-c/protobuf-c.pb.h>
+
++#include "compat.h"
++
+ namespace protobuf_c {
+
+ // --- Borrowed from stubs. ---
+@@ -84,11 +86,10 @@ template <typename T> std::string SimpleItoa(T n) {
+
+ std::string SimpleFtoa(float f);
+ std::string SimpleDtoa(double f);
+-void SplitStringUsing(const std::string &str, const char *delim, std::vector<std::string> *out);
+-std::string CEscape(const std::string& src);
+-std::string StringReplace(const std::string& s, const std::string& oldsub, const std::string& newsub, bool replace_all);
+-inline bool HasSuffixString(const std::string& str, const std::string& suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; }
+-inline std::string StripSuffixString(const std::string& str, const std::string& suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } }
++void SplitStringUsing(compat::StringView str, const char *delim, std::vector<std::string> *out);
++std::string CEscape(compat::StringView src);
++inline bool HasSuffixString(compat::StringView str, compat::StringView suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; }
++inline std::string StripSuffixString(compat::StringView str, compat::StringView suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } }
+ char* FastHexToBuffer(int i, char* buffer);
+
+
+@@ -110,31 +111,31 @@ inline const google::protobuf::Descriptor* FieldScope(const google::protobuf::Fi
+
+ // convert a CamelCase class name into an all uppercase affair
+ // with underscores separating words, e.g. MyClass becomes MY_CLASS.
+-std::string CamelToUpper(const std::string &class_name);
+-std::string CamelToLower(const std::string &class_name);
++std::string CamelToUpper(compat::StringView class_name);
++std::string CamelToLower(compat::StringView class_name);
+
+ // lowercased, underscored name to camel case
+-std::string ToCamel(const std::string &name);
++std::string ToCamel(compat::StringView name);
+
+ // lowercase the string
+-std::string ToLower(const std::string &class_name);
+-std::string ToUpper(const std::string &class_name);
++std::string ToLower(compat::StringView class_name);
++std::string ToUpper(compat::StringView class_name);
+
+ // full_name() to lowercase with underscores
+-std::string FullNameToLower(const std::string &full_name, const google::protobuf::FileDescriptor *file);
+-std::string FullNameToUpper(const std::string &full_name, const google::protobuf::FileDescriptor *file);
++std::string FullNameToLower(compat::StringView full_name, const google::protobuf::FileDescriptor *file);
++std::string FullNameToUpper(compat::StringView full_name, const google::protobuf::FileDescriptor *file);
+
+ // full_name() to c-typename (with underscores for packages, otherwise camel case)
+-std::string FullNameToC(const std::string &class_name, const google::protobuf::FileDescriptor *file);
++std::string FullNameToC(compat::StringView class_name, const google::protobuf::FileDescriptor *file);
+
+ // Splits, indents, formats, and prints comment lines
+ void PrintComment(google::protobuf::io::Printer* printer, std::string comment);
+
+ // make a string of spaces as long as input
+-std::string ConvertToSpaces(const std::string &input);
++std::string ConvertToSpaces(compat::StringView input);
+
+ // Strips ".proto" or ".protodevel" from the end of a filename.
+-std::string StripProto(const std::string& filename);
++std::string StripProto(compat::StringView filename);
+
+ // Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.).
+ // Note: non-built-in type names will be qualified, meaning they will start
+@@ -148,15 +149,14 @@ const char* PrimitiveTypeName(google::protobuf::FieldDescriptor::CppType type);
+ const char* DeclaredTypeMethodName(google::protobuf::FieldDescriptor::Type type);
+
+ // Convert a file name into a valid identifier.
+-std::string FilenameIdentifier(const std::string& filename);
++std::string FilenameIdentifier(compat::StringView filename);
+
+ // return 'required', 'optional', or 'repeated'
+ std::string GetLabelName(google::protobuf::FieldDescriptor::Label label);
+
+-
+ // write IntRanges entries for a bunch of sorted values.
+ // returns the number of ranges there are to bsearch.
+-unsigned WriteIntRanges(google::protobuf::io::Printer* printer, int n_values, const int *values, const std::string &name);
++unsigned WriteIntRanges(google::protobuf::io::Printer* printer, int n_values, const int *values, compat::StringView name);
+
+ struct NameIndex
+ {
+
+From 75f1c32cc429233a3726358c999009f9ea373b45 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 20:25:43 -0500
+Subject: [PATCH 05/11] Convert string views to owned strings where necessary
+
+---
+ protoc-gen-c/c_enum.cc | 2 +-
+ protoc-gen-c/c_enum_field.cc | 2 +-
+ protoc-gen-c/c_helpers.cc | 8 ++++----
+ protoc-gen-c/c_helpers.h | 3 +--
+ 4 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/protoc-gen-c/c_enum.cc b/protoc-gen-c/c_enum.cc
+index 9212ab82..311e4c86 100644
+--- a/protoc-gen-c/c_enum.cc
++++ b/protoc-gen-c/c_enum.cc
+@@ -152,7 +152,7 @@ void EnumGenerator::GenerateValueInitializer(google::protobuf::io::Printer *prin
+ descriptor_->file()->options().optimize_for() ==
+ google::protobuf::FileOptions_OptimizeMode_CODE_SIZE;
+ vars["enum_value_name"] = vd->name();
+- vars["c_enum_value_name"] = FullNameToUpper(descriptor_->full_name(), descriptor_->file()) + "__" + vd->name();
++ vars["c_enum_value_name"] = FullNameToUpper(descriptor_->full_name(), descriptor_->file()) + "__" + std::string(vd->name());
+ vars["value"] = SimpleItoa(vd->number());
+ if (optimize_code_size)
+ printer->Print(vars, " { NULL, NULL, $value$ }, /* CODE_SIZE */\n");
+diff --git a/protoc-gen-c/c_enum_field.cc b/protoc-gen-c/c_enum_field.cc
+index 0926ae59..c3111f50 100644
+--- a/protoc-gen-c/c_enum_field.cc
++++ b/protoc-gen-c/c_enum_field.cc
+@@ -78,7 +78,7 @@ void SetEnumVariables(const google::protobuf::FieldDescriptor* descriptor,
+ (*variables)["type"] = FullNameToC(descriptor->enum_type()->full_name(), descriptor->enum_type()->file());
+ const google::protobuf::EnumValueDescriptor* default_value = descriptor->default_value_enum();
+ (*variables)["default"] = FullNameToUpper(default_value->type()->full_name(), default_value->type()->file())
+- + "__" + default_value->name();
++ + "__" + std::string(default_value->name());
+ (*variables)["deprecated"] = FieldDeprecated(descriptor);
+ }
+
+diff --git a/protoc-gen-c/c_helpers.cc b/protoc-gen-c/c_helpers.cc
+index c759c8c2..1aecef93 100644
+--- a/protoc-gen-c/c_helpers.cc
++++ b/protoc-gen-c/c_helpers.cc
+@@ -178,13 +178,13 @@ std::string ToCamel(compat::StringView name) {
+ std::string OverrideFullName(compat::StringView full_name, const google::protobuf::FileDescriptor* file) {
+ const ProtobufCFileOptions opt = file->options().GetExtension(pb_c_file);
+ if (!opt.has_c_package())
+- return full_name;
++ return std::string(full_name);
+
+ std::string new_name = opt.c_package();
+ if (file->package().empty())
+ new_name += ".";
+
+- return new_name + full_name.substr(file->package().length());
++ return new_name + std::string(full_name.substr(file->package().length()));
+ }
+
+ std::string FullNameToLower(compat::StringView full_name, const google::protobuf::FileDescriptor* file) {
+@@ -418,10 +418,10 @@ void SplitStringToIteratorUsing(compat::StringView full,
+ while (begin_index != std::string::npos) {
+ end_index = full.find_first_of(delim, begin_index);
+ if (end_index == std::string::npos) {
+- *result++ = full.substr(begin_index);
++ *result++ = std::string(full.substr(begin_index));
+ return;
+ }
+- *result++ = full.substr(begin_index, (end_index - begin_index));
++ *result++ = std::string(full.substr(begin_index, (end_index - begin_index)));
+ begin_index = full.find_first_not_of(delim, end_index);
+ }
+ }
+diff --git a/protoc-gen-c/c_helpers.h b/protoc-gen-c/c_helpers.h
+index ccd39ca2..985e4db6 100644
+--- a/protoc-gen-c/c_helpers.h
++++ b/protoc-gen-c/c_helpers.h
+@@ -89,10 +89,9 @@ std::string SimpleDtoa(double f);
+ void SplitStringUsing(compat::StringView str, const char *delim, std::vector<std::string> *out);
+ std::string CEscape(compat::StringView src);
+ inline bool HasSuffixString(compat::StringView str, compat::StringView suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; }
+-inline std::string StripSuffixString(compat::StringView str, compat::StringView suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } }
++inline std::string StripSuffixString(compat::StringView str, compat::StringView suffix) { if (HasSuffixString(str, suffix)) { return std::string(str.substr(0, str.size() - suffix.size())); } else { return std::string(str); } }
+ char* FastHexToBuffer(int i, char* buffer);
+
+-
+ // Get the (unqualified) name that should be used for this field in C code.
+ // The name is coerced to lower-case to emulate proto1 behavior. People
+ // should be using lowercase-with-underscores style for proto field names
+
+From 0edca93db369fb84f01cc0d4e3ee4cd6c2ad7f4f Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 20:39:11 -0500
+Subject: [PATCH 06/11] Convert various uses of `const char *` to
+ `compat::StringView`
+
+Also replace some uses of arrays manually allocated with new/delete with
+uses of `std::vector`.
+---
+ protoc-gen-c/c_enum.cc | 35 ++++++++++++++++++-----------------
+ protoc-gen-c/c_helpers.cc | 2 +-
+ protoc-gen-c/c_helpers.h | 2 +-
+ protoc-gen-c/c_message.cc | 28 ++++++++++++----------------
+ protoc-gen-c/c_service.cc | 19 +++++++++----------
+ 5 files changed, 41 insertions(+), 45 deletions(-)
+
+diff --git a/protoc-gen-c/c_enum.cc b/protoc-gen-c/c_enum.cc
+index 311e4c86..c7839edd 100644
+--- a/protoc-gen-c/c_enum.cc
++++ b/protoc-gen-c/c_enum.cc
+@@ -142,7 +142,7 @@ struct ValueIndex
+ int value;
+ unsigned index;
+ unsigned final_index; /* index in uniqified array of values */
+- const char *name;
++ compat::StringView name;
+ };
+ void EnumGenerator::GenerateValueInitializer(google::protobuf::io::Printer *printer, int index)
+ {
+@@ -176,7 +176,7 @@ static int compare_value_indices_by_name(const void *a, const void *b)
+ {
+ const ValueIndex *vi_a = (const ValueIndex *) a;
+ const ValueIndex *vi_b = (const ValueIndex *) b;
+- return strcmp (vi_a->name, vi_b->name);
++ return vi_a->name.compare(vi_b->name);
+ }
+
+ void EnumGenerator::GenerateEnumDescriptor(google::protobuf::io::Printer* printer) {
+@@ -194,18 +194,20 @@ void EnumGenerator::GenerateEnumDescriptor(google::protobuf::io::Printer* printe
+
+ // Sort by name and value, dropping duplicate values if they appear later.
+ // TODO: use a c++ paradigm for this!
+- NameIndex *name_index = new NameIndex[descriptor_->value_count()];
+- ValueIndex *value_index = new ValueIndex[descriptor_->value_count()];
+- for (int j = 0; j < descriptor_->value_count(); j++) {
++ std::vector<ValueIndex> value_index;
++ for (unsigned j = 0; j < descriptor_->value_count(); j++) {
+ const google::protobuf::EnumValueDescriptor *vd = descriptor_->value(j);
+- name_index[j].index = j;
+- name_index[j].name = vd->name().c_str();
+- value_index[j].index = j;
+- value_index[j].value = vd->number();
+- value_index[j].name = vd->name().c_str();
++ value_index.push_back({
++ .value = vd->number(),
++ .index = j,
++ .final_index = 0,
++ .name = vd->name(),
++ });
+ }
+- qsort(value_index, descriptor_->value_count(),
+- sizeof(ValueIndex), compare_value_indices_by_value_then_index);
++ qsort(&value_index[0],
++ value_index.size(),
++ sizeof(ValueIndex),
++ compare_value_indices_by_value_then_index);
+
+ // only record unique values
+ int n_unique_values;
+@@ -275,8 +277,10 @@ void EnumGenerator::GenerateEnumDescriptor(google::protobuf::io::Printer* printe
+ vars["n_ranges"] = SimpleItoa(n_ranges);
+
+ if (!optimize_code_size) {
+- qsort(value_index, descriptor_->value_count(),
+- sizeof(ValueIndex), compare_value_indices_by_name);
++ qsort(&value_index[0],
++ value_index.size(),
++ sizeof(ValueIndex),
++ compare_value_indices_by_name);
+ printer->Print(vars,
+ "static const ProtobufCEnumValueIndex $lcclassname$__enum_values_by_name[$value_count$] =\n"
+ "{\n");
+@@ -319,9 +323,6 @@ void EnumGenerator::GenerateEnumDescriptor(google::protobuf::io::Printer* printe
+ " NULL,NULL,NULL,NULL /* reserved[1234] */\n"
+ "};\n");
+ }
+-
+- delete[] value_index;
+- delete[] name_index;
+ }
+
+ } // namespace protobuf_c
+diff --git a/protoc-gen-c/c_helpers.cc b/protoc-gen-c/c_helpers.cc
+index 1aecef93..dec9ce28 100644
+--- a/protoc-gen-c/c_helpers.cc
++++ b/protoc-gen-c/c_helpers.cc
+@@ -261,7 +261,7 @@ int compare_name_indices_by_name(const void *a, const void *b)
+ {
+ const NameIndex *ni_a = (const NameIndex *) a;
+ const NameIndex *ni_b = (const NameIndex *) b;
+- return strcmp (ni_a->name, ni_b->name);
++ return ni_a->name.compare(ni_b->name);
+ }
+
+ std::string CEscape(compat::StringView src);
+diff --git a/protoc-gen-c/c_helpers.h b/protoc-gen-c/c_helpers.h
+index 985e4db6..69369997 100644
+--- a/protoc-gen-c/c_helpers.h
++++ b/protoc-gen-c/c_helpers.h
+@@ -160,7 +160,7 @@ unsigned WriteIntRanges(google::protobuf::io::Printer* printer, int n_values, co
+ struct NameIndex
+ {
+ unsigned index;
+- const char *name;
++ compat::StringView name;
+ };
+ int compare_name_indices_by_name(const void*, const void*);
+
+diff --git a/protoc-gen-c/c_message.cc b/protoc-gen-c/c_message.cc
+index 46413873..7252923c 100644
+--- a/protoc-gen-c/c_message.cc
++++ b/protoc-gen-c/c_message.cc
+@@ -567,27 +567,26 @@ GenerateMessageDescriptor(google::protobuf::io::Printer* printer, bool gen_init)
+ "static const ProtobufCFieldDescriptor $lcclassname$__field_descriptors[$n_fields$] =\n"
+ "{\n");
+ printer->Indent();
+- const google::protobuf::FieldDescriptor **sorted_fields = new const google::protobuf::FieldDescriptor *[descriptor_->field_count()];
++
++ std::vector<const google::protobuf::FieldDescriptor*> sorted_fields;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+- sorted_fields[i] = descriptor_->field(i);
++ sorted_fields.push_back(descriptor_->field(i));
+ }
+- qsort (sorted_fields, descriptor_->field_count(),
++ qsort(&sorted_fields[0], sorted_fields.size(),
+ sizeof(const google::protobuf::FieldDescriptor*),
+ compare_pfields_by_number);
+- for (int i = 0; i < descriptor_->field_count(); i++) {
+- const google::protobuf::FieldDescriptor* field = sorted_fields[i];
++ for (auto field : sorted_fields) {
+ field_generators_.get(field).GenerateDescriptorInitializer(printer);
+ }
+ printer->Outdent();
+ printer->Print(vars, "};\n");
+
+ if (!optimize_code_size) {
+- NameIndex *field_indices = new NameIndex [descriptor_->field_count()];
+- for (int i = 0; i < descriptor_->field_count(); i++) {
+- field_indices[i].name = sorted_fields[i]->name().c_str();
+- field_indices[i].index = i;
++ std::vector<NameIndex> field_indices;
++ for (unsigned i = 0; i < descriptor_->field_count(); i++) {
++ field_indices.push_back({ .index = i, .name = sorted_fields[i]->name() });
+ }
+- qsort (field_indices, descriptor_->field_count(), sizeof (NameIndex),
++ qsort(&field_indices[0], field_indices.size(), sizeof(NameIndex),
+ compare_name_indices_by_name);
+ printer->Print(vars, "static const unsigned $lcclassname$__field_indices_by_name[] = {\n");
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+@@ -596,19 +595,16 @@ GenerateMessageDescriptor(google::protobuf::io::Printer* printer, bool gen_init)
+ printer->Print(vars, " $index$, /* field[$index$] = $name$ */\n");
+ }
+ printer->Print("};\n");
+- delete[] field_indices;
+ }
+
+ // create range initializers
+- int *values = new int[descriptor_->field_count()];
++ std::vector<int> values;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+- values[i] = sorted_fields[i]->number();
++ values.push_back(sorted_fields[i]->number());
+ }
+ int n_ranges = WriteIntRanges(printer,
+- descriptor_->field_count(), values,
++ descriptor_->field_count(), &values[0],
+ vars["lcclassname"] + "__number_ranges");
+- delete [] values;
+- delete [] sorted_fields;
+
+ vars["n_ranges"] = SimpleItoa(n_ranges);
+ } else {
+diff --git a/protoc-gen-c/c_service.cc b/protoc-gen-c/c_service.cc
+index ee4d4a95..2c3ddcf3 100644
+--- a/protoc-gen-c/c_service.cc
++++ b/protoc-gen-c/c_service.cc
+@@ -184,19 +184,19 @@ void ServiceGenerator::GenerateInit(google::protobuf::io::Printer* printer)
+ "}\n");
+ }
+
+-struct MethodIndexAndName { unsigned i; const char *name; };
++struct MethodIndexAndName { unsigned i; compat::StringView name; };
+ static int
+ compare_method_index_and_name_by_name (const void *a, const void *b)
+ {
+ const MethodIndexAndName *ma = (const MethodIndexAndName *) a;
+ const MethodIndexAndName *mb = (const MethodIndexAndName *) b;
+- return strcmp (ma->name, mb->name);
++ return ma->name.compare(mb->name);
+ }
+
+ void ServiceGenerator::GenerateServiceDescriptor(google::protobuf::io::Printer* printer)
+ {
+ int n_methods = descriptor_->method_count();
+- MethodIndexAndName *mi_array = new MethodIndexAndName[n_methods];
++ std::vector<MethodIndexAndName> mi_array;
+
+ bool optimize_code_size = descriptor_->file()->options().has_optimize_for() &&
+ descriptor_->file()->options().optimize_for() ==
+@@ -205,7 +205,7 @@ void ServiceGenerator::GenerateServiceDescriptor(google::protobuf::io::Printer*
+ vars_["n_methods"] = SimpleItoa(n_methods);
+ printer->Print(vars_, "static const ProtobufCMethodDescriptor $lcfullname$__method_descriptors[$n_methods$] =\n"
+ "{\n");
+- for (int i = 0; i < n_methods; i++) {
++ for (unsigned i = 0; i < n_methods; i++) {
+ const google::protobuf::MethodDescriptor* method = descriptor_->method(i);
+ vars_["method"] = method->name();
+ vars_["input_descriptor"] = "&" + FullNameToLower(method->input_type()->full_name(), method->input_type()->file()) + "__descriptor";
+@@ -217,14 +217,15 @@ void ServiceGenerator::GenerateServiceDescriptor(google::protobuf::io::Printer*
+ printer->Print(vars_,
+ " { \"$method$\", $input_descriptor$, $output_descriptor$ },\n");
+ }
+- mi_array[i].i = i;
+- mi_array[i].name = method->name().c_str();
++ mi_array.push_back({i, method->name()});
+ }
+ printer->Print(vars_, "};\n");
+
+ if (!optimize_code_size) {
+- qsort ((void*)mi_array, n_methods, sizeof (MethodIndexAndName),
+- compare_method_index_and_name_by_name);
++ qsort(&mi_array[0],
++ mi_array.size(),
++ sizeof(MethodIndexAndName),
++ compare_method_index_and_name_by_name);
+ printer->Print(vars_, "const unsigned $lcfullname$__method_indices_by_name[] = {\n");
+ for (int i = 0; i < n_methods; i++) {
+ vars_["i"] = SimpleItoa(mi_array[i].i);
+@@ -258,8 +259,6 @@ void ServiceGenerator::GenerateServiceDescriptor(google::protobuf::io::Printer*
+ " $lcfullname$__method_indices_by_name\n"
+ "};\n");
+ }
+-
+- delete[] mi_array;
+ }
+
+ void ServiceGenerator::GenerateCallersImplementations(google::protobuf::io::Printer* printer)
+
+From ebeddac1a746393a16d9ba4cf80e3d12c3ab7d7f Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 20:56:48 -0500
+Subject: [PATCH 07/11] Fix indentation of
+ MessageGenerator::GenerateMessageDescriptor()
+
+---
+ protoc-gen-c/c_message.cc | 321 +++++++++++++++++++-------------------
+ 1 file changed, 159 insertions(+), 162 deletions(-)
+
+diff --git a/protoc-gen-c/c_message.cc b/protoc-gen-c/c_message.cc
+index 7252923c..2a3b2a2f 100644
+--- a/protoc-gen-c/c_message.cc
++++ b/protoc-gen-c/c_message.cc
+@@ -461,199 +461,196 @@ GenerateHelperFunctionDefinitions(google::protobuf::io::Printer* printer,
+
+ void MessageGenerator::
+ GenerateMessageDescriptor(google::protobuf::io::Printer* printer, bool gen_init) {
+- std::map<std::string, std::string> vars;
+- vars["fullname"] = descriptor_->full_name();
+- vars["classname"] = FullNameToC(descriptor_->full_name(), descriptor_->file());
+- vars["lcclassname"] = FullNameToLower(descriptor_->full_name(), descriptor_->file());
+- vars["shortname"] = ToCamel(descriptor_->name());
+- vars["n_fields"] = SimpleItoa(descriptor_->field_count());
+- vars["packagename"] = descriptor_->file()->package();
+-
+- bool optimize_code_size = descriptor_->file()->options().has_optimize_for() &&
+- descriptor_->file()->options().optimize_for() ==
+- google::protobuf::FileOptions_OptimizeMode_CODE_SIZE;
+-
+- const ProtobufCMessageOptions opt =
+- descriptor_->options().GetExtension(pb_c_msg);
+- // Override parent settings, if needed
+- if (opt.has_gen_init_helpers())
+- gen_init = opt.gen_init_helpers();
+-
+- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+- nested_generators_[i]->GenerateMessageDescriptor(printer, gen_init);
+- }
++ std::map<std::string, std::string> vars;
++ vars["fullname"] = descriptor_->full_name();
++ vars["classname"] = FullNameToC(descriptor_->full_name(), descriptor_->file());
++ vars["lcclassname"] = FullNameToLower(descriptor_->full_name(), descriptor_->file());
++ vars["shortname"] = ToCamel(descriptor_->name());
++ vars["n_fields"] = SimpleItoa(descriptor_->field_count());
++ vars["packagename"] = descriptor_->file()->package();
+
+- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
+- enum_generators_[i]->GenerateEnumDescriptor(printer);
+- }
++ bool optimize_code_size = descriptor_->file()->options().has_optimize_for() &&
++ descriptor_->file()->options().optimize_for() ==
++ google::protobuf::FileOptions_OptimizeMode_CODE_SIZE;
+
+- for (int i = 0; i < descriptor_->field_count(); i++) {
+- const google::protobuf::FieldDescriptor* fd = descriptor_->field(i);
+- if (fd->has_default_value()) {
+- field_generators_.get(fd).GenerateDefaultValueImplementations(printer);
+- }
+- }
++ const ProtobufCMessageOptions opt = descriptor_->options().GetExtension(pb_c_msg);
++ // Override parent settings, if needed
++ if (opt.has_gen_init_helpers()) {
++ gen_init = opt.gen_init_helpers();
++ }
+
+- for (int i = 0; i < descriptor_->field_count(); i++) {
+- const google::protobuf::FieldDescriptor* fd = descriptor_->field(i);
+- const ProtobufCFieldOptions opt = fd->options().GetExtension(pb_c_field);
+- if (fd->has_default_value()) {
+-
+- bool already_defined = false;
+- vars["name"] = fd->name();
+- vars["lcname"] = CamelToLower(fd->name());
+- vars["maybe_static"] = "static ";
+- vars["field_dv_ctype_suffix"] = "";
+- vars["default_value"] = field_generators_.get(fd).GetDefaultValue();
+- switch (fd->cpp_type()) {
+- case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
+- vars["field_dv_ctype"] = "int32_t";
+- break;
+- case google::protobuf::FieldDescriptor::CPPTYPE_INT64:
+- vars["field_dv_ctype"] = "int64_t";
+- break;
+- case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:
+- vars["field_dv_ctype"] = "uint32_t";
+- break;
+- case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:
+- vars["field_dv_ctype"] = "uint64_t";
+- break;
+- case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
+- vars["field_dv_ctype"] = "float";
+- break;
+- case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
+- vars["field_dv_ctype"] = "double";
+- break;
+- case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:
+- vars["field_dv_ctype"] = "protobuf_c_boolean";
+- break;
+-
+- case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:
+- // NOTE: not supported by protobuf
+- vars["maybe_static"] = "";
+- vars["field_dv_ctype"] = "{ ... }";
+- GOOGLE_LOG(FATAL) << "Messages can't have default values!";
+- break;
+- case google::protobuf::FieldDescriptor::CPPTYPE_STRING:
+- if (fd->type() == google::protobuf::FieldDescriptor::TYPE_BYTES || opt.string_as_bytes())
+- {
+- vars["field_dv_ctype"] = "ProtobufCBinaryData";
+- }
+- else /* STRING type */
+- {
+- already_defined = true;
+- vars["maybe_static"] = "";
+- vars["field_dv_ctype"] = "char";
+- vars["field_dv_ctype_suffix"] = "[]";
+- }
+- break;
+- case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:
+- {
+- const google::protobuf::EnumValueDescriptor* vd = fd->default_value_enum();
+- vars["field_dv_ctype"] = FullNameToC(vd->type()->full_name(), vd->type()->file());
+- break;
+- }
+- default:
+- GOOGLE_LOG(FATAL) << "Unknown CPPTYPE";
+- break;
+- }
+- if (!already_defined)
+- printer->Print(vars, "$maybe_static$const $field_dv_ctype$ $lcclassname$__$lcname$__default_value$field_dv_ctype_suffix$ = $default_value$;\n");
+- }
+- }
++ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
++ nested_generators_[i]->GenerateMessageDescriptor(printer, gen_init);
++ }
+
+- if ( descriptor_->field_count() ) {
+- printer->Print(vars,
+- "static const ProtobufCFieldDescriptor $lcclassname$__field_descriptors[$n_fields$] =\n"
+- "{\n");
+- printer->Indent();
++ for (int i = 0; i < descriptor_->enum_type_count(); i++) {
++ enum_generators_[i]->GenerateEnumDescriptor(printer);
++ }
+
+- std::vector<const google::protobuf::FieldDescriptor*> sorted_fields;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+- sorted_fields.push_back(descriptor_->field(i));
+- }
+- qsort(&sorted_fields[0], sorted_fields.size(),
+- sizeof(const google::protobuf::FieldDescriptor*),
+- compare_pfields_by_number);
+- for (auto field : sorted_fields) {
+- field_generators_.get(field).GenerateDescriptorInitializer(printer);
++ const google::protobuf::FieldDescriptor* fd = descriptor_->field(i);
++ if (fd->has_default_value()) {
++ field_generators_.get(fd).GenerateDefaultValueImplementations(printer);
++ }
+ }
+- printer->Outdent();
+- printer->Print(vars, "};\n");
+
+- if (!optimize_code_size) {
+- std::vector<NameIndex> field_indices;
+- for (unsigned i = 0; i < descriptor_->field_count(); i++) {
+- field_indices.push_back({ .index = i, .name = sorted_fields[i]->name() });
++ for (int i = 0; i < descriptor_->field_count(); i++) {
++ const google::protobuf::FieldDescriptor* fd = descriptor_->field(i);
++ const ProtobufCFieldOptions opt = fd->options().GetExtension(pb_c_field);
++ if (fd->has_default_value()) {
++ bool already_defined = false;
++ vars["name"] = fd->name();
++ vars["lcname"] = CamelToLower(fd->name());
++ vars["maybe_static"] = "static ";
++ vars["field_dv_ctype_suffix"] = "";
++ vars["default_value"] = field_generators_.get(fd).GetDefaultValue();
++ switch (fd->cpp_type()) {
++ case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
++ vars["field_dv_ctype"] = "int32_t";
++ break;
++ case google::protobuf::FieldDescriptor::CPPTYPE_INT64:
++ vars["field_dv_ctype"] = "int64_t";
++ break;
++ case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:
++ vars["field_dv_ctype"] = "uint32_t";
++ break;
++ case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:
++ vars["field_dv_ctype"] = "uint64_t";
++ break;
++ case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
++ vars["field_dv_ctype"] = "float";
++ break;
++ case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
++ vars["field_dv_ctype"] = "double";
++ break;
++ case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:
++ vars["field_dv_ctype"] = "protobuf_c_boolean";
++ break;
++ case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:
++ // NOTE: not supported by protobuf
++ vars["maybe_static"] = "";
++ vars["field_dv_ctype"] = "{ ... }";
++ GOOGLE_LOG(FATAL) << "Messages can't have default values!";
++ break;
++ case google::protobuf::FieldDescriptor::CPPTYPE_STRING:
++ if (fd->type() == google::protobuf::FieldDescriptor::TYPE_BYTES || opt.string_as_bytes()) {
++ vars["field_dv_ctype"] = "ProtobufCBinaryData";
++ } else {
++ /* STRING type */
++ already_defined = true;
++ vars["maybe_static"] = "";
++ vars["field_dv_ctype"] = "char";
++ vars["field_dv_ctype_suffix"] = "[]";
++ }
++ break;
++ case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: {
++ const google::protobuf::EnumValueDescriptor* vd = fd->default_value_enum();
++ vars["field_dv_ctype"] = FullNameToC(vd->type()->full_name(), vd->type()->file());
++ break;
++ }
++ default:
++ GOOGLE_LOG(FATAL) << "Unknown CPPTYPE";
++ break;
++ }
++ if (!already_defined) {
++ printer->Print(vars, "$maybe_static$const $field_dv_ctype$ $lcclassname$__$lcname$__default_value$field_dv_ctype_suffix$ = $default_value$;\n");
++ }
+ }
+- qsort(&field_indices[0], field_indices.size(), sizeof(NameIndex),
+- compare_name_indices_by_name);
+- printer->Print(vars, "static const unsigned $lcclassname$__field_indices_by_name[] = {\n");
++ }
++
++ if (descriptor_->field_count()) {
++ printer->Print(vars,
++ "static const ProtobufCFieldDescriptor $lcclassname$__field_descriptors[$n_fields$] =\n"
++ "{\n");
++ printer->Indent();
++
++ std::vector<const google::protobuf::FieldDescriptor*> sorted_fields;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+- vars["index"] = SimpleItoa(field_indices[i].index);
+- vars["name"] = field_indices[i].name;
+- printer->Print(vars, " $index$, /* field[$index$] = $name$ */\n");
++ sorted_fields.push_back(descriptor_->field(i));
+ }
+- printer->Print("};\n");
+- }
++ qsort(&sorted_fields[0],
++ sorted_fields.size(),
++ sizeof(const google::protobuf::FieldDescriptor*),
++ compare_pfields_by_number);
++ for (auto field : sorted_fields) {
++ field_generators_.get(field).GenerateDescriptorInitializer(printer);
++ }
++ printer->Outdent();
++ printer->Print(vars, "};\n");
+
+- // create range initializers
+- std::vector<int> values;
+- for (int i = 0; i < descriptor_->field_count(); i++) {
+- values.push_back(sorted_fields[i]->number());
+- }
+- int n_ranges = WriteIntRanges(printer,
+- descriptor_->field_count(), &values[0],
+- vars["lcclassname"] + "__number_ranges");
++ if (!optimize_code_size) {
++ std::vector<NameIndex> field_indices;
++ for (unsigned i = 0; i < descriptor_->field_count(); i++) {
++ field_indices.push_back({ .index = i, .name = sorted_fields[i]->name() });
++ }
++ qsort(&field_indices[0],
++ field_indices.size(),
++ sizeof(NameIndex),
++ compare_name_indices_by_name);
++ printer->Print(vars, "static const unsigned $lcclassname$__field_indices_by_name[] = {\n");
++ for (int i = 0; i < descriptor_->field_count(); i++) {
++ vars["index"] = SimpleItoa(field_indices[i].index);
++ vars["name"] = field_indices[i].name;
++ printer->Print(vars, " $index$, /* field[$index$] = $name$ */\n");
++ }
++ printer->Print("};\n");
++ }
+
+- vars["n_ranges"] = SimpleItoa(n_ranges);
+- } else {
+- /* MS compiler can't handle arrays with zero size and empty
+- * initialization list. Furthermore it is an extension of GCC only but
+- * not a standard. */
+- vars["n_ranges"] = "0";
+- printer->Print(vars,
+- "#define $lcclassname$__field_descriptors NULL\n"
+- "#define $lcclassname$__field_indices_by_name NULL\n"
+- "#define $lcclassname$__number_ranges NULL\n");
++ // create range initializers
++ std::vector<int> values;
++ for (int i = 0; i < descriptor_->field_count(); i++) {
++ values.push_back(sorted_fields[i]->number());
+ }
++ int n_ranges = WriteIntRanges(printer,
++ descriptor_->field_count(),
++ &values[0],
++ vars["lcclassname"] + "__number_ranges");
++
++ vars["n_ranges"] = SimpleItoa(n_ranges);
++ } else {
++ /* MS compiler can't handle arrays with zero size and empty
++ * initialization list. Furthermore it is an extension of GCC only but
++ * not a standard. */
++ vars["n_ranges"] = "0";
++ printer->Print(vars,
++ "#define $lcclassname$__field_descriptors NULL\n"
++ "#define $lcclassname$__field_indices_by_name NULL\n"
++ "#define $lcclassname$__number_ranges NULL\n");
++ }
+
+ printer->Print(vars,
+- "const ProtobufCMessageDescriptor $lcclassname$__descriptor =\n"
+- "{\n"
+- " PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,\n");
++ "const ProtobufCMessageDescriptor $lcclassname$__descriptor =\n"
++ "{\n"
++ " PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,\n");
+ if (optimize_code_size) {
+ printer->Print(" NULL,NULL,NULL,NULL, /* CODE_SIZE */\n");
+ } else {
+ printer->Print(vars,
+- " \"$fullname$\",\n"
+- " \"$shortname$\",\n"
+- " \"$classname$\",\n"
+- " \"$packagename$\",\n");
++ " \"$fullname$\",\n"
++ " \"$shortname$\",\n"
++ " \"$classname$\",\n"
++ " \"$packagename$\",\n");
+ }
+ printer->Print(vars,
+- " sizeof($classname$),\n"
+- " $n_fields$,\n"
+- " $lcclassname$__field_descriptors,\n");
++ " sizeof($classname$),\n"
++ " $n_fields$,\n"
++ " $lcclassname$__field_descriptors,\n");
+ if (optimize_code_size) {
+ printer->Print(" NULL, /* CODE_SIZE */\n");
+ } else {
+- printer->Print(vars,
+- " $lcclassname$__field_indices_by_name,\n");
++ printer->Print(vars, " $lcclassname$__field_indices_by_name,\n");
+ }
+ printer->Print(vars,
+- " $n_ranges$,"
+- " $lcclassname$__number_ranges,\n");
++ " $n_ranges$,"
++ " $lcclassname$__number_ranges,\n");
+ if (gen_init) {
+- printer->Print(vars,
+- " (ProtobufCMessageInit) $lcclassname$__init,\n");
++ printer->Print(vars, " (ProtobufCMessageInit) $lcclassname$__init,\n");
+ } else {
+- printer->Print(vars,
+- " NULL, /* gen_init_helpers = false */\n");
++ printer->Print(vars, " NULL, /* gen_init_helpers = false */\n");
+ }
+ printer->Print(vars,
+- " NULL,NULL,NULL /* reserved[123] */\n"
+- "};\n");
++ " NULL,NULL,NULL /* reserved[123] */\n"
++ "};\n");
+ }
+
+ int MessageGenerator::GetOneofUnionOrder(const google::protobuf::FieldDescriptor* fd)
+
+From c59b146aee2d97091ca2adeecd3f2741cb7f0082 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 21:10:37 -0500
+Subject: [PATCH 08/11] compat: Use absl::string_view instead of
+ google::protobuf::internal::DescriptorStringView
+
+Even though google::protobuf::internal::DescriptorStringView is exposed
+in public protobuf headers, it's probably not a good idea to rely on an
+"internal" typedef.
+
+According to https://protobuf.dev/news/2024-10-02/#descriptor-apis:
+
+ v30 will update return types in descriptor (such as full_name) to be
+ absl::string_view.
+
+So `absl::string_view` is probably the right type to use here.
+---
+ protoc-gen-c/compat.h | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/protoc-gen-c/compat.h b/protoc-gen-c/compat.h
+index fe8041b5..a70cef34 100644
+--- a/protoc-gen-c/compat.h
++++ b/protoc-gen-c/compat.h
+@@ -37,12 +37,16 @@
+ # define GOOGLE_LOG ABSL_LOG
+ #endif
+
++#if GOOGLE_PROTOBUF_VERSION >= 6030000
++# include <absl/strings/string_view.h>
++#endif
++
+ namespace protobuf_c {
+
+ namespace compat {
+
+ #if GOOGLE_PROTOBUF_VERSION >= 6030000
+-typedef google::protobuf::internal::DescriptorStringView StringView;
++typedef absl::string_view StringView;
+ #else
+ typedef const std::string& StringView;
+ #endif
+
+From 9c56038fd9d3cc2552c297457d7a66efe5cbd2c7 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 21:37:30 -0500
+Subject: [PATCH 09/11] Makefile.am: Add compat.h to
+ protoc_gen_c_protoc_gen_c_SOURCES
+
+---
+ Makefile.am | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/Makefile.am b/Makefile.am
+index 77aa9d99..26d19f16 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -102,6 +102,7 @@ protoc_gen_c_protoc_gen_c_SOURCES = \
+ protoc-gen-c/c_service.h \
+ protoc-gen-c/c_string_field.cc \
+ protoc-gen-c/c_string_field.h \
++ protoc-gen-c/compat.h \
+ protobuf-c/protobuf-c.pb.cc \
+ protobuf-c/protobuf-c.pb.h \
+ protoc-gen-c/main.cc
+
+From 4ebd5cd8238d1f2ac6291b8c8925f34e16ce2123 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 21:38:07 -0500
+Subject: [PATCH 10/11] compat: Conditionalize the include of <string>
+
+It is only needed on older protobuf versions where absl::string_view is
+not being used.
+---
+ protoc-gen-c/compat.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/protoc-gen-c/compat.h b/protoc-gen-c/compat.h
+index a70cef34..f6ace7cb 100644
+--- a/protoc-gen-c/compat.h
++++ b/protoc-gen-c/compat.h
+@@ -28,8 +28,6 @@
+ #ifndef PROTOBUF_C_PROTOC_GEN_C_COMPAT_H__
+ #define PROTOBUF_C_PROTOC_GEN_C_COMPAT_H__
+
+-#include <string>
+-
+ #if GOOGLE_PROTOBUF_VERSION >= 4022000
+ # define GOOGLE_ARRAYSIZE ABSL_ARRAYSIZE
+ # define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
+@@ -39,6 +37,8 @@
+
+ #if GOOGLE_PROTOBUF_VERSION >= 6030000
+ # include <absl/strings/string_view.h>
++#else
++# include <string>
+ #endif
+
+ namespace protobuf_c {
+
+From 9a6b35e1e6956fb5cb044910448049b7a5339244 Mon Sep 17 00:00:00 2001
+From: Robert Edmonds <edmonds@users.noreply.github.com>
+Date: Sat, 8 Feb 2025 21:44:42 -0500
+Subject: [PATCH 11/11] Cater to Microsoft Visual C++
+
+Apparently MSVC doesn't support designated initializers for some reason.
+---
+ protoc-gen-c/c_enum.cc | 9 ++-------
+ protoc-gen-c/c_message.cc | 2 +-
+ 2 files changed, 3 insertions(+), 8 deletions(-)
+
+diff --git a/protoc-gen-c/c_enum.cc b/protoc-gen-c/c_enum.cc
+index c7839edd..1940ba9d 100644
+--- a/protoc-gen-c/c_enum.cc
++++ b/protoc-gen-c/c_enum.cc
+@@ -195,14 +195,9 @@ void EnumGenerator::GenerateEnumDescriptor(google::protobuf::io::Printer* printe
+ // Sort by name and value, dropping duplicate values if they appear later.
+ // TODO: use a c++ paradigm for this!
+ std::vector<ValueIndex> value_index;
+- for (unsigned j = 0; j < descriptor_->value_count(); j++) {
++ for (int j = 0; j < descriptor_->value_count(); j++) {
+ const google::protobuf::EnumValueDescriptor *vd = descriptor_->value(j);
+- value_index.push_back({
+- .value = vd->number(),
+- .index = j,
+- .final_index = 0,
+- .name = vd->name(),
+- });
++ value_index.push_back({ vd->number(), (unsigned)j, 0, vd->name() });
+ }
+ qsort(&value_index[0],
+ value_index.size(),
+diff --git a/protoc-gen-c/c_message.cc b/protoc-gen-c/c_message.cc
+index 2a3b2a2f..94889179 100644
+--- a/protoc-gen-c/c_message.cc
++++ b/protoc-gen-c/c_message.cc
+@@ -581,7 +581,7 @@ GenerateMessageDescriptor(google::protobuf::io::Printer* printer, bool gen_init)
+ if (!optimize_code_size) {
+ std::vector<NameIndex> field_indices;
+ for (unsigned i = 0; i < descriptor_->field_count(); i++) {
+- field_indices.push_back({ .index = i, .name = sorted_fields[i]->name() });
++ field_indices.push_back({ i, sorted_fields[i]->name() });
+ }
+ qsort(&field_indices[0],
+ field_indices.size(),
diff --git a/meta-oe/recipes-devtools/protobuf/protobuf-c_1.5.0.bb b/meta-oe/recipes-devtools/protobuf/protobuf-c_1.5.1.bb
similarity index 88%
rename from meta-oe/recipes-devtools/protobuf/protobuf-c_1.5.0.bb
rename to meta-oe/recipes-devtools/protobuf/protobuf-c_1.5.1.bb
index 82aaf1bae6..7640797771 100644
--- a/meta-oe/recipes-devtools/protobuf/protobuf-c_1.5.0.bb
+++ b/meta-oe/recipes-devtools/protobuf/protobuf-c_1.5.1.bb
@@ -8,14 +8,16 @@ has been split out into the protobuf-c-rpc project."
HOMEPAGE = "https://github.com/protobuf-c/protobuf-c"
SECTION = "console/tools"
LICENSE = "BSD-2-Clause"
-LIC_FILES_CHKSUM = "file://LICENSE;md5=d11077c6a2b5d2e64b9f32b61a9b78ba"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=bd8de4f63e06b1ccc06e9f8dc5b1aa97"
DEPENDS = "protobuf-native protobuf"
-SRC_URI = "git://github.com/protobuf-c/protobuf-c.git;branch=master;protocol=https"
+SRC_URI = "git://github.com/protobuf-c/protobuf-c.git;branch=master;protocol=https \
+ file://protobuf-30.patch \
+"
SRC_URI:append:class-native = " file://0001-Makefile.am-do-not-compile-the-code-which-was-genera.patch"
-SRCREV = "8c201f6e47a53feaab773922a743091eb6c8972a"
+SRCREV = "185beed28e65494be7505b30c1afeaf199e19b23"
S = "${WORKDIR}/git"
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [oe] [meta-oe][PATCH v2] protobuf: 4.25.5 -> 4.30.0
2025-03-11 23:31 ` [oe] " Khem Raj
2025-03-12 7:54 ` [meta-oe][PATCH] protobuf-c: 1.5.0 -> 1.5.1 Hongxu Jia
@ 2025-03-12 17:14 ` Khem Raj
2025-03-13 2:51 ` hongxu
1 sibling, 1 reply; 5+ messages in thread
From: Khem Raj @ 2025-03-12 17:14 UTC (permalink / raw)
To: hongxu.jia; +Cc: openembedded-devel
ptest build fails see -
https://autobuilder.yoctoproject.org/valkyrie/#/builders/81/builds/448/steps/14/logs/stdio
On Tue, Mar 11, 2025 at 4:31 PM Khem Raj <raj.khem@gmail.com> wrote:
>
> This causes protobuf-c to not build see
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/81/builds/446/steps/14/logs/stdio
>
> On Tue, Mar 11, 2025 at 1:41 AM hongxu via lists.openembedded.org
> <hongxu.jia=eng.windriver.com@lists.openembedded.org> wrote:
> >
> > Refresh local patches
> > - 0001-Fix-build-on-mips-clang.patch
> > - 0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
> >
> > Drop the fix for gold linker build
> >
> > Changelog:
> > https://github.com/protocolbuffers/protobuf/releases/tag/v30.0
> >
> > Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> > ---
> > .../0001-Fix-build-on-mips-clang.patch | 26 ++++++++-----
> > ...e-respect-CXX-LDFLAGS-variables-fix-.patch | 37 ++++++-------------
> > ...{protobuf_4.25.5.bb => protobuf_4.30.0.bb} | 4 +-
> > 3 files changed, 31 insertions(+), 36 deletions(-)
> > rename meta-oe/recipes-devtools/protobuf/{protobuf_4.25.5.bb => protobuf_4.30.0.bb} (98%)
> >
> > diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch
> > index 9f6116c4c4..6db22c26d3 100644
> > --- a/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch
> > +++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-Fix-build-on-mips-clang.patch
> > @@ -1,6 +1,6 @@
> > -From 08e46feb6553af670754e65d94c3bb6fcd4e0cf9 Mon Sep 17 00:00:00 2001
> > +From fd5a966a6385165506a1b84298465cbb9f44222d Mon Sep 17 00:00:00 2001
> > From: Khem Raj <raj.khem@gmail.com>
> > -Date: Sun, 31 Oct 2021 23:39:44 -0700
> > +Date: Mon, 10 Mar 2025 19:59:19 -0700
> > Subject: [PATCH] Fix build on mips/clang
> >
> > clang13 crashes on mips, until its fixed upstream disable tailcall on
> > @@ -10,17 +10,25 @@ https://bugs.llvm.org/show_bug.cgi?id=52367
> >
> > Upstream-Status: Inappropriate [Clang workaround]
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > +
> > +Rebase to v4.30.0
> > +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> > ---
> > - src/google/protobuf/port_def.inc | 2 +-
> > - 1 file changed, 1 insertion(+), 1 deletion(-)
> > + src/google/protobuf/port_def.inc | 1 +
> > + 1 file changed, 1 insertion(+)
> >
> > +diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
> > +index 35f49afb4..e9597af0d 100644
> > --- a/src/google/protobuf/port_def.inc
> > +++ b/src/google/protobuf/port_def.inc
> > -@@ -255,6 +255,7 @@
> > +@@ -222,6 +222,7 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
> > #error PROTOBUF_TAILCALL was previously defined
> > #endif
> > - #if __has_cpp_attribute(clang::musttail) && !defined(__arm__) && \
> > + #if ABSL_HAVE_CPP_ATTRIBUTE(clang::musttail) && !defined(__arm__) && \
> > + !defined(__mips__) && \
> > - !defined(_ARCH_PPC) && !defined(__wasm__) && \
> > - !(defined(_MSC_VER) && defined(_M_IX86)) && \
> > - !(defined(__NDK_MAJOR__) && __NDK_MAJOR <= 24)
> > + !defined(_ARCH_PPC) && !defined(__wasm__) && \
> > + !(defined(_MSC_VER) && defined(_M_IX86)) && !defined(__i386__)
> > + // Compilation fails on ARM32: b/195943306
> > +--
> > +2.25.1
> > +
> > diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
> > index 7c4bf260eb..5457d0d6bc 100644
> > --- a/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
> > +++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch
> > @@ -1,36 +1,23 @@
> > -From e3fa241637ab5a7fa78c0d474802134cff75f91e Mon Sep 17 00:00:00 2001
> > +From 88d4e5afb2c3b56933c529216cd8b733e10a5b7b Mon Sep 17 00:00:00 2001
> > From: Martin Jansa <Martin.Jansa@gmail.com>
> > -Date: Fri, 28 Jun 2019 13:50:52 +0000
> > -Subject: [PATCH] examples/Makefile: respect CXX,LDFLAGS variables, fix build
> > - with gold
> > +Date: Tue, 11 Mar 2025 16:35:39 +0800
> > +Subject: [PATCH] examples/Makefile: respect CXX,LDFLAGS variables
> >
> > * move pkg-config call to separate variable, so that the final version
> > of the whole command so it's shown in log.do_compile_ptest_base
> > -* add ../src/google/protobuf/.libs/timestamp.pb.o when linking
> > - add_person_cpp otherwise it fails to link with gold:
> > - i686-oe-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=core2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
> > - /tmp/cccjSJQs.o:addressbook.pb.cc:scc_info_Person_addressbook_2eproto: error: undefined reference to 'scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto'
> > - /tmp/cccjSJQs.o:addressbook.pb.cc:descriptor_table_addressbook_2eproto_deps: error: undefined reference to 'descriptor_table_google_2fprotobuf_2ftimestamp_2eproto'
> > - collect2: error: ld returned 1 exit status
> > - Makefile:43: recipe for target 'add_person_cpp' failed
> > -
> > -* and the same with list_people_cpp this time with pkg-config already through the variable:
> > - i686-oe-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=core2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -pthread -Icore2-32-oe-linux/protobuf/3.8.0-r0/git/src -Lcore2-32-oe-linux/protobuf/3.8.0-r0/git/src/.libs -Lcore2-32-oe-linux/protobuf/3.8.0-r0/recipe-sysroot/usr/lib -lprotobuf list_people.cc addressbook.pb.cc -o list_people_cpp
> > - /tmp/ccpaI5Su.o:addressbook.pb.cc:scc_info_Person_addressbook_2eproto: error: undefined reference to 'scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto'
> > - /tmp/ccpaI5Su.o:addressbook.pb.cc:descriptor_table_addressbook_2eproto_deps: error: undefined reference to 'descriptor_table_google_2fprotobuf_2ftimestamp_2eproto'
> > - collect2: error: ld returned 1 exit status
> > - Makefile:49: recipe for target 'list_people_cpp' failed
> >
> > Upstream-Status: Pending
> > Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> > Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
> >
> > +Rebase to v4.30.0
> > +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> > ---
> > examples/Makefile | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/examples/Makefile b/examples/Makefile
> > -index ef7a4ef58..7206e14e1 100644
> > +index 5290fdb03f..b695b03707 100644
> > --- a/examples/Makefile
> > +++ b/examples/Makefile
> > @@ -2,6 +2,8 @@
> > @@ -42,20 +29,20 @@ index ef7a4ef58..7206e14e1 100644
> > all: cpp java python
> >
> > cpp: add_person_cpp list_people_cpp
> > -@@ -41,11 +43,11 @@ protoc_middleman_dart: addressbook.proto
> > +@@ -46,11 +48,11 @@ protoc_middleman_ruby: addressbook.proto
> >
> > add_person_cpp: add_person.cc protoc_middleman
> > pkg-config --cflags protobuf # fails if protobuf is not installed
> > -- c++ -std=c++14 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
> > -+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp #$(CXX) -std=c++17 $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp
> > +- c++ add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
> > ++ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PROTOBUF) add_person.cc addressbook.pb.cc -o add_person_cpp
> >
> > list_people_cpp: list_people.cc protoc_middleman
> > pkg-config --cflags protobuf # fails if protobuf is not installed
> > -- c++ -std=c++14 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
> > -+ $(CXX) $(CXXFLAGS) $(LDFLAGS) ../src/google/protobuf/.libs/timestamp.pb.o $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp #$(CXX) -std=c++17 $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp
> > +- c++ list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
> > ++ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PROTOBUF) list_people.cc addressbook.pb.cc -o list_people_cpp
> >
> > add_person_dart: add_person.dart protoc_middleman_dart
> >
> > ---
> > +--
> > 2.34.1
> >
> > diff --git a/meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb b/meta-oe/recipes-devtools/protobuf/protobuf_4.30.0.bb
> > similarity index 98%
> > rename from meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb
> > rename to meta-oe/recipes-devtools/protobuf/protobuf_4.30.0.bb
> > index a470a7c643..f899a1dc07 100644
> > --- a/meta-oe/recipes-devtools/protobuf/protobuf_4.25.5.bb
> > +++ b/meta-oe/recipes-devtools/protobuf/protobuf_4.30.0.bb
> > @@ -14,9 +14,9 @@ LIC_FILES_CHKSUM = " \
> > DEPENDS = "zlib abseil-cpp jsoncpp"
> > DEPENDS:append:class-target = " protobuf-native"
> >
> > -SRCREV = "9d0ec0f92b5b5fdeeda11f9dcecc1872ff378014"
> > +SRCREV = "d295af5c3002c08e1bfd9d7f9e175d0a4d015f1e"
> >
> > -SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=25.x;protocol=https \
> > +SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=30.x;protocol=https \
> > file://run-ptest \
> > file://0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch \
> > "
> > --
> > 2.34.1
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#115849): https://lists.openembedded.org/g/openembedded-devel/message/115849
> > Mute This Topic: https://lists.openembedded.org/mt/111636359/1997914
> > Group Owner: openembedded-devel+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [meta-oe][PATCH v2] protobuf: 4.25.5 -> 4.30.0
2025-03-12 17:14 ` [oe] [meta-oe][PATCH v2] protobuf: 4.25.5 -> 4.30.0 Khem Raj
@ 2025-03-13 2:51 ` hongxu
0 siblings, 0 replies; 5+ messages in thread
From: hongxu @ 2025-03-13 2:51 UTC (permalink / raw)
To: openembedded-devel
[-- Attachment #1: Type: text/plain, Size: 40 bytes --]
Got it, I am working on it
//Hongxu
[-- Attachment #2: Type: text/html, Size: 79 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-13 2:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11 8:41 [meta-oe][PATCH v2] protobuf: 4.25.5 -> 4.30.0 Hongxu Jia
2025-03-11 23:31 ` [oe] " Khem Raj
2025-03-12 7:54 ` [meta-oe][PATCH] protobuf-c: 1.5.0 -> 1.5.1 Hongxu Jia
2025-03-12 17:14 ` [oe] [meta-oe][PATCH v2] protobuf: 4.25.5 -> 4.30.0 Khem Raj
2025-03-13 2:51 ` hongxu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.