Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5475

shorten-64-to-32 errors compilation errors on macOS

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Ruby - Library
    • None

    Description

      The ruby gem fail to compile on newer macOS versions, presumably because of a new clang warning.

       

      I provided a patch for it here: https://github.com/apache/thrift/pull/2464

       

      On a sidenote, it's not recommended for Ruby native extensions to set `-Wall` outside of their own CI environment for this exact reason. Newer compilers get stricter, and the gem becomes unusable. 

      ```

       

      {{$ ruby --version
      ruby 3.1.0dev (2021-10-06T06:42:37Z master d53493715c) [x86_64-darwin20]
      $ gem install thrift
      Building native extensions. This could take a while...
      ERROR: Error installing thrift:
      ERROR: Failed to build gem native extension.

      current directory: /Users/byroot/.gem/ruby/3.1.0/gems/thrift-0.15.0/ext
      /opt/rubies/3.1.0-dev/bin/ruby -I /opt/rubies/3.1.0-dev/lib/ruby/3.1.0 -r ./siteconf20211013-11520-x7l42b.rb extconf.rb
      checking for strlcpy() in string.h... yes
      creating Makefile

      current directory: /Users/byroot/.gem/ruby/3.1.0/gems/thrift-0.15.0/ext
      make DESTDIR\= clean

      current directory: /Users/byroot/.gem/ruby/3.1.0/gems/thrift-0.15.0/ext
      make DESTDIR\=
      compiling binary_protocol_accelerated.c
      binary_protocol_accelerated.c:85:27: error: implicit conversion loses integer precision: 'long' to 'int32_t' (aka 'int') [-Werror,-Wshorten-64-to-32]
      write_i32_direct(trans, RSTRING_LEN(str));
      ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~
      /opt/rubies/3.1.0-dev/include/ruby-3.1.0/ruby/internal/core/rstring.h:50:27: note: expanded from macro 'RSTRING_LEN'
      #define RSTRING_LEN RSTRING_LEN
      ^
      binary_protocol_accelerated.c:226:27: error: implicit conversion loses integer precision: 'long' to 'int32_t' (aka 'int') [-Werror,-Wshorten-64-to-32]
      write_i32_direct(trans, RSTRING_LEN(buf));
      ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~
      /opt/rubies/3.1.0-dev/include/ruby-3.1.0/ruby/internal/core/rstring.h:50:27: note: expanded from macro 'RSTRING_LEN'
      #define RSTRING_LEN RSTRING_LEN
      ^
      binary_protocol_accelerated.c:406:15: error: implicit conversion loses integer precision: 'long long' to 'int' [-Werror,-Wshorten-64-to-32]
      VERSION_1 = rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("VERSION_1")));
      ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      binary_protocol_accelerated.c:407:18: error: implicit conversion loses integer precision: 'long long' to 'int' [-Werror,-Wshorten-64-to-32]
      VERSION_MASK = rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("VERSION_MASK")));
      ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      binary_protocol_accelerated.c:408:15: error: implicit conversion loses integer precision: 'long long' to 'int' [-Werror,-Wshorten-64-to-32]
      TYPE_MASK = rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("TYPE_MASK")));
      ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      5 errors generated.
      make: *** [binary_protocol_accelerated.o] Error 1}}

      ```

      Attachments

        Activity

          People

            Unassigned Unassigned
            byroot Jean Boussier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: