It is often favourable to keep debugging information for certain packages.
Gentoo allows to keep those symbols by adding
CFLAGS="${CFLAGS} -ggdb" CXXFLAGS="${CXXFLAGS} -ggdb" FEATURES="${FEATURES} splitdebug"
to your make.conf
But this enables debugging information for all packages. In order to keep debugging symbols only for certain packages, you can define a splitdebug environment in /etc/portage/env/
/etc/portage/env/splitdebug.conf:
CFLAGS="${CFLAGS} -ggdb" CXXFLAGS="${CXXFLAGS} -ggdb" FEATURES="${FEATURES} splitdebug"
Now you can add your packages to /etc/portage/package.env:
sys-libs/glibc splitdebug.conf
So when compiling glibc, portage will use the splitdebug environment and keep debugging symbols.