if you sort the make.conf (e.g. sort /etc/portage/make.conf > /tmp/make.conf && mv /tmp/make.conf /etc/portage/make.conf) you will have this order: CFLAGS="${COMMON_FLAGS}" COMMON_FLAGS="-O2 -pipe" So the COMMON_FLAGS var is declared after CFLAGS and then CFLAGS is empty. Emerge --info says: ~ $ emerge --info | grep FLAGS CFLAGS="" CXXFLAGS="-O2 -pipe" FCFLAGS="-O2 -pipe" FFLAGS="-O2 -pipe" And obviously packages are compiled without user's cflags.
So don't sort it.
COMMON_FLAGS isn't even a standard make.conf variable. And if you're going to add new variables for convenience, needing to be set before they're used is a pretty normal thing. If you really wish to be able to sort it, then name it differently (like 0_COMMON_FLAGS) so it gets sorted first and update other variables to use it.
...or actually that's a pretty bad name for it (or at least for bash). I forgot about variables starting with numbers (sorry for double post).
Perhaps you should rename it if you need a sorted make.conf
(In reply to Ben Kohler from comment #4) > Perhaps you should rename it if you need a sorted make.conf I think it does not make sense. The default make.conf comes with COMMON_FLAGS and there is no warning about sorting make.conf, so in my opinion there are 2 choices: 1) Drop COMMON_FLAGS from the default make.conf 2) Make portage to be able to read even if not in a correct order.
I think it's common sense that if I set VAR then reference $VAR on the next line, rearranging the order is going to cause problems. I'm sorry that you got caught by surprise but I think you have several remedies available to you already.
(In reply to Ben Kohler from comment #6) > I'm sorry that you got caught by surprise but I think you have several > remedies available to you already. Personally, I do not use COMMON_FLAGS so there is no problem for me. I reported this bug because while it is common as you said, it should not happen. So a good idea can be drop COMMON_FLAGS from the default make.conf
COMMON_FLAGS was added for a reason. People don't just blindly sort this file and expect it to work. If they need to sort, they know how to work around the problem.
The make.conf format uses a subset of POSIX shell syntax, and sorting the lines like that will give similar results in any POSIX shell. The COMMON_FLAGS setting is generated by catalyst, so I'll reassign to catalyst for consideration.
I made that change in catalyst (with input from several other developers) and I believe it's correct and fine.