New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate native gems with -fvisibility=hidden
#6541
Conversation
25005a9
to
b40f120
Compare
I seem to recall a few gems that compile vendored code, then use ffi to access it. Will they be affected by this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely not an expert here, but making things private by default makes sense to me!
@MSP-Greg This is just the boilerplate code created by |
@deivid-rodriguez @casperisfine
Duh. This isn't mkmf. Sorry, not enough coffee yet... |
b40f120
to
075391e
Compare
bundler/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt
Outdated
Show resolved
Hide resolved
I recently ran into very nasty issues with dynamic symbols clashing between two native gems. I believe the overwhelming majority of native gems don't want to export their symbols, so hidding them by default would make sense to me.
Head branch was pushed to by a user without write access
075391e
to
449624a
Compare
To be fair, I think we should make this change in mkmf, we'll probably bring this up on ruby-lang at some point, but I thought bundler's templates was a good start. |
# Makes all symbols private by default to avoid unintended conflict | ||
# with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED | ||
# selectively, or entirely remove this flag. | ||
$CFLAGS << " -fvisibility=hidden " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course this option is compiler dependent.
Should be append_cflags("-fvisibility=hidden")
.
Partly reverted rubocop rule at GH-6541
Generate native gems with `-fvisibility=hidden` (cherry picked from commit 7305d11)
I recently ran into very nasty issues with dynamic symbols clashing between two native gems.
I believe the overwhelming majority of native gems don't want to export their symbols, so hiding them by default would make sense to me.