mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
This change refactors the generated `upb_MiniTableExtension` variables to be `const upb_MiniTableExtension*` instead of `const upb_MiniTableExtension`. The linker array now stores pointers to these extension objects. This fixes an issue related to position-independent executables on GCC (see the attached bug for more information). We also unconditionally retain all extensions for the generated registry when compiling under GCC. This effectively disables tree shaking of extensions when compiling with GCC, but fixes a GCC-only compiler error. There may be a way to re-enable linker GC with GCC at some point, but the priority for the moment is just fixing the issue. A new test is added to verify registry loading with no linked extensions. Fixes: https://github.com/protocolbuffers/protobuf/issues/26385 PiperOrigin-RevId: 906412231
15 lines
471 B
Protocol Buffer
15 lines
471 B
Protocol Buffer
edition = "2024";
|
|
|
|
package upb_test_empty_registry;
|
|
|
|
// A message that is in the same file as the unused extension.
|
|
message EmptyRegistryTestMessage {
|
|
extensions 1 to max;
|
|
}
|
|
|
|
// An extension that we will *not* reference. The existence of this extension
|
|
// will cause us to emit the code to register all extensions, but since this
|
|
// extension is never referenced, that list of extensions will be empty.
|
|
extend EmptyRegistryTestMessage {
|
|
int32 unused_extension = 1;
|
|
}
|