1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-03 06:45:37 -08:00
Commit Graph

74 Commits

Author SHA1 Message Date
cheloha
7e440d1959 make(1): inline set_times() into Job_Touch()
set_times() has one caller: Job_Touch().  set_times() is a thin
utimes(2) wrapper.  Using utimes(2) to reset a file's atime/mtime
to the current time is not cumbersome.

So, remove set_times() and just call utimes(2) directly.

Thread: https://marc.info/?l=openbsd-tech&m=171262211713835&w=2

ok kn@
2024-04-09 15:08:21 +00:00
espie
c9fc29cfc6 GC old code that was originally implemented to facilitate adoption by
other BSDs, which never happened, so make things simpler for further
development.

Ditches config.h entirely since it gets reduced to 2 defines.

okay tb@
2023-09-04 11:35:11 +00:00
espie
e2e5a33cfe reuse the code to exec command for VAR != cmd *and* normal target processing
okay tb@
2023-08-31 06:53:28 +00:00
espie
438dc521bf Due to the way make is designed, not being able to read a makefile
is basically silent.

Record errors due to missing permissions and other oddities, and display them
when we error out due to lack of targets, as a quality-of-life diagnostic.

Based on a remark from sthen@, with some feedback and tweaks from op@

okay op@, kn@
2023-05-30 04:42:21 +00:00
kn
dcbed439e4 Zap unused variables/functions under /usr/src/*bin/
OK deraadt
2021-10-25 19:54:29 +00:00
espie
18cc032855 remove OP_* for deprecated keywords (document that :: still uses
OP_INVISIBLE)

okay millert@
2020-01-26 12:41:21 +00:00
espie
868b296a5a turns out there WAS something fishy in signal handling in the "generic"
reaper. Specifically, the sigprocmask/wait/sigsuspend dance is correct for
the main process, BUT you have to remember to reset the signal mask to
something sane for the child (this was a duh! moment, that bug is very
stupid)


Finally, bluhm@  saw the actual issue. Kudoes to him.

The change to "unify" sequential and parallel make  made the bug reproducible
under some circumstances
(because in the parallel make case, many things may happen in different
successions, so you don't get the wrong signal mask that often, but the
sequential case is reproducible, and using the "streamlined" reaper meant the
fork would occur WITHIN the signal loop instead of OUTSIDE)

So:
- discover signal state early on through Sigset_init;
- introduce reset_signal_mask to get back to the initial state;
- call reset_signal_mask systematically after fork

This organisation thanks to cmd_exec.  SOME cmd_exec happens before Job_Init
happens, some afterwards (variables are still lazy and both !!= and :sh will
occur AFTER parsing), so both fork() need to be protected.

okay bluhm@

thx to sthen@ and naddy@ and mpi@ for helping out.
2020-01-16 16:07:18 +00:00
espie
bee8c711c1 unify compat mode and parallelmode a bit: there's no longer a need for
handle_one_job, always go thru Job_Make now.
2020-01-13 15:24:31 +00:00
espie
80ccc038b1 less confusing function name 2020-01-13 15:15:17 +00:00
espie
7a7b8f3368 introduce a JOB_KEEPERROR flag so that the logic for moving jobs
to availableJobs/errorJobs happens just once
2020-01-13 15:12:58 +00:00
espie
3bb9adb9ca better name for function 2020-01-13 14:56:59 +00:00
espie
7dccecca41 simplify the way we account for different jobs:
- have a simple variable "sequential" that counts  whether we are
running more than one job (for the expensive heuristics)
- don't expose various things globally, just have a set_noparallel() for
the parser
- preallocate exactly enough job structures and record them in availableJobs
- keep one job on the side for .INTERRUPT
2020-01-13 14:51:50 +00:00
espie
0b019757dd and actually comment about it 2020-01-13 14:15:21 +00:00
espie
d211a910f5 move expensive heuristics a bit and explain better why we do that
in that error case.
2020-01-13 14:14:24 +00:00
espie
342b95d74e Remove non-sensical line. The node certainly hasn't been rebuilt yet,
and the first thing job_attach_node does is... set the field to BUILDING.

probably remnants of code prior to refactoring


okay captain_obvious
2019-12-24 13:57:42 +00:00
espie
91797de122 yet another mostly cosmetic diff
- rename context into localvars, which is more meaningful and less generic
- instantiate the random rumbling at the start of gnode.h with actual
variable names
- explain and group gnode.h variables better
- make some comments terser/more meaningful

okay millert@
2019-12-21 15:31:54 +00:00
espie
194f6ecc45 rename a few variable/functions to have better names.
adjust comments to be more meaningful
reorder predecessors/successors fields in an order that
makes more sense to me.

okay millert@
2019-12-21 15:29:25 +00:00
espie
ed90eef365 rename built_status constants to be less quirky
fold back BEINGMADE and BUILDING which mean the same thing
GC CYCLE/ENDCYCLE

okay millert@
2019-12-21 15:28:16 +00:00
espie
096da974cb fix very stupid bug. 2019-05-21 17:10:49 +00:00
espie
4b65af26e8 handle -s and -i in a uniform fashion, do not try to change the node type
but use the Targ_* functions correctly.

This fixes an oddity in end node handling noticed by kn@

review and okay kn@
2018-11-27 09:33:48 +00:00
espie
0a3426757d turn stupid message into a proper warning.
noticed by Michael W. Bombardieri

okay schwarze@
2017-07-24 12:08:15 +00:00
espie
8a1af4f87f there's no need to fork/exec to execute comments
okay millert@
2017-07-09 15:28:00 +00:00
espie
68097c0d03 obvious protection against null pointer, because it's quite possible for cgn
to not have a parent...
2017-01-29 10:04:13 +00:00
espie
568f6c05a2 small obvious cleanups:
- remove a lot of unnecessary casts
- zap extra param that's no longer needed
- add proper prototype and make function static

okay natano@
2016-10-21 16:12:38 +00:00
espie
7f5855dc00 remove a bunch of dangerous casts (useless casts from void * to something
else, in some cases by adding extra temporary variables.
IMO, it's much better practice to do

void *a;
int *p = a;
*p = 42;

rather than
void *a;
*(int *)a = 42;

okay miod@... to be revisited for some possible const additions later.
2015-01-23 13:18:40 +00:00
gsoares
19e54df6fb redirect error output to stderr instead of stdout
stderr is always unbuffered by default, so zap fflush(3) its no longer makes any sense here
reminded by espie@

OK espie@
2014-10-31 13:29:42 +00:00
espie
9676bac07c modern bourne shells handle ~. Unlikely in makefiles, but still, better
fork a shell then (as seen in a commit message in netbsd's make, apparently
taken from debian. didn't look at the actual code, but it was a "duh" moment)

okay millert@
2014-05-30 21:19:57 +00:00
espie
56afcde6d4 wrappers for is*/to* that make damn sure their arguments are
cast to unsigned chars.

okay deraadt@
2013-11-22 15:47:35 +00:00
naddy
8a774f81ed replace rand(3)/random(3) calls with secure arc4random*()
npppd ok yasuoka@
ok millert@
2013-08-26 14:15:07 +00:00
espie
23a9ff7bf8 remove cmtime again, but with a proper test for nodes without children.
problem seen by aja,
make pointed by matthieu,
sleuthing by me,
okay by millert

(and you say OpenBSD developers don't work together)
2013-05-30 08:58:38 +00:00
espie
7ba3470543 obviously missed something, so revert.
(noticed by sthen@/matthieu@)
2013-05-25 11:54:14 +00:00
espie
4c9de42989 as checked through thorough tests, youngest->mtime == ctime, so ditch
the extra field.

remove some extra abstraction layer: use clock_gettime directly
instead of ts_set_from_now (what is "now" anyways)

time_to_string takes param by pointer

rename "now" into starttime (more accurate term)

randomize queue uses arc4random_uniform (prompted by deraadt@)

display debug timestamp with ns too (it's debug, so it doesn't really
matter whichever way it's done, as long as it's done)

okay millert@
2013-05-22 12:14:08 +00:00
espie
1ea29b928c keep track of the youngest child, helps a lot with out-of-date messages
in -dm mode.

okay millert@
2013-05-14 18:47:40 +00:00
espie
1f89b472f1 remove TIMESTAMP abstraction layer, prodded by theo.
while there, clean up includes.
use strtoll for ar timestamps (pretty much unused in reality, more
standard conforming than anything)

use idea from Todd to adapt to time_t being 32 bits OR 64 bits
(pedantically correct: INT_MIN would work just fine up to 1910 or so...)

okay millert@, gone thru a make build.
2013-04-23 14:32:53 +00:00
espie
e34c3a80c1 document engine interface, remove internal function from visible interface 2012-12-07 15:08:03 +00:00
espie
466b8ac54d ${.ALLSRC} and ${.OODATE} should always be defined, even for empty lists
of prerequisites. This prevents complaints from the var module and from
other developers.

That's a bug I introduced 5 years ago... found out by miod@

okay miod@
2012-11-21 23:21:54 +00:00
espie
be710f6fb8 numerous error message fixes:
- do ^C checking differently: don't record sent signals, but when jobs
die, recheck whether we received/have pending a INT/QUIT/TERM/HUP signal.
Then don't display our process group "normally", instead group together
everything dying by signal/shell dying by signal (just give the target
names).

- make certain we always handle signals before dying from "other conditions"
- have the parser messages look more like normal messages
- remove double error messages from some parser errors
- make sure unclosed variables ARE errors when some modifiers are present

- keep track of the base directory we're run from, so that submakes can
get shortened directories...
- make sure the whole error message including silent command fits into a
reasonable length.

okay millert@
2012-10-18 17:54:43 +00:00
espie
694f1218a2 warn about targets with multiple command lists (debug option), as it's
definitely non portable behavior.

discussed with millert@, who rightfully insisted on the optional debug part
2012-10-09 19:50:44 +00:00
espie
b12bcd0d47 - extra juice for debugging signal passing. Note when we can't pass the
signal because the process already bought it (pgroups will do that to you)
(lots of discussion with Todd on that one)
- tweak error handling some more to make it less verbose when just one job
is running...
- show signal name in case of signal interrupts.
- zap OP_LIB, move that stuff to the location where we warn when we meet
that bug.

okay millert@
2012-10-06 09:32:40 +00:00
espie
0031b98656 backout pgroup/job control from make, there is something deeply bogus
in stdin interaction.

Fixes update-patches as reported by aja...
2012-10-04 13:20:46 +00:00
espie
1bae8e1fd6 more changes, discussed and tested by various people.
- put back some job control, turns out it's necessary when we don't run a
shell.
- zap old #ifdef CLEANUP code... probably doesn't even compile.
- kill most of the OP_LIB code. Just keep a wee little bit for compatibility
(deprecated .LIBS and .INCLUDES, warns for weird dependencies instead of
erroring out).
- much improved debugging and -p output: sort variables, targets, rules,
output stuff in a nicer format mimicing input.
- better error message when no command is found, explain where the target comes from.
- sort final error list by file.
- show system files in errors as <bsd.prog.mk>
- reincorporate random delay, that was dropped
- optimize siginfo output by not regenerating the whole string each time.
- finish zapping old LocationInfo field that's no longer used.
2012-10-02 10:29:30 +00:00
espie
a6b963c872 major overhaul of the way make handle jobs, inspired by dpb:
instead of forking a "job" per target, and having that job further fork
separate commands, have make maintain a list of jobs, indexed by pid
of currently running commands, and handle process termination
continuation-style.  This has lots of benefits:
- make is responsible for most printing, so we no longer need pipes nor
job control: make -j jobs see the tty.
- no more special-casing for jobs that don't really execute anything.
- unify code for make -jn and make -B, including signal handlers and
job waiting.  So make -n, make -q, +cmd now run commands in the same
way in all cases.
- unified more accurate error-reporting, as make knows precisely which
command failed. Commands are tagged with their lines, and we display failing
commands in silent mode.
- fine-grained "expensive" command handling (recursion limiter). Do it
per-command instead of per-target.

Moreover, signal response is now simpler, as we just block the signals
in a small critical sections, test for events, and sigpause (thanks a lot
to guenther@ and millert@), so running make is now almost always paused
without any busy-waiting.

Thanks to everyone who tested and gave input.
2012-09-21 07:55:20 +00:00
espie
08c6f257b7 more accurate fix: don't mark '!' as a meta character, recognize "!" as
a shell reserved word.

okay millert@
2012-09-14 14:18:50 +00:00
espie
5b710adbeb ! is a meta character, this lets
test:
	! pgrep process

work, without trying to look for a '!' command

(remember that not running a shell for each command is an optimization ?)

bug fix prompted by eric@'s remark, okay millert@
2012-09-14 08:46:39 +00:00
espie
c1007ea275 - make wrong variable specs (unterminated) parse errors.
- add info to be able to pinpoint parse errors at runtime.
- let job runners abort when a parse error happens while expanding a variable
during execution
- fix an infinite loop when compiling without FEATURE_RECVARS.

okay millert@, krw@
the very few errors found out by this (less than 10 over src/X/ports)
fixed trivially beforehand, as requested by deraadt@
2012-08-25 08:12:56 +00:00
espie
f4f0b16ad7 minor cleanup: error messages include lineno and fileno together, so
recognize that and create a struct Location_ for it.

mostly from Jonathan Calmels, a few nits from me.

okay otto@
2012-03-22 13:47:12 +00:00
espie
3c4acb25b0 pure whitespace cleanup 2010-04-25 13:59:53 +00:00
espie
28c294aef1 write sensible error message 2009-08-16 09:49:22 +00:00
espie
78086188f5 avoid touching .PHONY targets, they don't exist. 2009-08-16 09:47:06 +00:00
espie
993065954e zap double prototype 2009-05-12 09:46:39 +00:00