Issue
I'm filing this as a follow-up to https://bugzilla.redhat.com/show_bug.cgi?id=2216918, where you can find some background, especially in #c42.
The gcc-toolset-12 in Centos Stream 9 is affected by https://bugzilla.redhat.com/show_bug.cgi?id=2111976. As a consequence, if one uses gcc-toolset-12 in rpmbuild, the build fails with:
cc1plus: fatal error: inaccessible plugin file /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/plugin/gcc-annobin.so expanded from short plugin name gcc-annobin: No such file or directory
The bug has been fixed in gcc-toolset-12-12.0-6.el9 which is present in RHEL 9 but somehow didn't land in Centos Stream 9. Re-aligning the package with RHEL 9 would fix the problem.
Please note that using gcc-toolset-12 in rpmbuild isn't a common practice and if one really needs a newer-them-system-GCC then gcc-toolset-13 can be used instead. It is already present in Centos Stream 9 and doesn't suffer from this particular bug. In other words, I believe there's a workaround available.