Patch from https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bc2ba1cd6fdc5a7ad7d161efb21652b73c6b207e