Subject: Changes to crunchgen
To: None <tech-toolchain@netbsd.org, tech-ports@netbsd.org>
From: James Chacon <jchacon@genuity.net>
List: tech-ports
Date: 10/03/2001 16:01:47
With the recent toolchain changes (USE_NEW_TOOLCHAIN) and some recent changes
to crunchgen a major deficiency crops up in how crunchgen works today.

It attempts to use the current object files (if they exist) to build the
crunched image. Well, this is bad since most of those were built with
optimizing cflags (i.e -O2) instead of something which tries to produce the
smallest code possible (-Os or equiv).

Them temporary work around to this was to cause each crunched object to nuke
it's already existing objects and rebuild them all with DBG=-Os.

This also is suboptimal since the crunchgen version of say /bin/cat shouldn't
be modifying the build results from the normal src/bin/cat in it's src/objdirs.
This results quite possibly causing a rebuild later on of the regular binary
to end up with a mix of .o's with various optimizations set.

So, what I'm about to check in are mods to crunchgen which do the following:

Add a -d option to set the DBG flag to whatever flags the builder wants. If
it's not set, default to -Os (so it's not hard coded into the binary.)

Generate a makefile by default that does all object file builds in local
subdirs by binary (i.e. bad144 gets built in $OBJDIR/bad144) via a reach over
make. (Sets .PATH and .CURDIR and does a make for the objects needed in that
dir).

Add a -o option that does the old behavior of searching for obj files by
querying the various object environment vars and searching. Without this
option none of the objdir special options, environment vars, etc will have
effect.

In both cases the special options objpaths, objs, etc still work as they always
have.

I've tested this for all the x86 ramdisks and it all builds fine (installboot
has some issues but thats local to it's Makefile I'll fix also).

If folks have concerns, changes, etc they'd like to see with this please let
me know. This shouldn't affect most ports snapshot builds unless it's 
building a program that doesn't have a makefile which behaves to

make <object file list>

(only 1 so far I've found had this issue).

I've also noticed most builds are building libhack with -O2 but everything
else with -Os so that should be adjusted in those ramdisk builds as well.


James

(BTW: crunchgen should probably go into tools since it's not likely to be
native on foreign systems or in the case of changes such as this work with
a build in all cases).