Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Always export the RBX version number #2302

merged 1 commit into from Apr 22, 2013


None yet
3 participants

vmg commented Apr 21, 2013

Alright, this is not pretty, so excuse me in advance for the mess:

As you probably know, very bad things happen if you're working with 2 different C extensions that re-use small snippets of C code between them (e.g. a hash table implementation, an array implementation, a small library, and so on). As the two C extensions get loaded dynamically into the same memory space, their symbols table collide. If they are not using the same version of the shared code, one of the C extensions will break.

The only way to ensure this is to make sure that no other symbols besides the entry point are exported from the C extension, which is rather tricky to do in practice (it involves manually hiding every single function that is not set to static with visibility attributes).

Another way to accomplish this is the "shotgun" approach of hiding every single symbol in the C extension besides the Init_ entry point by linking with -Fvisibility=hidden or with -Bsymbol. This works very well in practice for MRI, but Rubinius fails to load C extensions linked like this because it's looking for the __X_rubinius_version entry, which is now hidden at link time.

By enforcing a default visibility attribute on the Rubinius version, we make sure that it always gets exported and C extensions never fail to load, regardless of how they were linked.


dbussink commented Apr 22, 2013

Ah, interesting :). Sounds like this shouldn't be a problem to merge then.

@dbussink dbussink added a commit that referenced this pull request Apr 22, 2013

@dbussink dbussink Merge pull request #2302 from vmg/do-not-clobber
Always export the RBX version number

@dbussink dbussink merged commit 5ad811e into rubinius:master Apr 22, 2013

1 check failed

default The Travis build failed

brianmario commented Apr 22, 2013


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment