DragonFly BSD
DragonFly kernel List (threaded) for 2004-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

patch to sync make(1) with FreeBSD-CURRENT


From: Chris Pressey <cpressey@xxxxxxxxxxxxxxx>
Date: Sun, 21 Mar 2004 23:38:29 -0800

Well!  What follows is my report on my insane little weekend project.

I started out wanting to clean up make(1) in the usual style(9) way.

Then I looked at FreeBSD's CVSweb and realized that they've already done
this, but they (perhaps understandably) haven't MFCed it.

Then I realized that there are a whole bunch of bug fixes and
improvements - about 3 years worth - that they haven't merged into
RELENG_4* yet either, and most likely never will.

So I decided to see if I could sync our make with FreeBSD-CURRENT's (as
of this weekend.)  Just for kicks - we don't actually *need* it or
anything, but it might be nice to have the style cleanups and bugfixes,
at least.

It appears to have been a success.  I've done:

- make buildworld
- make -j 4 buildworld
- make installworld
- make kernel
- CCVER=gcc3 make buildworld

with everything going perfectly smoothly so far.  But it would be really
nice (read: an absolute requirement) to find some other brave souls
willing to test it before I would consider submitting it (assuming we
even want it (or parts of it.))

At the bottom of this message is a list of the changes - hopefully all
of them, but there are so many that missing one or two is almost
inevitable.  Many of these are thanks to jmallet, ru, OpenBSD, and
NetBSD.

I realize it's bad form to include style fixes, bugfixes, and feature
additions all in a single patch, but it's a sync.

I also realize it's bad form to include my own changes in a sync, but I
didn't want to just let the comments that were deleted in FreeBSD's K&R
removal go away.  I decided to treat it sort of like taking off a
band-aid -- do it all at once and it'll hurt less.  If it's a really big
problem, I can split it up into a pure sync patch plus other patches.

The patch is a whopping ~450K.  gzip'ed it's still ~112K.  It is
available here:

  http://catseye.webhop.net/DragonFlyBSD/make/

It also needs var.h and var_modify.c (I couldn't figure out how to make
'cvs diff' generate these like 'diff -N' does.)  And list.h can be
removed, it's obsolete.

FTR, this has no relation (that I'm aware of) to what Matt is working on
with make buildworld -j 4.  Might help it, might hinder it, most likely
no change.  Purely a coincidence - as I said, this was just on a whim,
and we don't actually need anything in it.  (Except our bug in
Var_SetEnv that should be fixed regardless, of course - see below :)

-Chris

Changes from FreeBSD
====================

Style
-----
- correction of copyright attribution.
- removal of ``register'' keywords.
- removal of some typos in comments. (one by asmodai :)
- DEBUGF macro to consistently print debugging info to stderr.
- small code code correctness issues thanks to Flexelint.
- refactoring code into new functions and source files.
- int -> size_t where appropriate.
- adding of __unused on parameters where appropriate.
- adding of missing prototypes.
- removal of relatively useless efree() function.
- one-use variable -> constant.
- ClientData -> void *, NIL/NILST/NILGNODE -> NULL
- STD{ERR,IN,OUT}_FILENO instead of their numeric values
- extern protoypes -> header files
- no more pre-__STDC__-isms (varargs.h, etc)
- make sure variables are initialized
- some never-used (#if 0) code removed

Bugfixes
--------
compat.c:1.26 - "Make the -q option DTRT in the compat mode."
cond.c:1.26 - "Fixed broken arithmetic expression parser."
cond.c:1.27 - "Consider a variable empty when not defined."
dir.c:1.32 - "Fix a bug that prevented exists() from finding "foo/",
              "foo/." and "foo/.." when ".PATH: foo" was also given."
dir.c:1.31 - "[Make] the -C option DTRT."
main.c:1.75 - "Reference the correct local variable in all parts of a
               for loop, so we operate on the correct data (properly)."
for.c:1.20 - "Command line variables take precedence over global
              variables [...] in the .for loops too."
main.c:1.74 - "stop there from being more than 500 processes forked by
               make(1), to prevent a forkbomb"
???:?.??? - "MAXPATHLEN includes the trailing NUL.  Correct array sizes
             to reflect this.  Correct NUL termination after strncpy."
main.c:1.49 - "unifdef -UWANT_ENV_PWD [...] bugfeature."
parse.c:1.49 - "correct the include path handling for SysV style"
parse.c:1.37 - "Fix a bug [...] which caused an example Makefile [...]
                to report a variable as being recursive."
str.c:1.28 - "Fixed broken logic when parsing double quotes."
var.c:1.44 - "Fix a bug in variable parsing code that could cause a
              segfault."
var.c:1.42 - "Change the handling of non-anchored global substitutions
              [...] to a non-silent explicit fatal error."
var.c:1.41 - "Prevent infinite substitution of the empty string by
              forcing non-global substitution."
var.c:1.40 - "changes failure cases which would have died horrid deaths
              to explicit clean death[s]"
var.c:1.37 - "When expanding a specific [1-char] variable [...] Don't
              just automatically expand something which starts with that
              character."
var.c:1.28 - "Fix a memory leak [using strdup and free appropriately]"
var.c:1.27 - "Possibly expand the variable name's embedded variables
              before using it [averting possible infinite loop]"

Features
--------
config.h:1.10 - "Allow use of the ${MAKE_SHELL} variable to specify
                 alternate shells for make(1) to use."[1]
for.c:1.20 - "print the useful line number on error in the .for loop"[2]
job.c:1.44 - "Give make(1) the ability to use KQUEUE to wait for worker
              processes instead of polling for them."[3]
job.c:1.34 - "Prefer BSDmakefile over makefile and Makefile."
main.c:1.86 - "Install a SIGCHLD handler so select(2) will be
               interrupted when a child terminates."
job.h:1.21 - "Change the select timeout from 100ms to 2 seconds now
              that SIGCHILD is handled."
main.c:1.59 - "Added the MAKE_VERSION global that could be useful in
               determining if a given make(1) is feature-compatible
               with a set of makefiles."[4]
parse.c:1.52 - "Make it possible to ``.undef ${VAR}'' (expanding VAR to
                get the variable name to undef)."
parse.c:1.38 - "Print a warning when we are given two scripts for one
                target."
parse.c:1.35 - "Provide a heuristic for RCS conflicts."
targ.c:1.22 - "When formatting the time for a target, use %H instead of
               %k"
var.c:1.46 - "Allow variable substitutions in SYSV variable
              substitutions like $(SRC:.c=$O)."
var.c:1.43 - "Implement the O modifier [which] sorts the words in a
              variable."

Additional Stuff I did in the Process
=====================================

Style
-----
- changed #include <sys/signal.h> to <signal.h> in main.c.
- added missing prototype for catch_children in main.c.
- changed an ARGSUSED to an __unused.
- retained some comments that were deleted in FreeBSD's K&R removal.
- did what I could to improve lacking comments in other ways.
- removed list.h (100% obsolete compat header).
- no space after function name (function definitions only).
- applied style(9) rules to #include ordering and spacing.
- no formfeeds in source code!!

Bugfixes
--------
- fixed an obviously erroneous statement in DragonFly's var.c:
  in Var_SetEnv:  v->flags | VAR_TO_ENV;  (the | should be a |=)
- trivial stop-a-NULL-pointer-derefence-from-making-make-dump-core
  bugfix which I submitted to FreeBSD (but which they haven't done
  anything with yet): PR 63405.


[1] sh, ksh, or csh, with the caveat that csh makes little sense.
[2] This is the newest change, only 8 days old.  The age of most other
    changes can be measured in months, and some of them have in fact
    been MFC'ed.
[3] This breaks in the kernel, apparently, so is not enabled by default.
[4] I haven't set a particular MAKE_VERSION for DragonFly, though.



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]