[Buildroot] [PATCH 07/28] barebox: use = instead of := and re-indent

Peter Korsgaard jacmet at uclibc.org
Tue Jul 5 21:04:58 UTC 2011


>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni at free-electrons.com> writes:

Hi,

 >> Using '=' evaluates the assignemnt every time it is referenced, which
 >> can be a little bit costly when there are tons of them (like in
 >> buildroot); while using ':=' does the evaluation only once, at the
 >> time of the assignment, not evaluation.
 >> 
 >> I agree that the code should be homogeneous, but I'd think it should
 >> be fast as well. He, if I can get butter, buter's money, and a litle
 >> smile from the dairywoman! ;-)

 Thomas> Then, we should state that those variables must all be defined with :=
 Thomas> all over the place and enforce this decision. In the mean time, I will
 Thomas> drop those modifications from my patch set.

:= is only a performance advantage if variables are expensive to expand
(use) and are used more than once - E.G. stuff involving $(shell) and
similar, like the UPPERCASE macro we had calling tr.

= has a number of advantages though. As it only gets expanded at the
last possible moment you don't have to take care about variable
ordering, E.G. when you use a variable like LIBGLIB2_HOST_BINARY on
another package, whereas with := you do. This can also be interesting
when the variable contains $(shell) or other functions, as you might
only want to execute them if/when they are needed, and not right away
when the Makefiles are parsed.

I would prefer to use = by default, and only use := where it matters for
correctness or performance.

-- 
Bye, Peter Korsgaard



More information about the buildroot mailing list