ext: hide statically-linked symbols to prevent llhttp collision#1000
ext: hide statically-linked symbols to prevent llhttp collision#1000stanhu wants to merge 1 commit into
Conversation
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>
BeforeAfter: |
|
@carlosmn Could you look at this? |
|
@ethomson We ran into a significant regression after updating to Rugged v1.9 when the
|
|
That sounds like a problem, indeed. Sounds like something that libgit2 should be addressing. I won't be able to take a look for a few days, unfortunately. |
|
@ethomson any change this could be reviewed? |
|
It does seem like something that libgit2 should be doing itself. If you build the shared object, you don't get these symbols exported, so I went looking and we might just want to move the line at https://github.com/libgit2/libgit2/blob/44c05e5d12f2b8b86b9730bb50f27daf74143782/cmake/DefaultCFlags.cmake#L116 to be outside of that IF. Testing locally it seems to do the trick. It looks like |
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: