-
Notifications
You must be signed in to change notification settings - Fork 142
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
Define YP_EXPORTED_FUNCTION as empty #1111
Conversation
We are currently leaking YARP symbols in Ruby 3.3 (Ruby head): ``` $ nm libruby.3.3-static.a | grep yp_parser_init 000000000000000c T _yp_parser_init 000000000002a393 s l___func__.yp_parser_init ``` This is not good because if we use Ruby 3.3 to compile YARP as a C extension (for example installing the YARP gem), the linker gets confused and ends up prioritizing the symbol found in Ruby rather than the one from the Gem. This means the C extension can end up calling in to `yp_parser_init` in Ruby rather than the new one shipped with the extension. If I use current Ruby head to compile YARP in this repository, `nm` will show that `yp_parser_init` is *not* defined: ``` $ nm lib/yarp.bundle | grep yp_parser_init U _yp_parser_init ``` This is because the linker got confused about the leaked symbols. I would like to default all functions to *not* be external. This hides the symbols and fixes the problem with Ruby and YARP as a gem. If I apply this patch to Ruby, build Ruby, then build YARP, `yp_parser_init` is defined in the Gem: ``` $ nm lib/yarp.bundle | grep yp_parser_init 00000000000162f8 t _yp_parser_init 000000000002d8ac t _yp_parser_init.cold.1 000000000002d8d4 t _yp_parser_init.cold.2 ```
49c305b
to
748f933
Compare
I think at this point with this PR you can just remove the whole macro. If the point is that nothing should be exported let's get rid of the whole thing and just keep visibility hidden. |
We need the symbols to be exported for the dynamic library, for Fiddle/FFI: #1112 |
Could Ruby define |
Yeah, just for the record: #1069 set up compilation so that compiling with It seems like we have two options:
I don't care which; but if we choose 2 then we need to make sure
Compare that output to what gets built on
|
Yeah I'd be totally fine to change the default, just as you said the |
Yes, I'd like to do this one because I don't really want to modify the build system in Ruby. |
This reverses the convention introduced in ruby#1069, and requires `YP_EXPORT_SYMBOLS` to be defined at compile-time when building a shared library. See related ruby#1111 which describes a symbol leakage problem in Ruby 3.3 (ruby head) that this commit, once merged upstream into Ruby, should address. Note that the tests introduced in a previous commit ensure that the static archive and shared objects are all being created correctly after this change.
This reverses the convention introduced in ruby#1069, and requires `YP_EXPORT_SYMBOLS` to be defined at compile-time when building a shared library. See related ruby#1111 which describes a symbol leakage problem in Ruby 3.3 (ruby head) that this commit, once merged upstream into Ruby, should address. Note that the tests introduced in a previous commit ensure that the static archive and shared objects are all being created correctly after this change. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
This reverses the convention introduced in ruby#1069, and requires `YP_EXPORT_SYMBOLS` to be defined at compile-time when building a shared library. See related ruby#1111 which describes a symbol leakage problem in Ruby 3.3 (ruby head) that this commit, once merged upstream into Ruby, should address. Note that the tests introduced in a previous commit ensure that the static archive and shared objects are all being created correctly after this change. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
@tenderlove I think you can close this now that #1110 shipped. |
Closing since #1110 shipped |
We are currently leaking YARP symbols in Ruby 3.3 (Ruby head):
This is not good because if we use Ruby 3.3 to compile YARP as a C
extension (for example installing the YARP gem), the linker gets
confused and ends up prioritizing the symbol found in Ruby rather than
the one from the Gem. This means the C extension can end up calling in
to
yp_parser_init
in Ruby rather than the new one shipped with theextension.
If I use current Ruby head to compile YARP in this repository,
nm
willshow that
yp_parser_init
is not defined:This is because the linker got confused about the leaked symbols.
I would like to default all functions to not be external. This hides
the symbols and fixes the problem with Ruby and YARP as a gem. If I
apply this patch to Ruby, build Ruby, then build YARP,
yp_parser_init
is defined in the Gem:
/cc @flavorjones
Related to #1110