I have had problems compiling gdm recently because i used a separated CFLAG for some work, I called this variable COMMON_CFLAGS, when looking through the gdm build logs i noticed the -I parameters were missing, instead there were double CFLAGS in the build parameters. Unsetting COMMON_CFLAGS fixed the issue. I think its something to be aware since COMMON_CFLAGS should not be defining include parameters, basically a bad paradigm. Maybe this can be unset in the ebuild or there should be created a patch to fix this?
you should use the variable locally for your project. read https://www.tldp.org/LDP/abs/html/subshells.html https://unix.stackexchange.com/questions/138463/do-parentheses-really-put-the-command-in-a-subshell