make and make install rebuild items every time unnecessarily - sometimes causing races in parallel installs
The makefiles are written in a way that a few items are regenerated on every invocation of make, even if nothing changes, including, actually libruby.so. This would've been ok, but from ruby 3.1 onwards it started to cause races in parallel make installs, where items in capi/ext/ and libruby are re-linked at the same time, causing capi/ext ones to fail the linking step. This is how it looks like:
| building spec/ruby/optional/capi/ext/integer_spec.so | ../ruby-3.1.0/revision.h unchanged | generating enc.mk | building spec/ruby/optional/capi/ext/proc_spec.so | compiling enc/encinit.c | linking shared-library libruby.so.3.1.0 | ./libruby.so: file not recognized: file format not recognized | collect2: error: ld returned 1 exit status | ../ruby-3.1.0/defs/gmake.mk:413: recipe for target 'spec/ruby/optional/capi/ext/proc_spec.so' failed | make: *** [spec/ruby/optional/capi/ext/proc_spec.so] Error 1 | make: *** Waiting for unfinished jobs.... | linking ruby
To reproduce, configure with --enable-shared, and run 'make' several times.