Fix undefined symbol errors with Ruby 2.7+#2
Open
aashutosh-sahni wants to merge 2 commits intomasterfrom
Open
Conversation
Rename and/or/xor/difference to bitset_and/bitset_or/bitset_xor/bitset_difference.
These names are ISO C95 alternative operator tokens (<iso646.h>), and Ruby 2.7+
headers pull in that header, causing the preprocessor to replace the function
names with operators. Result: 'undefined symbol: and' at runtime.
Ruby method aliases ("and", "or", "xor") are unchanged -- only the internal
C function names and their pointer references are renamed.
inline alone does not guarantee symbol emission in C99 -- the compiler may inline at call sites and omit the standalone symbol. When the code takes function pointers (&bitset_or etc), the linker fails with 'undefined symbol: bitset_or'. Change to static to ensure symbols are always available in the translation unit.
|
I assume we checked upstream for ruby 2.7 compatibility changes? |
Collaborator
Author
|
Yes — upstream is |
richkettle
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch has been tagged as
v1.2.2and is already in use viatag: "v1.2.2"in the bookingbug app Gemfile. Do not merge to master — it is not needed and could affect other environments that depend on the default branch.This PR remains open for documentation/review purposes only.
Summary
and,or,xor,differencetobitset_and,bitset_or,bitset_xor,bitset_differenceinlinetostatic(C99inlinedoesn't guarantee symbol emission; taking function pointers fails at link time)&and→&bitset_and, etc.)"and","or","xor") are unchanged — no API changeWhy
andandorare ISO C95 alternative operator tokens defined in<iso646.h>as#define and &&/#define or ||. Ruby 2.7+ headers include this header, so the preprocessor replaces the function names with operators during compilation. The.socompiles but the symbols are mangled/missing, resulting in:Additionally, C99
inlinewithoutstaticorexterndoes not guarantee the compiler emits a standalone symbol. When function pointers are taken (&bitset_or), the linker fails withundefined symbol: bitset_or. Usingstaticensures symbols are always emitted.Tagged as v1.2.2
Usage in bookingbug Gemfile:
Test plan
db:migratepasses🤖 Generated with Claude Code