Skip to content

Commit

Permalink
Generate native gems with -fvisibility=hidden
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
byroot committed Mar 24, 2023
1 parent 3586d71 commit b40f120
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

require "mkmf"

$CFLAGS << " -fvisibility=hidden "

create_makefile(<%= config[:makefile_path].inspect %>)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

VALUE rb_m<%= config[:constant_array].join %>;

void
RUBY_FUNC_EXPORTED void
Init_<%= config[:underscored_name] %>(void)
{
rb_m<%= config[:constant_array].join %> = rb_define_module(<%= config[:constant_name].inspect %>);
Expand Down
4 changes: 4 additions & 0 deletions bundler/lib/bundler/templates/newgem/rubocop.yml.tt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ Style/StringLiteralsInInterpolation:
Enabled: true
EnforcedStyle: double_quotes

Style/GlobalVars:
Exclude:
- ext/**/extconf.rb

Layout/LineLength:
Max: 120

0 comments on commit b40f120

Please sign in to comment.