since couple of releases, compiling ROOT on a machine with 12 GB of RAM is impossible. Linking of RIO takes more than 11 GB of RAM. I am speaking about using g++ compiler.
I was finally able to link it by changing linker to mold. Do you have perhaps similar observations?