Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 699298 - a sorted make.conf produces an empty CFLAGS variable
Summary: a sorted make.conf produces an empty CFLAGS variable
Status: RESOLVED WONTFIX
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: Gentoo Catalyst Developers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-04 10:07 UTC by Agostino Sarubbo
Modified: 2019-11-10 18:59 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2019-11-04 10:07:48 UTC
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.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2019-11-04 10:21:30 UTC
So don't sort it.
Comment 2 Ionen Wolkens gentoo-dev 2019-11-04 11:37:05 UTC
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.
Comment 3 Ionen Wolkens gentoo-dev 2019-11-04 11:46:38 UTC
...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).
Comment 4 Ben Kohler gentoo-dev 2019-11-04 13:16:34 UTC
Perhaps you should rename it if you need a sorted make.conf
Comment 5 Agostino Sarubbo gentoo-dev 2019-11-04 13:21:58 UTC
(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.
Comment 6 Ben Kohler gentoo-dev 2019-11-04 13:25:36 UTC
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.
Comment 7 Agostino Sarubbo gentoo-dev 2019-11-04 13:58:25 UTC
(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
Comment 8 Ben Kohler gentoo-dev 2019-11-04 13:59:48 UTC
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.
Comment 9 Zac Medico gentoo-dev 2019-11-04 16:25:14 UTC
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.
Comment 10 Ben Kohler gentoo-dev 2019-11-04 16:26:18 UTC
I made that change in catalyst (with input from several other developers) and I believe it's correct and fine.