kwilczynski / ruby-magic

Simple interface to libmagic for Ruby Programming Language
Apache License 2.0
27 stars 8 forks source link

Work around Ruby 3.1 pkg_config limitations #32

Closed flavorjones closed 2 years ago

flavorjones commented 2 years ago

Pull in the Ruby master mkmf.rb temporarily.

Note that ruby-magic.c doesn't compile in the rake-compiler-dock environment, failing with:

In file included from ../../../../ext/magic/functions.h:8,
                 from ../../../../ext/magic/functions.c:5:
../../../../ext/magic/common.h: At top level:
../../../../ext/magic/common.h:142:11: fatal error: rubysig.h: No such file or directory
  142 | # include <rubysig.h>
      |           ^~~~~~~~~~~
compilation terminated.
In file included from ../../../../ext/magic/ruby-magic.h:8,
                 from ../../../../ext/magic/ruby-magic.c:5:
../../../../ext/magic/common.h: At top level:
../../../../ext/magic/common.h:142:11: fatal error: rubysig.h: No such file or directory
  142 | # include <rubysig.h>
      |           ^~~~~~~~~~~
compilation terminated.

which comes from the GVL/blocking region section in common.h. I don't know how to resolve that, and I'm asking for help @stanhu @kwilczynski

kwilczynski commented 2 years ago

Hi @flavorjones,

Let me look into this! The rubysig.h was to be deprecated for a while now, I suppose, it finally happened. Bear with me!

Update:

I need to check what else changed in Ruby 3.1, as where this branched into during the preprocessor pass should not really be possible on a modern Ruby.

Krzysztof

kwilczynski commented 2 years ago

Hi @flavorjones,

Using your branch and my local Ruby 3.1.0 things seem to work perfectly as per:

Screenshot from 2022-01-13 23-04-42

I had to make sure nothing broke with this latest release of Ruby. Next, let me try the rake-compiler/rake-compiler-dock environment.

Also, we never had issues with this before Ruby 3.1, I believe.

Update:

No, rake-compiler-dock version 1.1.0 which offers Ruby 3.0 works perfectly fine.

flavorjones commented 2 years ago

You should also check by running rake gem:x86_64-linux and build in the rake-compiler-dock image. That ruby has different compile-time options than my ruby-build-installed ruby on my host (and so might yours?)

kwilczynski commented 2 years ago

Hi @flavorjones,

You should also check by running rake gem:x86_64-linux and build in the rake-compiler-dock image. That ruby has different compile-time options than my ruby-build-installed ruby on my host (and so might yours?)

This is what I am doing at the moment. And there is a very curious thing about this Docker container. For example, the following works fine:

Works ```bash $ RCD_PLATFORM=x86_64-linux rake-compiler-dock [kwilczynski@9feaa209b219 ruby-magic]$ ruby -v ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux] [kwilczynski@9feaa209b219 ruby-magic]$ bundle install Fetching gem metadata from https://rubygems.org/. Bundler 2.3.4 is running, but your lockfile was generated with 2.3.5. Installing Bundler 2.3.5 and restarting using that version. Fetching bundler 2.3.5 Installing bundler 2.3.5 Fetching gem metadata from https://rubygems.org/......... Using rake 13.0.6 Using bundler 2.3.5 Fetching coderay 1.1.3 Fetching ffi 1.15.5 Fetching formatador 0.3.0 Fetching thor 1.2.1 Fetching lumberjack 1.2.8 Fetching rb-fsevent 0.11.0 Fetching shellany 0.0.1 Using mini_portile2 2.7.1 Fetching mocha 1.13.0 Fetching rainbow 3.1.1 Using power_assert 2.0.1 Using stringio 3.0.1 Fetching guard-compat 1.2.1 Fetching rake-compiler 1.1.7 Fetching rake-compiler-dock 1.2.0 Fetching nenv 0.3.0 Fetching parallel 1.21.0 Fetching ast 2.4.2 Fetching method_source 1.0.0 Installing formatador 0.3.0 Installing shellany 0.0.1 Installing lumberjack 1.2.8 Installing rainbow 3.1.1 Installing nenv 0.3.0 Installing rake-compiler 1.1.7 Installing thor 1.2.1 Installing method_source 1.0.0 Installing parallel 1.21.0 Installing ast 2.4.2 Installing guard-compat 1.2.1 Installing rake-compiler-dock 1.2.0 Installing coderay 1.1.3 Installing mocha 1.13.0 Installing rb-fsevent 0.11.0 Fetching regexp_parser 2.2.0 Using rexml 3.2.5 Fetching ruby-progressbar 1.11.0 Fetching unicode-display_width 2.1.0 Using ruby-magic 0.5.3 from source at `.` Using test-unit 3.5.3 Using psych 4.0.3 Fetching parser 3.1.0.0 Installing ffi 1.15.5 with native extensions Using rdoc 6.4.0 Installing ruby-progressbar 1.11.0 Installing regexp_parser 2.2.0 Fetching notiffany 0.1.3 Installing unicode-display_width 2.1.0 Fetching pry 0.14.1 Installing notiffany 0.1.3 Installing parser 3.1.0.0 Installing pry 0.14.1 Fetching rubocop-ast 1.15.1 Installing rubocop-ast 1.15.1 Fetching rubocop 1.24.1 Installing rubocop 1.24.1 Fetching rb-inotify 0.10.1 Installing rb-inotify 0.10.1 Fetching listen 3.7.1 Installing listen 3.7.1 Fetching guard 2.18.0 Installing guard 2.18.0 Fetching guard-bundler 3.0.0 Fetching guard-rake 1.0.0 Installing guard-rake 1.0.0 Installing guard-bundler 3.0.0 Bundle complete! 11 Gemfile dependencies, 39 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. [kwilczynski@9feaa209b219 ruby-magic]$ gem env RubyGems Environment: - RUBYGEMS VERSION: 3.3.4 - RUBY VERSION: 3.1.0 (2021-12-25 patchlevel 0) [x86_64-linux] - INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-3.1.0 - USER INSTALLATION DIRECTORY: /tmp/home/kwilczynski/.gem/ruby/3.1.0 - RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-3.1.0/bin/ruby - GIT EXECUTABLE: /bin/git - EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-3.1.0/bin - SPEC CACHE DIRECTORY: /tmp/home/kwilczynski/.local/share/gem/specs - SYSTEM CONFIGURATION DIRECTORY: /usr/local/rvm/rubies/ruby-3.1.0/etc - RUBYGEMS PLATFORMS: - ruby - x86_64-linux - GEM PATHS: - /usr/local/rvm/gems/ruby-3.1.0 - /usr/local/rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0 - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - https://rubygems.org/ - SHELL PATH: - /opt/rh/devtoolset-10/root/usr/bin - /usr/local/rvm/gems/ruby-3.1.0/bin - /usr/local/rvm/gems/ruby-3.1.0@global/bin - /usr/local/rvm/rubies/ruby-3.1.0/bin - /usr/local/rvm/bin - /sbin - /bin - /usr/sbin - /usr/bin [kwilczynski@9feaa209b219 ruby-magic]$ rvm list Warning! PATH is not properly set up, /usr/local/rvm/gems/ruby-3.1.0/bin is not at first place. Usually this is caused by shell initialization files. Search for PATH=... entries. You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles To fix it temporarily in this shell session run: rvm use ruby-3.1.0 To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file. ruby-2.5.9 [ x86_64 ] =* ruby-3.1.0 [ x86_64 ] # => - current # =* - current && default # * - default [kwilczynski@9feaa209b219 ruby-magic]$ ruby ext/magic/extconf.rb Building ruby-magic using packaged libraries. Static linking is enabled. Cross build is disabled. Using mini_portile version 2.7.1 Building Ruby Magic with a packaged version of libmagic-5.39. Activating libmagic 5.39 (from /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ports/x86_64-pc-linux-gnu/libmagic/5.39)... checking for ruby.h... yes checking for -lpthread... yes checking for -lrt... yes checking for -ldl... yes checking for -lcrypt... yes checking for rb_thread_call_without_gvl()... yes checking for rb_thread_blocking_region()... no checking for magic.h... yes checking for -lmagic... yes checking for magic_getpath()... yes checking for magic_getflags()... yes checking for utime.h... yes checking for sys/types.h... yes checking for sys/time.h... yes checking for utime()... yes checking for utimes()... yes creating extconf.h creating Makefile [kwilczynski@9feaa209b219 ruby-magic]$ make compiling ext/magic/functions.c In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:42, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/int.h:26, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/char.h:23, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic.h:23, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:27, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/functions.h:8, from ext/magic/functions.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/special_consts.h: In function ‘RB_TEST’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/special_consts.h:148:16: warning: unsigned conversion from ‘int’ to ‘VALUE’ {aka ‘long unsigned int’} changes value from ‘-9’ to ‘18446744073709551607’ [-Wsign-conversion] 148 | return obj & ~RUBY_Qnil; | ^ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/int.h:26, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/char.h:23, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic.h:23, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:27, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/functions.h:8, from ext/magic/functions.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘RB_INT2FIX’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:117:29: warning: conversion to ‘long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion] 117 | const unsigned long j = i; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:119:29: warning: conversion to ‘long int’ from ‘long unsigned int’ may change the sign of the result [-Wsign-conversion] 119 | const long l = k; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:121:29: warning: conversion to ‘VALUE’ {aka ‘const long unsigned int’} from ‘long int’ may change the sign of the result [-Wsign-conversion] 121 | const VALUE n = m; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rbimpl_fix2long_by_idiv’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:169:28: warning: conversion to ‘long int’ from ‘VALUE’ {aka ‘long unsigned int’} may change the sign of the result [-Wsign-conversion] 169 | const SIGNED_VALUE y = x - RUBY_FIXNUM_FLAG; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rbimpl_fix2long_by_shift’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:196:28: warning: conversion to ‘long int’ from ‘VALUE’ {aka ‘long unsigned int’} may change the sign of the result [-Wsign-conversion] 196 | const SIGNED_VALUE y = x; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rb_fix2ulong’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:255:12: warning: conversion to ‘long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion] 255 | return rb_fix2long(x); | ^~~~~~~~~~~~~~ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rb_ulong2num_inline’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:326:28: warning: conversion to ‘long int’ from ‘long unsigned int’ may change the sign of the result [-Wsign-conversion] 326 | return RB_LONG2FIX(v); | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long_long.h: In function ‘rb_num2ull_inline’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:53:22: warning: conversion to ‘long long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion] 53 | #define RB_FIX2LONG rb_fix2long /**< @alias{rb_fix2long} */ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long_long.h:130:16: note: in expansion of macro ‘RB_FIX2LONG’ 130 | return RB_FIX2LONG(x); | ^~~~~~~~~~~ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic.h:36, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:27, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/functions.h:8, from ext/magic/functions.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/st_data_t.h: In function ‘RB_ST2FIX’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/st_data_t.h:61:22: warning: conversion to ‘long int’ from ‘st_data_t’ {aka ‘long unsigned int’} may change the sign of the result [-Wsign-conversion] 61 | SIGNED_VALUE x = i; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/st_data_t.h:72:24: warning: conversion to ‘long int’ from ‘long unsigned int’ may change the sign of the result [-Wsign-conversion] 72 | return RB_LONG2FIX(y); | ^ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/assume.h:29, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward/2/assume.h:24, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/defines.h:72, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:25, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/functions.h:8, from ext/magic/functions.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rarray.h: In function ‘RARRAY_PTR’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rarray.h:556:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 556 | return RBIMPL_CAST((VALUE *)RARRAY_CONST_PTR(tmp)); | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:41, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/functions.h:8, from ext/magic/functions.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/memory.h: In function ‘rb_alloc_tmp_buffer2’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/memory.h:642:56: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘long int’ may change the sign of the result [-Wsign-conversion] 642 | const size_t total_size = rbimpl_size_mul_or_raise(count, elsize); | ^~~~~ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h:27, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/encoding.h:22, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/io.h:16, from ext/magic/common.h:36, from ext/magic/functions.h:8, from ext/magic/functions.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h: In function ‘RB_ENCODING_SET_INLINED’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h:82:28: warning: conversion to ‘VALUE’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion] 82 | VALUE f = /* upcast */ encindex; | ^~~~~~~~ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/assume.h:29, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward/2/assume.h:24, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/defines.h:72, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:25, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/functions.h:8, from ext/magic/functions.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h: In function ‘rb_enc_step_back’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h:747:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 747 | return RBIMPL_CAST((char *)ur); | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h: In function ‘rb_enc_is_newline’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h:45:33: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 45 | OnigUChar *up = RBIMPL_CAST((OnigUChar *)p); | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h:46:33: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 46 | OnigUChar *ue = RBIMPL_CAST((OnigUChar *)e); | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ compiling ext/magic/ruby-magic.c In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:42, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/int.h:26, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/char.h:23, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic.h:23, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:27, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/ruby-magic.h:8, from ext/magic/ruby-magic.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/special_consts.h: In function ‘RB_TEST’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/special_consts.h:148:16: warning: unsigned conversion from ‘int’ to ‘VALUE’ {aka ‘long unsigned int’} changes value from ‘-9’ to ‘18446744073709551607’ [-Wsign-conversion] 148 | return obj & ~RUBY_Qnil; | ^ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/int.h:26, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/char.h:23, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic.h:23, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:27, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/ruby-magic.h:8, from ext/magic/ruby-magic.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘RB_INT2FIX’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:117:29: warning: conversion to ‘long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion] 117 | const unsigned long j = i; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:119:29: warning: conversion to ‘long int’ from ‘long unsigned int’ may change the sign of the result [-Wsign-conversion] 119 | const long l = k; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:121:29: warning: conversion to ‘VALUE’ {aka ‘const long unsigned int’} from ‘long int’ may change the sign of the result [-Wsign-conversion] 121 | const VALUE n = m; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rbimpl_fix2long_by_idiv’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:169:28: warning: conversion to ‘long int’ from ‘VALUE’ {aka ‘long unsigned int’} may change the sign of the result [-Wsign-conversion] 169 | const SIGNED_VALUE y = x - RUBY_FIXNUM_FLAG; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rbimpl_fix2long_by_shift’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:196:28: warning: conversion to ‘long int’ from ‘VALUE’ {aka ‘long unsigned int’} may change the sign of the result [-Wsign-conversion] 196 | const SIGNED_VALUE y = x; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rb_fix2ulong’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:255:12: warning: conversion to ‘long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion] 255 | return rb_fix2long(x); | ^~~~~~~~~~~~~~ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rb_ulong2num_inline’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:326:28: warning: conversion to ‘long int’ from ‘long unsigned int’ may change the sign of the result [-Wsign-conversion] 326 | return RB_LONG2FIX(v); | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long_long.h: In function ‘rb_num2ull_inline’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:53:22: warning: conversion to ‘long long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion] 53 | #define RB_FIX2LONG rb_fix2long /**< @alias{rb_fix2long} */ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long_long.h:130:16: note: in expansion of macro ‘RB_FIX2LONG’ 130 | return RB_FIX2LONG(x); | ^~~~~~~~~~~ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic.h:36, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:27, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/ruby-magic.h:8, from ext/magic/ruby-magic.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/st_data_t.h: In function ‘RB_ST2FIX’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/st_data_t.h:61:22: warning: conversion to ‘long int’ from ‘st_data_t’ {aka ‘long unsigned int’} may change the sign of the result [-Wsign-conversion] 61 | SIGNED_VALUE x = i; | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/st_data_t.h:72:24: warning: conversion to ‘long int’ from ‘long unsigned int’ may change the sign of the result [-Wsign-conversion] 72 | return RB_LONG2FIX(y); | ^ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/assume.h:29, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward/2/assume.h:24, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/defines.h:72, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:25, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/ruby-magic.h:8, from ext/magic/ruby-magic.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rarray.h: In function ‘RARRAY_PTR’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rarray.h:556:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 556 | return RBIMPL_CAST((VALUE *)RARRAY_CONST_PTR(tmp)); | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:41, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/ruby-magic.h:8, from ext/magic/ruby-magic.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/memory.h: In function ‘rb_alloc_tmp_buffer2’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/memory.h:642:56: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘long int’ may change the sign of the result [-Wsign-conversion] 642 | const size_t total_size = rbimpl_size_mul_or_raise(count, elsize); | ^~~~~ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h:27, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/encoding.h:22, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/io.h:16, from ext/magic/common.h:36, from ext/magic/ruby-magic.h:8, from ext/magic/ruby-magic.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h: In function ‘RB_ENCODING_SET_INLINED’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h:82:28: warning: conversion to ‘VALUE’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion] 82 | VALUE f = /* upcast */ encindex; | ^~~~~~~~ In file included from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/assume.h:29, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward/2/assume.h:24, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/defines.h:72, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:25, from /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ext/magic/common.h:32, from ext/magic/ruby-magic.h:8, from ext/magic/ruby-magic.c:5: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h: In function ‘rb_enc_step_back’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h:747:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 747 | return RBIMPL_CAST((char *)ur); | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h: In function ‘rb_enc_is_newline’: /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h:45:33: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 45 | OnigUChar *up = RBIMPL_CAST((OnigUChar *)p); | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h:46:33: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 46 | OnigUChar *ue = RBIMPL_CAST((OnigUChar *)e); | ^ /usr/local/rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ linking shared-object magic/magic.so [kwilczynski@9feaa209b219 ruby-magic]$ cp magic.so lib/magic [kwilczynski@9feaa209b219 ruby-magic]$ rake test no configuration section for specified version of Ruby (rbconfig-x86-linux-2.5.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-2.6.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-2.7.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-3.0.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-3.1.0) Loaded suite /usr/local/rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/rake_test_loader Started ......................................................................................................................................O ====================================================================================================================================================================================================== Omission: Platform supports fork [test_magic_singleton_do_not_auto_load_global_no_fork(MagicTest)] /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/test/test_magic.rb:785:in `test_magic_singleton_do_not_auto_load_global_no_fork' ====================================================================================================================================================================================================== ........................... Finished in 0.079678989 seconds. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 162 tests, 237 assertions, 0 failures, 0 errors, 0 pendings, 1 omissions, 0 notifications 100% passed ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 2033.16 tests/s, 2974.44 assertions/s ```

In this case, mkmf had no issues locating the rb_thread_call_without_gvl() function, which should be exported and available on any modern Ruby. However, the following that is using rake compile fails and the aforementioned function cannot be found, as per:

Broken ```bash [kwilczynski@9feaa209b219 ruby-magic]$ rake clean clobber no configuration section for specified version of Ruby (rbconfig-x86-linux-2.5.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-2.6.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-2.7.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-3.0.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-3.1.0) [kwilczynski@9feaa209b219 ruby-magic]$ rake compile no configuration section for specified version of Ruby (rbconfig-x86-linux-2.5.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-2.6.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-2.7.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-3.0.0) no configuration section for specified version of Ruby (rbconfig-x86-linux-3.1.0) /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:69: warning: already initialized constant MakeMakefile::CONFIG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:69: warning: previous definition of CONFIG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:70: warning: already initialized constant MakeMakefile::ORIG_LIBPATH /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:70: warning: previous definition of ORIG_LIBPATH was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:75: warning: already initialized constant MakeMakefile::C_EXT /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:75: warning: previous definition of C_EXT was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:80: warning: already initialized constant MakeMakefile::CXX_EXT /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:80: warning: previous definition of CXX_EXT was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:88: warning: already initialized constant MakeMakefile::SRC_EXT /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:88: warning: previous definition of SRC_EXT was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:93: warning: already initialized constant MakeMakefile::HDR_EXT /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:93: warning: previous definition of HDR_EXT was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:167: warning: already initialized constant MakeMakefile::INSTALL_DIRS /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:167: warning: previous definition of INSTALL_DIRS was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:258: warning: already initialized constant MakeMakefile::CONFTEST /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:258: warning: previous definition of CONFTEST was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:259: warning: already initialized constant MakeMakefile::CONFTEST_C /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:259: warning: previous definition of CONFTEST_C was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:261: warning: already initialized constant MakeMakefile::OUTFLAG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:261: warning: previous definition of OUTFLAG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:262: warning: already initialized constant MakeMakefile::COUTFLAG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:262: warning: previous definition of COUTFLAG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:263: warning: already initialized constant MakeMakefile::CSRCFLAG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:263: warning: previous definition of CSRCFLAG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:264: warning: already initialized constant MakeMakefile::CPPOUTFILE /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:264: warning: previous definition of CPPOUTFILE was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:1361: warning: already initialized constant MakeMakefile::STRING_OR_FAILED_FORMAT /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:1361: warning: previous definition of STRING_OR_FAILED_FORMAT was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2640: warning: already initialized constant MakeMakefile::FailedMessage /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2638: warning: previous definition of FailedMessage was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2713: warning: already initialized constant MakeMakefile::EXPORT_PREFIX /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2711: warning: previous definition of EXPORT_PREFIX was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2731: warning: already initialized constant MakeMakefile::COMMON_HEADERS /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2729: warning: previous definition of COMMON_HEADERS was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2736: warning: already initialized constant MakeMakefile::COMMON_LIBS /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2734: warning: previous definition of COMMON_LIBS was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2741: warning: already initialized constant MakeMakefile::COMPILE_RULES /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2739: warning: previous definition of COMPILE_RULES was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2742: warning: already initialized constant MakeMakefile::RULE_SUBST /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2740: warning: previous definition of RULE_SUBST was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2747: warning: already initialized constant MakeMakefile::COMPILE_C /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2745: warning: previous definition of COMPILE_C was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2752: warning: already initialized constant MakeMakefile::COMPILE_CXX /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2750: warning: previous definition of COMPILE_CXX was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2757: warning: already initialized constant MakeMakefile::ASSEMBLE_C /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2755: warning: previous definition of ASSEMBLE_C was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2762: warning: already initialized constant MakeMakefile::ASSEMBLE_CXX /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2760: warning: previous definition of ASSEMBLE_CXX was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2767: warning: already initialized constant MakeMakefile::TRY_LINK /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2765: warning: previous definition of TRY_LINK was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2774: warning: already initialized constant MakeMakefile::LINK_SO /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2772: warning: previous definition of LINK_SO was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2786: warning: already initialized constant MakeMakefile::LIBPATHFLAG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2784: warning: previous definition of LIBPATHFLAG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2787: warning: already initialized constant MakeMakefile::RPATHFLAG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2785: warning: previous definition of RPATHFLAG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2792: warning: already initialized constant MakeMakefile::LIBARG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2790: warning: previous definition of LIBARG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2797: warning: already initialized constant MakeMakefile::MAIN_DOES_NOTHING /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2795: warning: previous definition of MAIN_DOES_NOTHING was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2798: warning: already initialized constant MakeMakefile::UNIVERSAL_INTS /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2796: warning: previous definition of UNIVERSAL_INTS was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2806: warning: already initialized constant MakeMakefile::CLEANINGS /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2804: warning: previous definition of CLEANINGS was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2840: warning: already initialized constant MakeMakefile::CONFTEST_CXX /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2838: warning: previous definition of CONFTEST_CXX was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2842: warning: already initialized constant MakeMakefile::TRY_LINK_CXX /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2840: warning: previous definition of TRY_LINK_CXX was here Building ruby-magic using packaged libraries. Static linking is enabled. Cross build is enabled. Using mini_portile version 2.7.1 ---------- IMPORTANT NOTICE ---------- Building Ruby Magic with a packaged version of libmagic-5.39. Configuration options: --disable-silent-rules --disable-dependency-tracking --enable-fsect-man5 --disable-shared --enable-static --target\=x86_64-redhat-linux --host\=x86_64-redhat-linux CFLAGS\=-fPIC The following patches are being applied: - 0001-Don-t-attempt-to-build-tests-documentation-and-Python-bindings.patch Extracting file-5.39.tar.gz into tmp/x86_64-redhat-linux/ports/libmagic/5.39... OK Running git apply with /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/patches/libmagic/0001-Don-t-attempt-to-build-tests-documentation-and-Python-bindings.patch... OK Running 'configure' for libmagic 5.39... OK Running 'compile' for libmagic 5.39... OK Running 'install' for libmagic 5.39... OK Activating libmagic 5.39 (from /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ports/x86_64-redhat-linux/libmagic/5.39)... checking for ruby.h... yes checking for -lpthread... yes checking for -lrt... yes checking for -ldl... yes checking for -lcrypt... yes checking for rb_thread_call_without_gvl()... no checking for rb_thread_blocking_region()... no checking for magic.h... yes checking for -lmagic... yes checking for magic_getpath()... yes checking for magic_getflags()... yes checking for utime.h... yes checking for sys/types.h... yes checking for sys/time.h... yes checking for utime()... yes checking for utimes()... yes creating extconf.h creating Makefile /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:69: warning: already initialized constant MakeMakefile::CONFIG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:69: warning: previous definition of CONFIG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:70: warning: already initialized constant MakeMakefile::ORIG_LIBPATH /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:70: warning: previous definition of ORIG_LIBPATH was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:75: warning: already initialized constant MakeMakefile::C_EXT /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:75: warning: previous definition of C_EXT was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:80: warning: already initialized constant MakeMakefile::CXX_EXT /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:80: warning: previous definition of CXX_EXT was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:88: warning: already initialized constant MakeMakefile::SRC_EXT /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:88: warning: previous definition of SRC_EXT was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:93: warning: already initialized constant MakeMakefile::HDR_EXT /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:93: warning: previous definition of HDR_EXT was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:167: warning: already initialized constant MakeMakefile::INSTALL_DIRS /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:167: warning: previous definition of INSTALL_DIRS was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:258: warning: already initialized constant MakeMakefile::CONFTEST /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:258: warning: previous definition of CONFTEST was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:259: warning: already initialized constant MakeMakefile::CONFTEST_C /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:259: warning: previous definition of CONFTEST_C was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:261: warning: already initialized constant MakeMakefile::OUTFLAG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:261: warning: previous definition of OUTFLAG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:262: warning: already initialized constant MakeMakefile::COUTFLAG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:262: warning: previous definition of COUTFLAG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:263: warning: already initialized constant MakeMakefile::CSRCFLAG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:263: warning: previous definition of CSRCFLAG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:264: warning: already initialized constant MakeMakefile::CPPOUTFILE /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:264: warning: previous definition of CPPOUTFILE was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:1361: warning: already initialized constant MakeMakefile::STRING_OR_FAILED_FORMAT /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:1361: warning: previous definition of STRING_OR_FAILED_FORMAT was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2640: warning: already initialized constant MakeMakefile::FailedMessage /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2638: warning: previous definition of FailedMessage was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2713: warning: already initialized constant MakeMakefile::EXPORT_PREFIX /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2711: warning: previous definition of EXPORT_PREFIX was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2731: warning: already initialized constant MakeMakefile::COMMON_HEADERS /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2729: warning: previous definition of COMMON_HEADERS was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2736: warning: already initialized constant MakeMakefile::COMMON_LIBS /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2734: warning: previous definition of COMMON_LIBS was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2741: warning: already initialized constant MakeMakefile::COMPILE_RULES /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2739: warning: previous definition of COMPILE_RULES was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2742: warning: already initialized constant MakeMakefile::RULE_SUBST /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2740: warning: previous definition of RULE_SUBST was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2747: warning: already initialized constant MakeMakefile::COMPILE_C /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2745: warning: previous definition of COMPILE_C was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2752: warning: already initialized constant MakeMakefile::COMPILE_CXX /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2750: warning: previous definition of COMPILE_CXX was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2757: warning: already initialized constant MakeMakefile::ASSEMBLE_C /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2755: warning: previous definition of ASSEMBLE_C was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2762: warning: already initialized constant MakeMakefile::ASSEMBLE_CXX /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2760: warning: previous definition of ASSEMBLE_CXX was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2767: warning: already initialized constant MakeMakefile::TRY_LINK /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2765: warning: previous definition of TRY_LINK was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2774: warning: already initialized constant MakeMakefile::LINK_SO /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2772: warning: previous definition of LINK_SO was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2786: warning: already initialized constant MakeMakefile::LIBPATHFLAG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2784: warning: previous definition of LIBPATHFLAG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2787: warning: already initialized constant MakeMakefile::RPATHFLAG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2785: warning: previous definition of RPATHFLAG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2792: warning: already initialized constant MakeMakefile::LIBARG /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2790: warning: previous definition of LIBARG was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2797: warning: already initialized constant MakeMakefile::MAIN_DOES_NOTHING /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2795: warning: previous definition of MAIN_DOES_NOTHING was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2798: warning: already initialized constant MakeMakefile::UNIVERSAL_INTS /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2796: warning: previous definition of UNIVERSAL_INTS was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2806: warning: already initialized constant MakeMakefile::CLEANINGS /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2804: warning: previous definition of CLEANINGS was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2840: warning: already initialized constant MakeMakefile::CONFTEST_CXX /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2838: warning: previous definition of CONFTEST_CXX was here /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ext/magic/mkmf-upstream.rb:2842: warning: already initialized constant MakeMakefile::TRY_LINK_CXX /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/tmp/x86_64-linux/magic/3.1.0/mkmf.rb:2840: warning: previous definition of TRY_LINK_CXX was here Building ruby-magic using packaged libraries. Static linking is enabled. Cross build is enabled. Using mini_portile version 2.7.1 Building Ruby Magic with a packaged version of libmagic-5.39. Activating libmagic 5.39 (from /home/kwilczynski/Development/Projects/Personal/Ruby/ruby-magic/ports/x86_64-redhat-linux/libmagic/5.39)... checking for ruby.h... yes checking for -lpthread... yes checking for -lrt... yes checking for -ldl... yes checking for -lcrypt... yes checking for rb_thread_call_without_gvl()... no checking for rb_thread_blocking_region()... no checking for magic.h... yes checking for -lmagic... yes checking for magic_getpath()... yes checking for magic_getflags()... yes checking for utime.h... yes checking for sys/types.h... yes checking for sys/time.h... yes checking for utime()... yes checking for utimes()... yes creating extconf.h creating Makefile compiling ../../../../ext/magic/functions.c In file included from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:42, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/int.h:26, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/char.h:23, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic.h:23, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:27, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ../../../../ext/magic/common.h:32, from ../../../../ext/magic/functions.h:8, from ../../../../ext/magic/functions.c:5: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/special_consts.h: In function ‘RB_TEST’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/special_consts.h:148:16: warning: unsigned conversion from ‘int’ to ‘VALUE’ {aka ‘long unsigned int’} changes value from ‘-9’ to ‘18446744073709551607’ [-Wsign-conversion] 148 | return obj & ~RUBY_Qnil; | ^ In file included from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/int.h:26, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/char.h:23, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic.h:23, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:27, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ../../../../ext/magic/common.h:32, from ../../../../ext/magic/functions.h:8, from ../../../../ext/magic/functions.c:5: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘RB_INT2FIX’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:117:29: warning: conversion to ‘long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion] 117 | const unsigned long j = i; | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:119:29: warning: conversion to ‘long int’ from ‘long unsigned int’ may change the sign of the result [-Wsign-conversion] 119 | const long l = k; | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:121:29: warning: conversion to ‘VALUE’ {aka ‘const long unsigned int’} from ‘long int’ may change the sign of the result [-Wsign-conversion] 121 | const VALUE n = m; | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rbimpl_fix2long_by_idiv’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:169:28: warning: conversion to ‘long int’ from ‘VALUE’ {aka ‘long unsigned int’} may change the sign of the result [-Wsign-conversion] 169 | const SIGNED_VALUE y = x - RUBY_FIXNUM_FLAG; | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rbimpl_fix2long_by_shift’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:196:28: warning: conversion to ‘long int’ from ‘VALUE’ {aka ‘long unsigned int’} may change the sign of the result [-Wsign-conversion] 196 | const SIGNED_VALUE y = x; | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rb_fix2ulong’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:255:12: warning: conversion to ‘long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion] 255 | return rb_fix2long(x); | ^~~~~~~~~~~~~~ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h: In function ‘rb_ulong2num_inline’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:326:28: warning: conversion to ‘long int’ from ‘long unsigned int’ may change the sign of the result [-Wsign-conversion] 326 | return RB_LONG2FIX(v); | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long_long.h: In function ‘rb_num2ull_inline’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long.h:53:22: warning: conversion to ‘long long unsigned int’ from ‘long int’ may change the sign of the result [-Wsign-conversion] 53 | #define RB_FIX2LONG rb_fix2long /**< @alias{rb_fix2long} */ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/long_long.h:130:16: note: in expansion of macro ‘RB_FIX2LONG’ 130 | return RB_FIX2LONG(x); | ^~~~~~~~~~~ In file included from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic.h:36, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:27, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ../../../../ext/magic/common.h:32, from ../../../../ext/magic/functions.h:8, from ../../../../ext/magic/functions.c:5: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/st_data_t.h: In function ‘RB_ST2FIX’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/st_data_t.h:61:22: warning: conversion to ‘long int’ from ‘st_data_t’ {aka ‘long unsigned int’} may change the sign of the result [-Wsign-conversion] 61 | SIGNED_VALUE x = i; | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/arithmetic/st_data_t.h:72:24: warning: conversion to ‘long int’ from ‘long unsigned int’ may change the sign of the result [-Wsign-conversion] 72 | return RB_LONG2FIX(y); | ^ In file included from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/assume.h:29, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/backward/2/assume.h:24, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/defines.h:72, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:25, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ../../../../ext/magic/common.h:32, from ../../../../ext/magic/functions.h:8, from ../../../../ext/magic/functions.c:5: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rarray.h: In function ‘RARRAY_PTR’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rarray.h:556:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 556 | return RBIMPL_CAST((VALUE *)RARRAY_CONST_PTR(tmp)); | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ In file included from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:41, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ../../../../ext/magic/common.h:32, from ../../../../ext/magic/functions.h:8, from ../../../../ext/magic/functions.c:5: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/memory.h: In function ‘rb_alloc_tmp_buffer2’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/memory.h:642:56: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘long int’ may change the sign of the result [-Wsign-conversion] 642 | const size_t total_size = rbimpl_size_mul_or_raise(count, elsize); | ^~~~~ In file included from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h:27, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/encoding.h:22, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/io.h:16, from ../../../../ext/magic/common.h:36, from ../../../../ext/magic/functions.h:8, from ../../../../ext/magic/functions.c:5: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h: In function ‘RB_ENCODING_SET_INLINED’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h:82:28: warning: conversion to ‘VALUE’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion] 82 | VALUE f = /* upcast */ encindex; | ^~~~~~~~ In file included from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/assume.h:29, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/backward/2/assume.h:24, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/defines.h:72, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/ruby.h:25, from /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby.h:38, from ../../../../ext/magic/common.h:32, from ../../../../ext/magic/functions.h:8, from ../../../../ext/magic/functions.c:5: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h: In function ‘rb_enc_step_back’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/encoding.h:747:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 747 | return RBIMPL_CAST((char *)ur); | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h: In function ‘rb_enc_is_newline’: /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h:45:33: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 45 | OnigUChar *up = RBIMPL_CAST((OnigUChar *)p); | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/encoding/ctype.h:46:33: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 46 | OnigUChar *ue = RBIMPL_CAST((OnigUChar *)e); | ^ /usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/cast.h:31:29: note: in definition of macro ‘RBIMPL_CAST’ 31 | # define RBIMPL_CAST(expr) (expr) | ^~~~ In file included from ../../../../ext/magic/functions.h:8, from ../../../../ext/magic/functions.c:5: ../../../../ext/magic/common.h: At top level: ../../../../ext/magic/common.h:142:11: fatal error: rubysig.h: No such file or directory 142 | # include | ^~~~~~~~~~~ compilation terminated. gmake: *** [functions.o] Error 1 rake aborted! Command failed with status (2): [/bin/gmake...] /usr/local/rvm/gems/ruby-3.1.0/gems/rake-compiler-1.1.7/lib/rake/extensiontask.rb:181:in `block (2 levels) in define_compile_tasks' /usr/local/rvm/gems/ruby-3.1.0/gems/rake-compiler-1.1.7/lib/rake/extensiontask.rb:180:in `block in define_compile_tasks' /usr/local/rvm/gems/ruby-3.1.0/bin/ruby_executable_hooks:22:in `eval' /usr/local/rvm/gems/ruby-3.1.0/bin/ruby_executable_hooks:22:in `
' Tasks: TOP => compile => compile:x86_64-linux => compile:magic:x86_64-linux => copy:magic:x86_64-linux:3.1.0 => tmp/x86_64-linux/magic/3.1.0/magic.so (See full trace by running task with --trace) ```

I am not sure (yet) why the latter version does not work whereas former works fine. Perhaps a difference in paths? I can't imagine Rake and the rake-compiler Ruby Gem settings something special, however, I need to confirm this.

Sorry for the delay with resolution!

Krzysztof

flavorjones commented 2 years ago

why the latter version does not work whereas former works fine

I believe the difference is between the rvm-installed rubies (just 2.5.9 and 3.1.0) used in the "working" scenario, and the rubies you're compiling against used in the "failing" scenario:

[flavorjones@454e95346e25 ruby]$ cat ~/.rake-compiler/config.yml
---
rbconfig-x86_64-linux-gnu-2.4.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-2.4.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-gnu-2.5.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-2.5.0/lib/ruby/2.5.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-2.5.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-2.5.0/lib/ruby/2.5.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-gnu-2.6.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-2.6.0/lib/ruby/2.6.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-2.6.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-2.6.0/lib/ruby/2.6.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-gnu-2.7.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-2.7.0/lib/ruby/2.7.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-2.7.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-2.7.0/lib/ruby/2.7.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-gnu-3.0.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.0.0/lib/ruby/3.0.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-3.0.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.0.0/lib/ruby/3.0.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-gnu-3.1.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/lib/ruby/3.1.0/x86_64-linux-gnu/rbconfig.rb"
rbconfig-x86_64-linux-3.1.0: "/usr/local/rake-compiler/ruby/x86_64-redhat-linux/ruby-3.1.0/lib/ruby/3.1.0/x86_64-linux-gnu/rbconfig.rb"

Instead of running ruby ext/magic/extconf.rb inside the container, instead run bundle exec rake gem:x86_64-linux:builder and you'll reproduce the issue.

flavorjones commented 2 years ago

@kwilczynski I spent a bit of time this morning trying to build a ruby on my development machine that would reproduce what we're seeing in the RCD image with the xruby 3.1.0, and I can't.

@larskanis Do you have any pointers on where to investigate what's going on here? If you want to get quick reproduction, check out this branch and run bundle exec rake gem:x86_64-linux. This doesn't reproduce with any other Ruby 3.1.0 that I've built, even one built with the same configure options, and I'm struggling to understand what other variables might exist.

larskanis commented 2 years ago

I can reproduce the issue locally. I'll check what's going on.

There's another pkg-config related issue in the x64-mingw-ucrt image of rake-compiler-dock here, but it might be unrelated here.

larskanis commented 2 years ago

xruby-3.0 links to libruby-static, while for some reason xruby-3.1 doesn't. This probably is a bug in rake-compiler-dock. We do some magic there with the libruby files.

A workaround is:

have_library('ruby-static')
have_func('rb_thread_call_without_gvl', 'ruby/thread.h')

Using 'ruby/thread.h' in have_func isn't necessary, but is faster, since it detects the function in the first compiler run, while without it, two runs are necessary.

kwilczynski commented 2 years ago

Hi @larskanis,

Thank you for looking into this!

[...]

A workaround is:

have_library('ruby-static')
have_func('rb_thread_call_without_gvl', 'ruby/thread.h')

This helps!

A slightly different question as I am still, however, puzzled why do we need to add the following explicitly:

have_library('pthread')
have_library('rt')
have_library('dl')
have_library('crypt')

I don't know much about mkmf internals, however, I would imagine that these are default libraries to link Ruby against? Would you happen to know? I wonder if we are doing something wrong here.

Using 'ruby/thread.h' in have_func isn't necessary, but is faster, since it detects the function in the first compiler run, while without it, two runs are necessary.

Interestingly, the extconf.rb appears to be run multiple times. I am not sure why that is. Not the case with Ruby 3.0.x, however.

Krzysztof

larskanis commented 2 years ago

Interestingly, the extconf.rb appears to be run multiple times. I am not sure why that is. Not the case with Ruby 3.0.x, however.

This is because two implementations of mkmf.rb are active. Although ruby-core's mkmf.rb isn't required in your extconf.rb it is already active because of rake-compiler's .rake-compiler-siteconf.rb. See here.

A slightly different question as I am still, however, puzzled why do we need to add the following explicitly:

have_library('pthread')
have_library('rt')
have_library('dl')
have_library('crypt')

That's not intended. Looks like an issue of rake-compiler-dock. I'll investigate it.

flavorjones commented 2 years ago

OK, I've pushed a slimmer changeset, which slims down the patched mkmf.rb to be just the pkg_config() method, and it has two outcomes:

  1. extconf.rb doesn't run multiple times now
  2. the compiler errors no longer happen

:shrug:

flavorjones commented 2 years ago

@kwilczynski Are you waiting on me for anything else related to this? I think it might be good to go.

kwilczynski commented 2 years ago

Hi @flavorjones,

Sorry for the delay!

@kwilczynski Are you waiting on me for anything else related to this? I think it might be good to go.

No. Everything looks good! Thank you so much! Also, thank you for reporting this issue upstream so that everyone else can benefit from the fix/workaround, etc.

To add - everything builds fine, indeed, even though (at least in my case) the extconf.rb seems to be running twice.

By the way, you are a project member with commit bit, thus similarly to @stanhu feel free to close Pull Requests, push commits, etc. I fully trust the two of you, of course. 😄

Krzysztof

stanhu commented 2 years ago

@kwilczynski Looking into why Ruby 2.6 and 2.7 are failing here: https://gitlab.com/stanhu/ruby-magic/-/jobs/2123000713

stanhu commented 2 years ago

I guess a retry fixed it.