Reported in Gentoo as bug 944114
The included getopt.h only declares a proper getopt prototype for glibc and otherwise ("not __GNU_LIBRARY__") declares it as extern int getopt(), which fails to compile with gcc-15.
Simply using the same protoype as for glibc makes it build & work fine - see the patch attached to the aforementioned bug.
Edit: apparently this was fixed long ago in gnulib: coreutils/gnulib@1c64ecc