Portage sets KV environment variable for every portage build (see ebuild.sh). However, this is a bit expensive, since there is an external awk/Python script involved, as well as the first few lines of /usr/src/linux/Makefile being parsed to extract the information. While I think that this is definitely the right way to determine the kernel version, as opposed to seeing where the symlink points (thanks to Jon Nelson), it is inefficient to set KV for building packages that don't need to know installed kernel version. I propose that instead of setting KV universally we provide a stand alone script to do the same job, which can be invoked as needed. This was the original idea when KV was introduced as response to bug 599, but for some reason it materialized as an environment variable. Since implementing this is trivial, I'm attaching no patch.
Hiya drobbins. Could you please provide one line's worth of reasoning for closing this bug?
jnelson coded a "lighter than before" solution that doesn't rely on starting another process. It still uses KV, but it's light enough for me. Also, this is definitely not a performance bottleneck for the Portage code so it makes no sense to optimize here.