That is a bit unusual. Usually build-scripts tell linker to seek libXXX.so with parameter -lXXX, but here the parameter is -llibXXX. That is, the “lib” prefix and “.so” suffix could both be implicit.
Regardless, the linker cannot find file libxml2.so. Which package does have such file?
dnf provides */libxml2.so
That command tells that package libxml2-devel.x86_64 has file /usr/lib64/libxml2.so.
Therefore, the dnf install libxml2-devel does indeed put the file into our system.
One must however ask whether a source build is really necessary?
The dnf list \*ruby\* shows multiple “rubygem” packages. None of them provides what this script requires?
The dnf module list ruby shows multiple streams. They might not all contain same set of packages; other version could have more.