Commit Graph

714 Commits

Author SHA1 Message Date
dsl
9f624ea07b Instead of trying to report all the 'job suspended' and 'job resumed'
messages whan make itself is suspended (ie by ^Z) before make actually
suspends, supress the messages during this sequence.
This means we don't care that they would be output after the suspend
and we can stop attempting to reap child status from withing the signal
handler (which doesn't work for recursive parallel makes).
The code simplification means that we can remove much of the code that
blocked signals - since the signal handlers (expect that for ^C and friends)
now do almost no work.
2006-10-09 13:40:11 +00:00
peter
e263dfd62f WFORMAT is no more... 2006-10-08 17:52:28 +00:00
dsl
a178085551 Reap any dead children that we have at startup.
If there are any undead ones set a flag so we don't report the 'Child (pid)
not in table' message when they die - it is impossible to (portably) find
the childrens pids.
This happens when make is run as 'make -f- ... <<EOF' and the shell uses
a child of (what will be) make to write the data into a pipe.
2006-09-29 19:38:48 +00:00
dsl
56564e27f6 Complete revamp of the way make handles job control signals.
- Send each type of signal to its own handler.
- Only call JobFinish when a process exits, in particular don't 'fake up'
  'exitstatus' for jobs being continued, nor call it for suspends.
- When a job is stopped, use an entire variable to remember the fact, so
  we know we need to send a SIGCONT.  Don't change any other state.
- In order to report '*** [job3] Suspended' before we suspend ourselves we
  have to call waitpid() from the signal handler - where we don't want to
  process job termination events. Save the exit status and process later.
The code now handles:
- jobs that suspend themselves
- jobs exiting while suspended
- jobs that don't actually suspend at all
Hoewever it still does printfs() from the signal handler, and I haven't yet
stopped it thrashing the signal mask.
2006-09-23 20:51:28 +00:00
dsl
7adfa633e3 Fix build on 64 bit systems.
Remove now-unecessary temporary local.
2006-09-22 21:55:52 +00:00
dsl
11d35f72b2 Replace the two lists 'job_list' (previously 'jobs') and 'stoppedJobs'
with a table that is malloced with 'maxJobs' entries.
Add a 'job_state' field to the Job type that exactly follows which of
the old lists the job was on (or not).
Change all the code that scanned the lists to scan the array.
No logic changes in this commit.
(Soon we'll no longer need to lock out signals for the changes to job
statuses that are done from signal handlers now that there is no linked list.)
2006-09-22 19:07:09 +00:00
dsl
edb0aa98de Rename the variable 'jobs' to 'job_list' in preparation for making it an array. 2006-09-21 19:56:05 +00:00
christos
55ee861f25 protect libutil with HOSTPROG 2006-08-29 16:54:03 +00:00
christos
03eff0d591 Fix non-native build. 2006-08-26 22:19:03 +00:00
christos
623c0a861f Don't include <util.h> if we are not NetBSD. Other OS's don't have it. 2006-08-26 22:13:00 +00:00
christos
cdab3a7a06 More programs using efun. 2006-08-26 18:17:41 +00:00
christos
67a75c5772 If a word is "" eat the last quote since we ate the first. 2006-08-11 19:11:00 +00:00
sjg
7ab69f08a8 Indicate which modifier a result applies to, helps debug complex cases. 2006-07-28 17:08:55 +00:00
sjg
ba9f975490 Add debug output for CondDoExists() - the results can be surprising. 2006-07-28 17:07:33 +00:00
sjg
772ecb66aa Fix minor mem leak in PrintOnError(). 2006-07-28 17:06:14 +00:00
rillig
9edce8b593 Fixed gcc warnings about signed vs. unsigned in comparisons. 2006-06-29 22:02:06 +00:00
rillig
a3ea8b9d59 Fixed the bug reported in PR 33866, which is that the :Q operator does not
handle newlines correctly. Ok'ed by christos.
2006-06-29 22:01:17 +00:00
reed
c5f16e7060 Fix mispelling. 2006-06-17 02:06:17 +00:00
skrll
f1713aebe3 Remove a hack that's no longer needed with gcc 3.3.6. 2006-06-15 10:55:02 +00:00
christos
236f8aef2c Coverity CI D3758: Plug memory leak. 2006-05-19 17:29:01 +00:00
christos
19d4b5c5e9 Coverity CID 3757: Plug memory leak. 2006-05-19 17:27:06 +00:00
christos
ffbb87954b Coverity CID 3147: Plug memory leak. 2006-05-19 17:21:46 +00:00
sjg
fc23c7c758 Remove the modterm case from moderrs, the syntax errors
generated by /bin/sh on other systems are not consistent.
2006-05-11 18:48:33 +00:00
sjg
03cbcf6532 Extract the variable modifier logic to a separate function.
This cuts Var_Parse in half! and allows the modifier logic to
be used recursively - when getting modifiers via variables.

Add new unit-test, to check that certain error cases are handled
correctly.
2006-05-11 15:37:07 +00:00
he
b28792d8d4 Our gcc 3.3.3 (nb3) for hppa gets an "unrecognized insn" internal
compiler error when building buf.c with -O2, so reduce optimization
level to -O1 for this single file.
To be documented in docs/HACKS, discussed with skrll.
2006-05-08 11:07:57 +00:00
christos
3d5b8ce5a8 Coverity CID 529: Call VarFreeEnv to prevent leak. 2006-04-22 19:40:40 +00:00
christos
ac5c384e1b Coverity CID 534: Free junk variables on return from Var_Parse. 2006-04-22 19:32:35 +00:00
christos
bb46846e03 Coverity CID 533: Plug memory leak.
Add a new function VarFreeEnv() to free environment variables and use it.
2006-04-22 19:28:51 +00:00
christos
58c48be0b3 Coverity CID 526: Check for condTop < 0 where we decrement it, not later
when the damage is already done.
2006-04-22 18:53:32 +00:00
christos
1c603f6321 Coverity CID 527: Make it painfully obvious that av is freed. 2006-04-22 18:48:46 +00:00
christos
0f515a9e28 Coverity CID 528: Avoid NULL deref. 2006-04-22 18:47:10 +00:00
christos
f2f8f4c25a Coverity CID 530: Don't leak the argument vector. 2006-04-22 18:43:06 +00:00
christos
1456136e74 Coverity CID 523: Fix off by one mistake. 2006-04-22 18:38:38 +00:00
sjg
d7df397808 Change ReadMakefile to return 0 on success so that it better meets
the expectations of Lst_Find*.  This way we only read the first sys.mk
found via sysIncPath.
At the same time we need to add a ReadAllMakefiles() for the case
where multiple -f makefile args are provided (uncommon, but documented).
2006-04-12 20:32:27 +00:00
christos
8533275dab Remove bogus debugging code I accidentally committed. 2006-04-02 00:15:53 +00:00
christos
e052a053e4 Add some coverity allocation comments, and change the way the allocator
functions work. When they allocate storage that needs to be freed, instead
of setting a boolean, set the pointer to be freed. Plug some more memory
leaks found by inspection.
2006-03-31 21:58:08 +00:00
dsl
33369a0245 There is no need to count jobs and job tokens.
If we don't create the job pipe, use the '-j n' option to limit the number
of tokens we will remove from the pipe.
2006-03-31 21:05:34 +00:00
christos
ec5cc02622 Coverity CID 544: Fix memory leak. 2006-03-31 20:30:46 +00:00
ginsbach
a8cd0ffcee - Change where variable substitution is done when processing traditional
include statements so that if a variable expands to more than one file
  name make will "do the right thing".
- Add additional debug print

Reviewed by christos.
2006-03-28 17:41:35 +00:00
wiz
59ba5fe8d1 New sentence, new line. 2006-03-19 10:45:03 +00:00
sjg
98b766c482 Fix :P modifier so it actually works as described.
I.e ${var.c:P} should expand to the absolute path of var.c found via .PATH
2006-03-19 01:54:21 +00:00
sjg
8af5ec82ab Document an interesting kwirk in := handling of undefined variables. 2006-03-19 01:53:01 +00:00
christos
75f03570ec Coverity CID 2719: argvalue can be NULL when passed into functions.
De-obfuscate by undefining optarg, and check explicitly for NULL before
use.
2006-03-17 15:39:44 +00:00
dsl
5f31eae781 nJobs and jobTokensRunning are both counting the same thing.
Kill nJobs and just use the count of tokens in use.
Don't eat job tokens when we are ignoring errors.
2006-03-15 20:33:19 +00:00
dsl
f26d89e3d9 JOB_FIRST is always set (since we only execute the shell once for every
target). Nuke it.
2006-03-13 20:35:09 +00:00
dsl
b85c051fa8 Remove the 'never non-NULL' 'previous' argument to JobStart.
Looks like it was intended as a minor (and pointless) optimisation to
remove a free() malloc() pair.
Make he comment about the stoppedJobs list more correct.
2006-03-12 20:14:56 +00:00
dsl
a484dfd693 It isn't possibly to execute any part of job.c that references compatMake
when it is 'true'.  So delete the unexecutable code.
2006-03-12 19:14:51 +00:00
dsl
c9b3912b1e Remove most of the code seemed to be there to support 'remote jobs'.
It isn't clear that it ever worked, if it did it has almost certainly
bitrotted in the last 12 years.  I'm not even sure all the required
components were present.
I suspect it was written to attempt to use a 'farm' of diskless sun3s.
In any case the apparant random assignment fo jobs to other systems doesn't
actually seem like a good idea!
Things like 'distcc' han be used to help slow systems run native builds.
Removing this code also simplifies make, and should let me speed up some of
its processing - without worrying about bitrotting it further.
2006-03-11 17:18:00 +00:00
wiz
904496fbc8 Markup fixes. 2006-03-11 12:02:20 +00:00
christos
5e6b1075e2 PR/33049: OKANO Takayoshi: Fix the spelling of NetBSD RCS tags. 2006-03-10 15:53:55 +00:00
dsl
5e60bf00ce Avoid calling JobRestartJobs() from the SIGCONT signal handler, instead
push a byte through the (now badly named) exit_pipe and call JobRestartJobs()
from the main code path when poll() wakes up.
Part of a plan to remove JobSigLock() and the zillions of system calls
it does.
2006-03-08 22:11:48 +00:00
apb
f34c12e989 Make ".WAIT" apply recursively to all children of nodes on the right
hand side of the .WAIT, except when the recursive interpretation would
cause a cycle in the dependency graph.

Discussed in tech-toolchain.  Reviewed by christos, sjg.
2006-02-26 22:45:46 +00:00
wiz
3ea7f78b57 Fix typo. 2006-02-26 22:40:50 +00:00
sjg
701c9d99a7 Using ./bin in the test case, causes problems when 'make test' is
run from 'unit-tests' rather than the parent dir.
2006-02-26 22:20:55 +00:00
sjg
2bc18a45e6 Update man page and add test case for specifying modifiers via variable.
Also allow said variable to appear anywhere in the modifier list.
2006-02-26 21:43:00 +00:00
tsutsui
8c30474280 Don't use data in freed stack. 2006-02-18 04:10:05 +00:00
sjg
051abc7bc4 Allow variable modifiers to be specified via variable. 2006-02-18 01:29:27 +00:00
sjg
555fff313b Fix enum for better portability 2006-02-18 01:28:48 +00:00
apb
c5bdb87cca Escape dots in sed regexps. Without this patch, and without
an OBJDIR, "make test" in usr.bin/make fails.
2006-02-13 18:17:36 +00:00
dsl
2bfcea2ea3 Add some more debug prints. 2006-02-11 20:59:49 +00:00
dsl
e99202b6cf Actually SIG_DFL the correct signal (not SIGINT every time) just prior to
exec'ing a program in the child.
2006-02-11 20:58:53 +00:00
dsl
26ed52262a Delete obsolete static defn.
Trace number of unmade children on pass 1
2006-02-11 20:19:36 +00:00
dsl
49c83bef6a Debug trace all the targets we are actually intending making.
De-optimise the getting of a job token so we don't re-order the job
list when there are no tokens.
This might have helped etc/Makefile, but isn't enough.
2006-02-11 18:37:36 +00:00
dsl
de841c2752 Make .NOTPARALLEL stop the job engine issuing more than one token (instead
of trying to de-jobify the make.
You can now put .NOTPARALLEL in a submake of a recursive make (where it is
using a job-token pipe from the outer make and have it only run a single job.
You can also specify .NOTPARRALEL in the root makefile of a large recursive
make and have the submakes run multiple commands.
Add some diagnostics printfs (enabled with -dp) to the parser.
2006-01-22 19:54:55 +00:00
dsl
363c3a143d Check the 'job_pipe' for the error token 'E' before every job, including
the first one for each make.  This significantly speeds up the detection
of errors in other branches of the make (ie those running in a different
make process).  The cost of reading and writing a byte from the pipe
should be insignificant.
Defer replacing job tokens until we've decided there is an error.
If we detect an error in another branch of the make, then call Fatal(),
setting 'aborting' and failing to return a token leads to infinite loops.
Now parallel makes actually stop with the failing command on the screen.
2006-01-21 19:18:37 +00:00
dsl
8cc9d75901 Include the 'preds' and 'successors' in the diag output.
These are the values that are actually used to control what is built.
(I suspect .WAIT info added in the previous delta isn't always useful.)
2006-01-08 17:43:31 +00:00
dsl
07c6949e33 Don't (try to) use files marked .OPTIONAL as implicit sources.
There existance hasn't been verified at the point the implicit rules are
checked.
2006-01-08 12:59:52 +00:00
dsl
94a49912ba Include .WAIT in the debug output for dependency lists. 2006-01-08 11:54:13 +00:00
dsl
913c34c213 Expunge last references to jobTokensFree 2006-01-04 21:35:44 +00:00
dsl
1f61a1399d When a parallel make job completes, always put the job token back into the
job_pipe and collect another one for the next job.
If we are aborting, remove all the 'normal' job tokens and add an 'error' one.
If we get an 'error' token, remove any other tokens, re-insert the error
token and exit (with error 'cos that is easier).
Add the current pid to some of the DEBUG(JOB) traces.
Combined effect is that parallel makes actually stop some fairly shortly
after an error, rather than running on long enough to fill the scrollback.
2006-01-04 21:31:55 +00:00
dsl
261501b75e F_DUPFD the job_pipe fds onto higher numbers (>15) to make it less likely
that they will get closed in a complex recursive parallel make.
2006-01-04 21:25:03 +00:00
dsl
68ab653c0c For parallel makes, don't recycle the job token when we decide not to
run anything.
2006-01-04 21:16:53 +00:00
dsl
12dafa0b4a If -s (silent) is specified, don't output the target name before target
output in parallel makes.
After all with -s you wouldn't know the command for a non-parallel make.
Makes (sic) the output of parallel NetBSD build fathomable.
2006-01-04 20:56:05 +00:00
perry
0f0296d88a Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:45:08 +00:00
christos
efc9df200f PR/31077: Wil L: /usr/bin/make can read off of end of buffer 2005-08-27 08:04:26 +00:00
christos
abefed98a7 Add typedefs for DuplicateProc and FreeProc from Max Okumoto. 2005-08-09 21:36:42 +00:00
christos
81b135acdf From Max Okumoto:
- Remove casts to NULL.
- Remove space between cast and object.
2005-08-08 16:42:54 +00:00
christos
6240774069 More KNF cleanups from Max Okumoto 2005-08-05 00:53:18 +00:00
christos
9f80093159 remove unnecessary casts to void * functions (Max Okumoto) 2005-08-04 00:20:12 +00:00
christos
62a6753895 from Max Okumoto: debug should be int, not boolean. 2005-08-03 20:55:01 +00:00
christos
b3350d3e14 Remove unused files. From Max Okumoto. 2005-07-30 00:49:13 +00:00
christos
3692d77541 Whitespace KNF cleanup from Max Okumoto 2005-07-25 22:55:58 +00:00
sjg
c3c1fc597e Expected results were not updated for comment testing. 2005-07-11 17:55:19 +00:00
christos
3d520edd5e PR/29985: Roland Illig: make(1) interprets backslash wrongly in for
loop expansions, when the expanded variable ends in backslash and
the backslash is the last character on the line. While this fix is
ugly (detect the condition and append a space), it is the least
intrusive for now.
2005-07-01 16:45:38 +00:00
christos
b775b6932a Don't apply .DEFAULT commands to special targets (.BEGIN, .END, .INTERRUPT). 2005-06-29 19:59:42 +00:00
wiz
3051d76108 Consistency. Use Pp instead of br. 2005-06-27 09:51:09 +00:00
lukem
2bf924f405 Restore the rework from rev 1.115 and expand the description of .OBJDIR
to document the behaviour that is currently in use (the "./obj" and
"/usr/obj/`pwd`" behaviour).
Hopefully the existing .OBJDIR behaviour is clearer now.
2005-06-27 00:17:08 +00:00
wiz
47fb7786c1 Since the obj dir handling changes in the code have been
reverted, revert them in the man page too (i.e., revert v1.115).
2005-06-26 10:14:43 +00:00
lukem
50e70cd0ee revert previous for now 2005-06-24 04:33:25 +00:00
lukem
62955ed1ec Revert rev 1.110 and restore the previous "automagic objdir" support;
at least until we clean up the objdir semantics in <bsd.obj.mk> for
NetBSD builds.
2005-06-24 02:53:27 +00:00
lukem
a6a204d392 Deprecate support for automagically setting the .OBJDIR to
./obj.${MACHINE}
	./obj
	/usr/obj/${PWD}

The rules for the default .OBJDIR setting are now simplified to
(and documented as) trying the chdir to the following
(if the appropriate variable is defined):
	${MAKEOBJDIRPREFIX}${.CURDIR}
	${MAKEOBJDIR}
	${.CURDIR}

.OBJDIR can be overridden in the makefile.
<bsd.obj.mk> uses this to provide the "culled" .OBJDIR semantics
for NetBSD's /usr/src builds.

MAKEOBJDIRPREFIX & MAKEOBJDIR still can only be provided
in the environment or on make(1)'s command line.

Per discussion on tech-toolchain.
This should reduce a lot of lossage people have experienced over
the years with various .OBJDIR setups.
2005-06-23 02:31:31 +00:00
wiz
19a870f516 Fix an article, and drop trailing whitespace. 2005-06-19 17:26:07 +00:00
rpaulo
9e77e5175e Change "non-escaped" to "unescaped".
Reviewed by hubertf.
2005-06-18 14:34:55 +00:00
rpaulo
a0c960912d Add a new test case to reflect the problem found on PR toolchain/30536.
Reviewed by sjg and hubertf.
2005-06-18 14:33:15 +00:00
rpaulo
f0f2f92389 PR standards/17732: make doesn't honour escaped comment lines. Now with
a real fix.
Ok'ed by sjg and hubertf.
2005-06-18 14:32:04 +00:00
wiz
7fba66045a Bump date for -jn, and add some formatting. 2005-06-17 19:30:49 +00:00
jmc
736ef19188 Add new debugging option '-dn' which will leave the scripts fed into make on
-j jobs in /tmp for debugging purposes. Add a note to the man page that
this could cause problems if run a lot (due to the number of files created)
2005-06-17 19:25:20 +00:00
jmc
e72c744fe2 If the line being passed to the shell is a blank line and we're not in compat
mode, use the ignErr template for the command as shell doesn't like an empty
construct of the form { } || <something>. Fixes build breakage on cats
distrib where a command ends up expanding to nothing.
2005-06-16 18:07:45 +00:00
rpaulo
a94394c1d9 Back it out while I'm working on a real fix without introducing new bugs. 2005-06-16 14:54:10 +00:00
rpaulo
9eb6f66b9a We now support comments until the end of a non-escaped line.
Ok'ed by hubertf.
2005-06-15 22:39:27 +00:00