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

Define YP_EXPORTED_FUNCTION as empty #1111

Closed
wants to merge 1 commit into from

Commits on Jun 30, 2023

  1. Define YP_EXPORTED_FUNCTION as empty

    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
    ```
    tenderlove committed Jun 30, 2023
    Configuration menu
    Copy the full SHA
    748f933 View commit details
    Browse the repository at this point in the history