Skip to content

Conversation

@kpumuk
Copy link
Contributor

@kpumuk kpumuk commented Dec 21, 2025

Currently, Ruby binary extension exports quite a load of functions, which might lead to conflicts with other gems.

After the patch:

$ nm -gU ext/thrift_native.so
0000000000007e60 T Init_thrift_native

Additionally,

  • Inherit compiling flags from Ruby build, only adding the ones Thrift cares about
    • For example, Ruby is usually compiled with -O3 and without debug symbols, but Thrift explicitly mentions debug symbols and all libraries use -O2
  • Fixed old style function definitions:
    binary_protocol_accelerated.c: In function ‘Init_binary_protocol_accelerated’:
    binary_protocol_accelerated.c:403:6: error: old-style function definition [-Werror=old-style-definition]
      403 | void Init_binary_protocol_accelerated() {
          |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

Before:

Full symbol dump before the patch
$ nm -gU ext/thrift_native.so
0000000000030440 B GARBAGE_BUFFER_SIZE
0000000000007260 T Init_binary_protocol_accelerated
0000000000009220 T Init_compact_protocol
0000000000009e04 T Init_memory_buffer
000000000000be00 T Init_struct
000000000000d060 T Init_thrift_native
0000000000030918 B TTYPE_BOOL
0000000000030914 B TTYPE_BYTE
0000000000030904 B TTYPE_DOUBLE
0000000000030910 B TTYPE_I16
000000000003090c B TTYPE_I32
0000000000030908 B TTYPE_I64
00000000000308f4 B TTYPE_LIST
00000000000308fc B TTYPE_MAP
00000000000308f8 B TTYPE_SET
000000000003091c B TTYPE_STOP
0000000000030900 B TTYPE_STRING
00000000000308f0 B TTYPE_STRUCT
0000000000030720 B binary_sym
0000000000030458 B buf_ivar_id
0000000000030728 B class_sym
0000000000007900 T convert_to_string
0000000000030778 B convert_to_string_id
00000000000078c0 T convert_to_utf8_byte_buffer
0000000000030780 B convert_to_utf8_byte_buffer_id
000000000000a580 T default_read_binary
000000000000a4c0 T default_read_bool
000000000000a4a0 T default_read_byte
000000000000a540 T default_read_double
000000000000a3a0 T default_read_field_begin
000000000000a3c0 T default_read_field_end
000000000000a4e0 T default_read_i16
000000000000a500 T default_read_i32
000000000000a520 T default_read_i64
000000000000a420 T default_read_list_begin
000000000000a440 T default_read_list_end
000000000000a3e0 T default_read_map_begin
000000000000a400 T default_read_map_end
000000000000a460 T default_read_set_begin
000000000000a480 T default_read_set_end
000000000000a560 T default_read_string
000000000000a5a0 T default_read_struct_begin
000000000000a5c0 T default_read_struct_end
000000000000a130 T default_write_binary
0000000000009fe0 T default_write_bool
000000000000a010 T default_write_byte
000000000000a0d0 T default_write_double
000000000000a300 T default_write_field_begin
000000000000a340 T default_write_field_end
000000000000a36c T default_write_field_stop
000000000000a040 T default_write_i16
000000000000a070 T default_write_i32
000000000000a0a0 T default_write_i64
000000000000a160 T default_write_list_begin
000000000000a1a0 T default_write_list_end
000000000000a22c T default_write_map_begin
000000000000a26c T default_write_map_end
000000000000a1cc T default_write_set_begin
000000000000a200 T default_write_set_end
000000000000a100 T default_write_string
000000000000a2a0 T default_write_struct_begin
000000000000a2d0 T default_write_struct_end
0000000000030730 B element_sym
00000000000307b8 B entries_method_id
0000000000030770 B fields_const_id
0000000000007880 T force_binary_encoding
0000000000030788 B force_binary_encoding_id
000000000000b1a0 T get_field_value
0000000000030450 B index_ivar_id
0000000000030740 B key_sym
00000000000307c0 B keys_method_id
0000000000030748 B name_sym
00000000000304a0 B name_to_id_method_id
0000000000030718 B protocol_exception_class
0000000000030938 B rb_cSet
0000000000006320 T rb_thrift_binary_proto_native_qmark
0000000000006a48 T rb_thrift_binary_proto_read_binary
0000000000006b40 T rb_thrift_binary_proto_read_bool
0000000000006b88 T rb_thrift_binary_proto_read_byte
00000000000064b0 T rb_thrift_binary_proto_read_double
0000000000006d50 T rb_thrift_binary_proto_read_field_begin
00000000000068d0 T rb_thrift_binary_proto_read_field_end
0000000000006900 T rb_thrift_binary_proto_read_i16
0000000000006a2c T rb_thrift_binary_proto_read_i32
0000000000006480 T rb_thrift_binary_proto_read_i64
0000000000006c20 T rb_thrift_binary_proto_read_list_begin
00000000000068e8 T rb_thrift_binary_proto_read_list_end
0000000000006bcc T rb_thrift_binary_proto_read_map_begin
00000000000068e0 T rb_thrift_binary_proto_read_map_end
00000000000070e0 T rb_thrift_binary_proto_read_message_begin
00000000000068b0 T rb_thrift_binary_proto_read_message_end
0000000000006c60 T rb_thrift_binary_proto_read_set_begin
00000000000068f0 T rb_thrift_binary_proto_read_set_end
0000000000006aa4 T rb_thrift_binary_proto_read_string
00000000000068c0 T rb_thrift_binary_proto_read_struct_begin
00000000000068c8 T rb_thrift_binary_proto_read_struct_end
0000000000006800 T rb_thrift_binary_proto_write_binary
0000000000006ce0 T rb_thrift_binary_proto_write_bool
0000000000006ea0 T rb_thrift_binary_proto_write_byte
00000000000067a0 T rb_thrift_binary_proto_write_double
0000000000006f30 T rb_thrift_binary_proto_write_field_begin
0000000000006888 T rb_thrift_binary_proto_write_field_end
0000000000006c64 T rb_thrift_binary_proto_write_field_stop
0000000000006ac0 T rb_thrift_binary_proto_write_i16
00000000000066b0 T rb_thrift_binary_proto_write_i32
0000000000006728 T rb_thrift_binary_proto_write_i64
0000000000006de0 T rb_thrift_binary_proto_write_list_begin
00000000000068a0 T rb_thrift_binary_proto_write_list_end
0000000000007000 T rb_thrift_binary_proto_write_map_begin
0000000000006890 T rb_thrift_binary_proto_write_map_end
0000000000006550 T rb_thrift_binary_proto_write_message_begin
0000000000006328 T rb_thrift_binary_proto_write_message_end
0000000000006e80 T rb_thrift_binary_proto_write_set_begin
00000000000068a8 T rb_thrift_binary_proto_write_set_end
000000000000666c T rb_thrift_binary_proto_write_string
0000000000006330 T rb_thrift_binary_proto_write_struct_begin
0000000000006880 T rb_thrift_binary_proto_write_struct_end
0000000000007940 T rb_thrift_compact_proto_native_qmark
000000000000816c T rb_thrift_compact_proto_read_binary
0000000000008b70 T rb_thrift_compact_proto_read_bool
0000000000008240 T rb_thrift_compact_proto_read_byte
0000000000007d50 T rb_thrift_compact_proto_read_double
0000000000008a20 T rb_thrift_compact_proto_read_field_begin
0000000000007e30 T rb_thrift_compact_proto_read_field_end
0000000000008030 T rb_thrift_compact_proto_read_i16
0000000000007fa4 T rb_thrift_compact_proto_read_i32
00000000000080c0 T rb_thrift_compact_proto_read_i64
0000000000008450 T rb_thrift_compact_proto_read_list_begin
0000000000007e48 T rb_thrift_compact_proto_read_list_end
0000000000007f04 T rb_thrift_compact_proto_read_map_begin
0000000000007e40 T rb_thrift_compact_proto_read_map_end
00000000000090cc T rb_thrift_compact_proto_read_message_begin
0000000000007e28 T rb_thrift_compact_proto_read_message_end
00000000000084e0 T rb_thrift_compact_proto_read_set_begin
0000000000007e50 T rb_thrift_compact_proto_read_set_end
0000000000008220 T rb_thrift_compact_proto_read_string
0000000000007980 T rb_thrift_compact_proto_read_struct_begin
0000000000007e60 T rb_thrift_compact_proto_read_struct_end
0000000000008724 T rb_thrift_compact_proto_write_binary
0000000000008fc8 T rb_thrift_compact_proto_write_bool
0000000000008300 T rb_thrift_compact_proto_write_byte
0000000000007cc0 T rb_thrift_compact_proto_write_double
0000000000008f2c T rb_thrift_compact_proto_write_field_begin
0000000000007e00 T rb_thrift_compact_proto_write_field_end
0000000000008284 T rb_thrift_compact_proto_write_field_stop
000000000000870c T rb_thrift_compact_proto_write_i16
0000000000008600 T rb_thrift_compact_proto_write_i32
00000000000084e4 T rb_thrift_compact_proto_write_i64
0000000000008ce0 T rb_thrift_compact_proto_write_list_begin
0000000000007e10 T rb_thrift_compact_proto_write_list_end
0000000000008c20 T rb_thrift_compact_proto_write_map_begin
0000000000007e08 T rb_thrift_compact_proto_write_map_end
0000000000008884 T rb_thrift_compact_proto_write_message_begin
0000000000007948 T rb_thrift_compact_proto_write_message_end
0000000000008dd0 T rb_thrift_compact_proto_write_set_begin
0000000000007e20 T rb_thrift_compact_proto_write_set_end
0000000000008850 T rb_thrift_compact_proto_write_string
0000000000007950 T rb_thrift_compact_proto_write_struct_begin
00000000000079a8 T rb_thrift_compact_proto_write_struct_end
00000000000099e0 T rb_thrift_memory_buffer_read
0000000000009b40 T rb_thrift_memory_buffer_read_byte
0000000000009c50 T rb_thrift_memory_buffer_read_into_buffer
0000000000009980 T rb_thrift_memory_buffer_write
0000000000030798 B read_all_method_id
0000000000030820 B read_binary_method_id
0000000000030850 B read_bool_method_id
0000000000030848 B read_byte_method_id
0000000000030818 B read_double_method_id
00000000000307d0 B read_field_begin_method_id
00000000000307c8 B read_field_end_method_id
0000000000030840 B read_i16_method_id
0000000000030838 B read_i32_method_id
0000000000030830 B read_i64_method_id
0000000000030790 B read_into_buffer_method_id
0000000000030800 B read_list_begin_method_id
00000000000307f8 B read_list_end_method_id
0000000000030810 B read_map_begin_method_id
0000000000030808 B read_map_end_method_id
00000000000307f0 B read_set_begin_method_id
00000000000307e8 B read_set_end_method_id
0000000000030828 B read_string_method_id
00000000000307e0 B read_struct_begin_method_id
00000000000307d8 B read_struct_end_method_id
00000000000304b8 B setfield_id
00000000000304b0 B setvalue_id
00000000000307a8 B skip_method_id
0000000000030448 B slice_method_id
0000000000030760 B strict_read_ivar_id
0000000000030758 B strict_write_ivar_id
0000000000030928 B thrift_bytes_module
0000000000030930 B thrift_module
0000000000030920 B thrift_types_module
00000000000304c0 B thrift_union_class
00000000000304a8 B to_s_method_id
0000000000030768 B transport_ivar_id
0000000000030750 B type_sym
00000000000308e8 B validate_method_id
0000000000030738 B value_sym
0000000000030888 B write_binary_method_id
00000000000308c0 B write_boolean_method_id
00000000000308b8 B write_byte_method_id
0000000000030898 B write_double_method_id
00000000000308d0 B write_field_begin_method_id
00000000000308c8 B write_field_end_method_id
00000000000307b0 B write_field_stop_method_id
00000000000308b0 B write_i16_method_id
00000000000308a8 B write_i32_method_id
00000000000308a0 B write_i64_method_id
0000000000030870 B write_list_begin_method_id
0000000000030868 B write_list_end_method_id
0000000000030880 B write_map_begin_method_id
0000000000030878 B write_map_end_method_id
00000000000307a0 B write_method_id
0000000000030860 B write_set_begin_method_id
0000000000030858 B write_set_end_method_id
0000000000030890 B write_string_method_id
00000000000308e0 B write_struct_begin_method_id
00000000000308d8 B write_struct_end_method_id
  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant