Issue #18391 has been reported by vo.x (Vit Ondruch).

----------------------------------------
Bug #18391: Error building gems with binary extensions on Ruby 3.1
https://bugs.ruby-lang.org/issues/18391

* Author: vo.x (Vit Ondruch)
* Status: Open
* Priority: Normal
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Testing Ruby 3.1 on Fedora, it seems that every gem with binary extension fails to build. This is the mkmf.log:

~~~
LD_LIBRARY_PATH=.:/usr/lib64 pkg-config --exists openssl
LD_LIBRARY_PATH=.:/usr/lib64 pkg-config --libs openssl |
=> "-lssl -lcrypto \n"
LD_LIBRARY_PATH=.:/usr/lib64 "gcc -o conftest -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I.    -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection conftest.c  -L. -L/usr/lib64 -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1   -m64   -lruby -lz -lpthread -lrt -lrt -lgmp -ldl -lcrypt -lm   -lm   -lc"
/usr/bin/ld: cannot find -lz
/usr/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */
~~~

and the issue are missing gmp-devel and zlib-devel packages, which were never needed previously. It seems the issue is that `LIBRUBYARG_SHARED` includes `$(MAINLIBS)` since commit:git|372d94b6ba73d85b2c63c70e873a4914bbe9dbad.

Please note that in Fedora, we construct the buildroot from scratch for every package. Therefore while the development dependencies are available during build of Ruby, they are not available during build of other packages. In essence, this is similar to #14422 



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>