Faster builds, smaller footprint, zero functionality!

This is the story of the day I decided that it would be a good idea to get my static analysis builds to stop linking, since I only care about the dehydra output produced by gcc.  I hear lots of people complain about how hard it can be to get the build system working.  I'm here to tell you that it can be quite difficult to make it not work.

The first idea was to write a wrapper around ld so it would just create a file, but not actually do the linking.  I wrote a little bash script ( to do it:

args=`getopt o: $* 2> /dev/null`  
set -- $args  
for i  
    case "$i"  
            touch "$2"; shift;  
            shift; break;;  

Next I set the LD environment variable (export LD=/path/to/ and rebuilt.  No dice.  Turns out we link via CXX, which I'd forgotten.

No problem, just change the value of MKSHLIB to:

touch $@; echo

But how?  After trying and failing about 6 different ways via my mozconfig, Benjamin had the answer: use

MKSHLIB=touch $@; echo  
MKCSHLIB=touch $@; echo

Stick that in objdir/config and rebuild...but:

Cannot mmap file ../../../dist/bin/components/

This turns out to be related to the fact that I'm doing an opt build, which means elf-dynstr-gc wants to do things with the resulting .so files, which are now empty. One more mozconfig change and we're rocking (see details in

ac_add_options --disable-elf-dynstr-gc

And now it works! But is it faster? I'm not sure, as dehydra is now asserting on nsRuleNode.cpp since I updated my tree, but I can blame Taras for that and safely conclude this experiment. It certainly isn't any slower, unless you count the time I've wasted getting this silly thing to work.

So if you ever find yourself in need of a build that doesn't actually create anything, you'll know what to do :) Thanks to Ted and Benjamin for putting up with me, as usual.  Never let it be said that our build system is easy to break!

UPDATE: "but what about..." so indeed there are few sharp edge cases that I missed.  First of all, as is always the case with my analysis work, I need to special case nss, which has its own ideas of how the build should happen.  MKSHLIB needs to be replaced there too (i.e., you could do it in security/coreconf/ or one of the OS specific includes).  Next you need to deal wtih the fact that shlibsign wants to do secure things to the binaries, which now don't exist.  To get past this set SKIP_CHK=1 in your environment.  Which brings us to xpcshell, that still wants to use $(LD) to link the binary, in which case above can help you.

Show Comments