rubyinstaller2 icon indicating copy to clipboard operation
rubyinstaller2 copied to clipboard

Latest gcc package version (15.1.0-1) breaks native gem compilation

Open johnnyshields opened this issue 7 months ago • 2 comments

As of April 25th, pacman is now installing gcc version 15.1.0-1 and this breaks native Ruby gem compilation for most of the gems I've tried. Unfortunately this affects all fresh Ruby installer installations.

On a previously working installation, I have confirmed that doing only ridk exec pacman -S mingw-w64-ucrt-x86_64-gcc and nothing else causes the breakage.

New version = mingw-w64-ucrt-x86_64-gcc-15.1.0-1 Old version = mingw-w64-ucrt-x86_64-gcc-14.2.0-3

Example failure:

>gem install snappy
Building native extensions. This could take a while...
ERROR:  Error installing snappy:
        ERROR: Failed to build gem native extension.

    current directory: c:/ruby34/lib/ruby/gems/3.4.0/gems/snappy-0.4.0/ext
c:/ruby34/bin/ruby.exe extconf.rb
checking for pkg-config for libsnappy... not found
checking for -lsnappy... yes
creating Makefile

current directory: c:/ruby34/lib/ruby/gems/3.4.0/gems/snappy-0.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20250502-24948-xrgqs6 sitelibdir\=./.gem.20250502-24948-xrgqs6 clean

current directory: c:/ruby34/lib/ruby/gems/3.4.0/gems/snappy-0.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20250502-24948-xrgqs6 sitelibdir\=./.gem.20250502-24948-xrgqs6
generating snappy_ext-x64-mingw-ucrt.def
compiling api.c
api.c: In function 'Init_snappy_ext':
api.c:104:55: error: passing argument 3 of 'rb_define_singleton_method' from incompatible pointer type [-Wincompatible-pointer-types]
  104 |     rb_define_singleton_method(rb_mSnappy, "deflate", snappy_deflate, -1);
      |                                                       ^~~~~~~~~~~~~~
      |                                                       |
      |                                                       VALUE (*)(int,  VALUE *, VALUE) {aka long long unsigned int (*)(int,  long long unsigned int *, long long unsigned int)}
In file included from C:/ruby34/include/ruby-3.4.0/ruby/internal/anyargs.h:76,
                 from C:/ruby34/include/ruby-3.4.0/ruby/ruby.h:27,
                 from C:/ruby34/include/ruby-3.4.0/ruby.h:38,
                 from api.c:1:
C:/ruby34/include/ruby-3.4.0/ruby/internal/intern/class.h:365:68: note: expected 'VALUE (*)(void)' {aka 'long long unsigned int (*)(void)'} but argument is of type 'VALUE (*)(int,  VALUE *, VALUE)' {aka 'long long unsigned int (*)(int,  long long unsigned int *, long long unsigned int)'}
  365 | void rb_define_singleton_method(VALUE obj, const char *mid, VALUE(*func)(ANYARGS), int arity);
      |                                                             ~~~~~~~^~~~~~~~~~~~~~
api.c:20:1: note: 'snappy_deflate' declared here
   20 | snappy_deflate(int argc, VALUE *argv, VALUE self)
      | ^~~~~~~~~~~~~~
api.c:105:55: error: passing argument 3 of 'rb_define_singleton_method' from incompatible pointer type [-Wincompatible-pointer-types]
  105 |     rb_define_singleton_method(rb_mSnappy, "inflate", snappy_inflate, -1);
      |                                                       ^~~~~~~~~~~~~~
      |                                                       |
      |                                                       VALUE (*)(int,  VALUE *, VALUE) {aka long long unsigned int (*)(int,  long long unsigned int *, long long unsigned int)}
C:/ruby34/include/ruby-3.4.0/ruby/internal/intern/class.h:365:68: note: expected 'VALUE (*)(void)' {aka 'long long unsigned int (*)(void)'} but argument is of type 'VALUE (*)(int,  VALUE *, VALUE)' {aka 'long long unsigned int (*)(int,  long long unsigned int *, long long unsigned int)'}
  365 | void rb_define_singleton_method(VALUE obj, const char *mid, VALUE(*func)(ANYARGS), int arity);
      |                                                             ~~~~~~~^~~~~~~~~~~~~~
api.c:48:1: note: 'snappy_inflate' declared here
   48 | snappy_inflate(int argc, VALUE *argv, VALUE self)
      | ^~~~~~~~~~~~~~
api.c:106:55: error: passing argument 3 of 'rb_define_singleton_method' from incompatible pointer type [-Wincompatible-pointer-types]
  106 |     rb_define_singleton_method(rb_mSnappy, "valid?",  snappy_valid_p, 1);
      |                                                       ^~~~~~~~~~~~~~
      |                                                       |
      |                                                       VALUE (*)(VALUE,  VALUE) {aka long long unsigned int (*)(long long unsigned int,  long long unsigned int)}
C:/ruby34/include/ruby-3.4.0/ruby/internal/intern/class.h:365:68: note: expected 'VALUE (*)(void)' {aka 'long long unsigned int (*)(void)'} but argument is of type 'VALUE (*)(VALUE,  VALUE)' {aka 'long long unsigned int (*)(long long unsigned int,  long long unsigned int)'}
  365 | void rb_define_singleton_method(VALUE obj, const char *mid, VALUE(*func)(ANYARGS), int arity);
      |                                                             ~~~~~~~^~~~~~~~~~~~~~
api.c:79:1: note: 'snappy_valid_p' declared here
   79 | snappy_valid_p(VALUE self, VALUE str)
      | ^~~~~~~~~~~~~~
make: *** [Makefile:251: api.o] Error 1

make failed, exit code 2

Gem files will remain installed in c:/ruby34/lib/ruby/gems/3.4.0/gems/snappy-0.4.0 for inspection.
Results logged to c:/ruby34/lib/ruby/gems/3.4.0/extensions/x64-mingw-ucrt/3.4.0/snappy-0.4.0/gem_make.out

johnnyshields avatar May 02 '25 13:05 johnnyshields

I already saw that. It's fixed by this commit on ruby-head. I guess that there will be new ruby releases in the next days due to https://www.ruby-lang.org/en/news/2025/04/28/dos-net-imap-cve-2025-43857/ . I'll wait for them and apply the patch if necessary then.

larskanis avatar May 02 '25 16:05 larskanis

OK, thank you! I left a comment asking to backport to the other Ruby versions.

johnnyshields avatar May 02 '25 18:05 johnnyshields

This appears to be fixed now.

johnnyshields avatar Aug 01 '25 13:08 johnnyshields

It's fixed for ruby-3.2.9, 3.3.9 and 2.4.4. I tried to backport the gcc-15 patches to 3.1.7, but gave up this plan. It is EOL now and will not be fixed.

larskanis avatar Aug 01 '25 16:08 larskanis

Thanks, I appreciate the effort! 🙇‍♂️

johnnyshields avatar Aug 01 '25 22:08 johnnyshields