Skip to content
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

Merged
merged 1 commit into from Mar 25, 2023

Conversation

casperisfine
Copy link

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.

@MSP-Greg
Copy link
Contributor

I seem to recall a few gems that compile vendored code, then use ffi to access it. Will they be affected by this?

Copy link
Member

@deivid-rodriguez deivid-rodriguez left a 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!

@deivid-rodriguez
Copy link
Member

@MSP-Greg This is just the boilerplate code created by bundle gem, so my understanding is that this should not affect any existing gems.

@MSP-Greg
Copy link
Contributor

@deivid-rodriguez @casperisfine

This is just the boilerplate code

Duh. This isn't mkmf. Sorry, not enough coffee yet...

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.
auto-merge was automatically disabled March 24, 2023 20:13

Head branch was pushed to by a user without write access

@simi simi enabled auto-merge March 24, 2023 20:14
@casperisfine
Copy link
Author

Duh. This isn't mkmf.

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.

@simi simi added this pull request to the merge queue Mar 24, 2023
Merged via the queue into rubygems:master with commit 7305d11 Mar 25, 2023
92 checks passed
# 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 "
Copy link
Contributor

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").

hsbt added a commit that referenced this pull request Mar 28, 2023
hsbt added a commit that referenced this pull request Mar 28, 2023
deivid-rodriguez pushed a commit that referenced this pull request Apr 10, 2023
Generate native gems with `-fvisibility=hidden`

(cherry picked from commit 7305d11)
deivid-rodriguez pushed a commit that referenced this pull request Apr 10, 2023
Partly reverted rubocop rule at GH-6541

(cherry picked from commit 18dbac7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants