I have what looks to be the exact same issue, with the same errors and a very similar log. The issue manifests with both the tarball and with the git repo on the ruby_3_2 branch. I can provide a full log if needed just for quick comparison here are about the same lines as what Martin provided:
building Rust YJIT (release mode)
touch yjit/target/release/libyjit.a
linking miniruby
/usr/bin/mkdir -p enc/jis
+ cp enc/jis/props.h.blt enc/jis/props.h
/bin/sh ./tool/ifchange "--timestamp=.rbconfig.time" rbconfig.rb rbconfig.tmp
rbconfig.rb updated
generating encdb.h
encdb.h updated
generating x86_64-linux-fake.rb
./template/fake.rb.in:19:in `eval': (eval):1: syntax error, unexpected backslash (SyntaxError)
\\# 71 "./version.c" 3 ...
^
from ./template/fake.rb.in:19:in `value'
from ./template/fake.rb.in:24:in `block (3 levels) in <main>'
from ./template/fake.rb.in:23:in `scan'
from ./template/fake.rb.in:23:in `block (2 levels) in <main>'
from /home/zero/.rbenv/versions/3.1.4/lib/ruby/3.1.0/erb.rb:905:in `eval'
from /home/zero/.rbenv/versions/3.1.4/lib/ruby/3.1.0/erb.rb:905:in `result'
from ./tool/generic_erb.rb:36:in `block (2 levels) in <main>'
from ./tool/generic_erb.rb:36:in `block in <main>'
from ./tool/generic_erb.rb:29:in `map'
from ./tool/generic_erb.rb:29:in `<main>'
make: *** [uncommon.mk:791: x86_64-linux-fake.rb] エラー 1
My system is a bit different though: Linux tsuki 6.2.0-24-generic #24-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 16 12:03:50 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
@nobu (Nobuyoshi Nakada) I have attached my version.i. Please let me know if I can provide any more information.
Thank you very much @nobu (Nobuyoshi Nakada). Allow me to confirm that with this patch I have successfully built Ruby on the systems it was not building on previously.