undefine

Boris Kolpackov <[email protected]>
Newsgroups gmane.comp.gnu.make.devel
Organization Code Synthesis Tools CC
Message-ID <[email protected]>
Hi Paul, All,

I was investigating why GNU make takes very long to run with my build
system and one thing I noticed is that I have a large number of global
variables and make spends considerable amount of time in hash functions
related the to global variable management. Most of these variables are
temporary in that they are used to store information while a makefile 
is parsed and are not needed after that. Currently I would just assign
an empty value to such variables since there is no way to actually
undefine them. But such a variable is still sitting in the hash table,
just with an empty value. What would be ideal for my situation is a
way to completely undefine a variable.

So I would like to implement a complimentary directive for 'define',
called 'undefine', which will allow to completely undefine a variable:

foo := foo
define bar
bar
endef

undefine foo
undefine bar

$(info $(origin foo))
$(info $(origin bar))

This would print:

undefined
undefined

I made a prototype of this feature and it gave me a 20% speedup.

The only mildly interesting area in the implementation of undefine 
is undefining of a command line variable. I think for this we should 
just use the same approach as with define, i.e., it can only be done
with override:

override undefine CFLAGS

Any thoughts?

Boris

-- 
Boris Kolpackov, Code Synthesis Tools  http://codesynthesis.com/~boris/blog
Open-source XML data binding for C++:  http://codesynthesis.com/products/xsd
XML data binding for embedded systems: http://codesynthesis.com/products/xsde
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.