Skip to content

ext: hide statically-linked symbols to prevent llhttp collision#1000

Open
stanhu wants to merge 1 commit intolibgit2:masterfrom
stanhu:sh-hide-symbols
Open

ext: hide statically-linked symbols to prevent llhttp collision#1000
stanhu wants to merge 1 commit intolibgit2:masterfrom
stanhu:sh-hide-symbols

Conversation

@stanhu
Copy link
Copy Markdown
Contributor

@stanhu stanhu commented Apr 29, 2026

libgit2 >= 1.8 bundles llhttp as its default HTTP parser. Without visibility controls, all 119 llhttp_* symbols are exported from rugged.so and collide with the llhttp-ffi gem (used by the http gem) when both are loaded in the same process.

Fix by:

  • Passing -DCMAKE_C_VISIBILITY_PRESET=hidden to cmake so libgit2 and its bundled deps (including llhttp) are compiled with -fvisibility=hidden on all platforms.
  • Appending -Wl,--exclude-libs,ALL to $LDFLAGS on Linux as a belt-and-suspenders linker-level guard (macOS ld does not support this flag, but the cmake flag covers it there).

libgit2 >= 1.8 bundles llhttp as its default HTTP parser. Without
visibility controls, all 119 llhttp_* symbols are exported from
rugged.so and collide with the llhttp-ffi gem (used by the http gem)
when both are loaded in the same process.

Fix by:
- Passing -DCMAKE_C_VISIBILITY_PRESET=hidden to cmake so libgit2 and
  its bundled deps (including llhttp) are compiled with
  -fvisibility=hidden on all platforms.
- Appending -Wl,--exclude-libs,ALL to $LDFLAGS on Linux as a
  belt-and-suspenders linker-level guard (macOS ld does not support
  this flag, but the cmake flag covers it there).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@stanhu stanhu marked this pull request as draft April 29, 2026 15:15
@stanhu stanhu marked this pull request as ready for review April 29, 2026 15:35
@stanhu
Copy link
Copy Markdown
Contributor Author

stanhu commented Apr 29, 2026

Before

$ objdump -T tmp/x86_64-linux/stage/lib/rugged/rugged.so | grep llhttp | head
000000000010bb30 g    DF .text  0000000000000010  Base        llhttp__internal__c_test_flags
000000000010b8e0 g    DF .text  000000000000014b  Base        llhttp__after_headers_complete
000000000010bc90 g    DF .text  0000000000000009  Base        llhttp__internal__c_load_header_state
000000000010b400 g    DF .text  000000000000004e  Base        llhttp__on_version
000000000010b170 g    DF .text  000000000000001a  Base        llhttp_set_lenient_transfer_encoding
000000000010b7c0 g    DF .text  0000000000000072  Base        llhttp__debug
000000000010b630 g    DF .text  0000000000000023  Base        llhttp__on_chunk_header
000000000010bef0 g    DF .text  000000000000000b  Base        llhttp__internal__c_update_type
000000000010a660 g    DF .text  0000000000000009  Base        llhttp_get_http_major
000000000010aac0 g    DF .text  0000000000000308  Base        llhttp_method_name

After:

$ objdump -T tmp/x86_64-linux/stage/lib/rugged/rugged.so | grep llhttp | head
$

@stanhu
Copy link
Copy Markdown
Contributor Author

stanhu commented Apr 29, 2026

@carlosmn Could you look at this?

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.

1 participant