Skip to content

Fixed two GCC-only issues around upb's generated extension registry.#27042

Draft
copybara-service[bot] wants to merge 1 commit intomainfrom
test_904021133
Draft

Fixed two GCC-only issues around upb's generated extension registry.#27042
copybara-service[bot] wants to merge 1 commit intomainfrom
test_904021133

Conversation

@copybara-service
Copy link
Copy Markdown

@copybara-service copybara-service Bot commented Apr 22, 2026

Fixed two GCC-only issues around upb's generated extension registry.

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: #26385

@copybara-service copybara-service Bot changed the title Internal change Fixed linker array sentinel on GCC, and added a test. Apr 22, 2026
@copybara-service copybara-service Bot force-pushed the test_904021133 branch 3 times, most recently from 01da5b4 to 1024535 Compare April 24, 2026 21:30
@copybara-service copybara-service Bot changed the title Fixed linker array sentinel on GCC, and added a test. Fixed two GCC-only issues around upb's generated extension registry. Apr 24, 2026
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: #26385
PiperOrigin-RevId: 904021133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

protobuf 34 upb compile and test failures with gcc

1 participant