Skip to content

Commit 05c6861

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Remove upb_ExtensionRegistry_AddAllLinkedExtensions API.
This is now an implementation detail of the public GeneratedRegistry. PiperOrigin-RevId: 827277782
1 parent 2e61833 commit 05c6861

30 files changed

+895
-174
lines changed

.github/workflows/test_upb.yml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
config:
3131
- { name: "Fastbuild" }
3232
- { name: "Optimized", flags: "-c opt", continuous-only: true }
33+
- { name: "GCC Optimized", flags: "-c opt --force_pic --java_runtime_version=remotejdk_11 --copt=\"-Wno-error=maybe-uninitialized\"", image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:8.0.1-12.2-12e21b8dda91028bc14212a3ab582c7c4d149fac" }
34+
- { name: "GCC Static", flags: "-c opt --dynamic_mode=off --java_runtime_version=remotejdk_11 --copt=\"-Wno-error=maybe-uninitialized\"", image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:8.0.1-12.2-12e21b8dda91028bc14212a3ab582c7c4d149fac", continuous-only: true }
3335
- { name: "ASAN", flags: "--config=asan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/...", runner: ubuntu-22-4core }
3436
- { name: "UBSAN", flags: "--config=ubsan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/... -//lua/...", continuous-only: true }
3537
- { name: "32-bit", flags: "--copt=-m32 --linkopt=-m32", exclude-targets: "-//benchmarks:benchmark -//python/..." }
@@ -49,33 +51,12 @@ jobs:
4951
if: ${{ !matrix.config.continuous-only || inputs.continuous-run }}
5052
uses: protocolbuffers/protobuf-ci/bazel-docker@v5
5153
with:
52-
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize:${{ matrix.config.bazel_version || '8.0.1' }}-12e21b8dda91028bc14212a3ab582c7c4d149fac
54+
image: ${{ matrix.config.image || 'us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize:8.0.1-12e21b8dda91028bc14212a3ab582c7c4d149fac' }}
5355
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
5456
bazel-cache: upb-bazel
5557
bazel: test //bazel/... //benchmarks/... //lua/... //python/... //upb/... //upb_generator/... ${{ matrix.config.flags }}
5658
exclude-targets: ${{ matrix.config.exclude-targets }}
5759

58-
linux-gcc:
59-
strategy:
60-
fail-fast: false # Don't cancel all jobs if one fails.
61-
name: GCC Optimized
62-
runs-on: ubuntu-latest
63-
steps:
64-
- name: Checkout pending changes
65-
uses: protocolbuffers/protobuf-ci/checkout@v5
66-
with:
67-
ref: ${{ inputs.safe-checkout }}
68-
- name: Run tests
69-
uses: protocolbuffers/protobuf-ci/bazel-docker@v5
70-
with:
71-
image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:8.0.1-12.2-12e21b8dda91028bc14212a3ab582c7c4d149fac"
72-
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
73-
bazel-cache: "upb-bazel-gcc"
74-
bazel: >-
75-
test -c opt
76-
--copt="-Wno-error=maybe-uninitialized" --java_runtime_version=remotejdk_11
77-
//bazel/... //benchmarks/... //lua/... //python/... //upb/... //upb_generator/...
78-
7960
windows:
8061
strategy:
8162
fail-fast: false # Don't cancel all jobs if one fails.

cmake/installed_include_golden.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,14 @@ upb/message/value.h
185185
upb/mini_descriptor/build_enum.h
186186
upb/mini_descriptor/decode.h
187187
upb/mini_descriptor/link.h
188+
upb/mini_table/compat.h
188189
upb/mini_table/debug_string.h
189190
upb/mini_table/enum.h
190191
upb/mini_table/extension.h
191192
upb/mini_table/extension_registry.h
192193
upb/mini_table/field.h
193194
upb/mini_table/file.h
195+
upb/mini_table/generated_registry.h
194196
upb/mini_table/message.h
195197
upb/mini_table/sub.h
196198
upb/port/atomic.h

hpb/extension.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "hpb/ptr.h"
2222
#include "upb/message/accessors.h"
2323
#include "upb/mini_table/extension_registry.h"
24+
#include "upb/mini_table/generated_registry.h"
2425

2526
namespace hpb {
2627
// upb has a notion of an ExtensionRegistry. We expect most callers to use
@@ -69,14 +70,17 @@ class ExtensionRegistry {
6970
friend upb_ExtensionRegistry* ::hpb::internal::GetUpbExtensions(
7071
const ExtensionRegistry& extension_registry);
7172
upb_ExtensionRegistry* registry_;
73+
explicit ExtensionRegistry(upb_ExtensionRegistry* registry)
74+
: registry_(registry) {}
7275
#endif
7376
// TODO: b/379100963 - Introduce ShutdownHpbLibrary
7477
static const ExtensionRegistry* NewGeneratedRegistry() {
7578
#if HPB_INTERNAL_BACKEND == HPB_INTERNAL_BACKEND_UPB
76-
static hpb::Arena* global_arena = new hpb::Arena();
77-
ExtensionRegistry* registry = new ExtensionRegistry(*global_arena);
78-
upb_ExtensionRegistry_AddAllLinkedExtensions(registry->registry_);
79-
return registry;
79+
static const upb_GeneratedRegistryRef* registry_ref =
80+
upb_GeneratedRegistry_Load();
81+
// Const cast is safe because we're returning a const wrapper.
82+
return new ExtensionRegistry(const_cast<upb_ExtensionRegistry*>(
83+
upb_GeneratedRegistry_Get(registry_ref)));
8084
#elif HPB_INTERNAL_BACKEND == HPB_INTERNAL_BACKEND_CPP
8185
ExtensionRegistry* registry = new ExtensionRegistry();
8286
return registry;

pkg/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ cc_dist_library(
249249
"//upb/json",
250250
"//upb/message:compare",
251251
"//upb/message:copy",
252+
"//upb/mini_table:compat",
252253
"//upb/mini_table:debug_string",
253254
"//upb/text",
254255
"//upb/text:debug",

upb/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ cc_library(
9898
"//upb/message:internal",
9999
"//upb/mini_descriptor",
100100
"//upb/mini_table",
101+
"//upb/mini_table:internal",
101102
"//upb/wire",
102103
] + select({
103104
":fasttable_enabled_setting": [
@@ -308,9 +309,13 @@ filegroup(
308309
filegroup(
309310
name = "test_srcs",
310311
srcs = [
312+
"//upb/hash:test_srcs",
311313
"//upb/json:test_srcs",
314+
"//upb/lex:test_srcs",
312315
"//upb/mem:test_srcs",
313316
"//upb/message:test_srcs",
317+
"//upb/mini_descriptor:test_srcs",
318+
"//upb/mini_table:test_srcs",
314319
"//upb/test:test_srcs",
315320
"//upb/util:test_srcs",
316321
"//upb/wire:test_srcs",

upb/generated_code_support.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "upb/mini_table/extension_registry.h"
3737
#include "upb/mini_table/field.h"
3838
#include "upb/mini_table/file.h"
39+
#include "upb/mini_table/internal/generated_registry.h"
3940
#include "upb/mini_table/message.h"
4041
#include "upb/mini_table/sub.h"
4142
#include "upb/wire/decode.h"

upb/hash/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ filegroup(
6565
"**/*test.cc",
6666
],
6767
),
68-
visibility = ["//pkg:__pkg__"],
68+
visibility = ["//upb:__pkg__"],
6969
)

upb/lex/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ filegroup(
7272
"**/*test.cc",
7373
],
7474
),
75-
visibility = ["//pkg:__pkg__"],
75+
visibility = ["//upb:__pkg__"],
7676
)

upb/mini_descriptor/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@ filegroup(
105105
"**/*test.cc",
106106
],
107107
),
108-
visibility = ["//pkg:__pkg__"],
108+
visibility = ["//upb:__pkg__"],
109109
)

upb/mini_table/BUILD

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ cc_library(
2828
name = "mini_table",
2929
srcs = [
3030
"extension_registry.c",
31+
"generated_registry.c",
3132
"message.c",
3233
],
3334
hdrs = [
@@ -36,6 +37,7 @@ cc_library(
3637
"extension_registry.h",
3738
"field.h",
3839
"file.h",
40+
"generated_registry.h",
3941
"message.h",
4042
"sub.h",
4143
],
@@ -84,6 +86,7 @@ cc_library(
8486
"internal/extension.h",
8587
"internal/field.h",
8688
"internal/file.h",
89+
"internal/generated_registry.h",
8790
"internal/message.h",
8891
"internal/size_log2.h",
8992
"internal/sub.h",
@@ -92,7 +95,6 @@ cc_library(
9295
visibility = ["//visibility:public"],
9396
deps = [
9497
"//upb/base",
95-
"//upb/hash",
9698
"//upb/mem",
9799
"//upb/message:types",
98100
"//upb/port",
@@ -131,6 +133,21 @@ cc_test(
131133
],
132134
)
133135

136+
cc_test(
137+
name = "generated_registry_test",
138+
srcs = ["generated_registry_test.cc"],
139+
deps = [
140+
":mini_table",
141+
"//src/google/protobuf:descriptor_upb_minitable_proto",
142+
"//upb/test:custom_options_upb_minitable_proto",
143+
"//upb/test:editions_test_upb_minitable_proto",
144+
"//upb/test:test_multiple_files_upb_minitable_proto",
145+
"@abseil-cpp//absl/synchronization",
146+
"@googletest//:gtest",
147+
"@googletest//:gtest_main",
148+
],
149+
)
150+
134151
proto_library(
135152
name = "message_benchmark_proto",
136153
testonly = 1,

0 commit comments

Comments
 (0)