Commit Graph

16207 Commits

Author SHA1 Message Date
rillig cde2127e43 make(1): rename SuffAddSrc to SrcList_Add
The main character in this function is the list of sources, therefore
make it the subject.
2020-11-21 18:12:55 +00:00
rillig bd80e4d940 make(1): improve parameter name in SuffUpdateTarget 2020-11-21 18:09:13 +00:00
rillig 9bed54020b make(1): document necessary condition in SuffUpdateTarget 2020-11-21 18:06:09 +00:00
rillig 6652031933 make(1): limit memory usage in tests
There is a suspicious condition in SuffUpdateTarget code that looks wrong
on the first sight.  When removing it though, make allocates huge amounts
of memory.  To stop freezing the whole machine in this situation, limit
the total memory.

The limit of 200000 has been determined experimentally on NetBSD 8.0
x86_64.  With a limit of 100000, make wouldn't even start.  100 MB of
memory is really a lot for such a simple program that according to top(1)
only needs 8 MB.  But 200 MB is still better than 5 GB.

Since the Makefile is used on other platforms as well, via the bmake
distribution, and since every operating system has its own list of ulimit
options, make this configurable.
2020-11-21 17:44:40 +00:00
rillig 65275b772e make(1): in SuffExpandChildren, only expand ${VAr} if needed 2020-11-21 17:18:36 +00:00
rillig 0eb2702f38 make(1): add test for dynamic variable with modifiers in global context 2020-11-21 15:48:05 +00:00
rillig 4fa84349d1 make(1): clean up freeing of environment variables in Var_Parse
The previous code with the extra boolean variable was a brain-twister
since the responsibility of freeing the memory was distributed over 3
different functions.
2020-11-21 15:32:52 +00:00
rillig bfaeb69ca7 make(1): clean up parameter order in EvalUndefined 2020-11-21 15:28:44 +00:00
rillig 4834bcd8db make(1): rename local variable in Var_Subst 2020-11-21 15:02:52 +00:00
rillig ef5f627573 make(1): add test for .include with trailing garbage in the line 2020-11-21 14:59:11 +00:00
rillig 84c5f79d54 make(1): clean up reference counting in SuffList_Insert 2020-11-21 13:20:12 +00:00
rillig 82ab80ea5e make(1): move reference counting for suffixes to SrcNew 2020-11-21 13:16:37 +00:00
rillig f2299498cb make(1): clean up reference counting for suffixes 2020-11-21 13:11:13 +00:00
rillig bbdb624c98 make(1): add explanation for test suff-rebuild 2020-11-21 12:01:16 +00:00
rillig 416a199000 make(1): add more debug logging for suffix handling
One notable thing is that there is no debug output when adding a
transformation rule like ".c.o",  which means that these rules don't end
up in the global allTargets variable.

This may or may not be intentional.  It seems not intentional since this
is one of the causes for the suff-rebuild test to behave unexpectedly.
2020-11-21 11:59:22 +00:00
rillig c7d2d627f1 make(1): enable debug logging for test suff-rebuild
As long as it is not clear why this test fails, it's better to have the
debug log available, both for reading it and for getting notified if
any behavior in this area changes.
2020-11-21 11:55:57 +00:00
rillig 91b9265a19 make(1): improve comment style in GNode_Free
It was unclear what the ellipsis referred to.  It was meant to refer to
the function call Lst_Free, but that was not necessarily obvious to a
casual reader.
2020-11-21 10:56:17 +00:00
rillig 6d886316ea make(1): fix indentation in Make_HandleUse 2020-11-21 10:51:26 +00:00
rillig ed1ae9b4ee make(1): fix comment for allTargets
Source nodes are also included in this list.  What's not includes is
nodes that are _only_ source nodes.
2020-11-21 10:50:39 +00:00
rillig 2c440fadec make(1): add more debug logging for suffixes
The "Removing suffix" is not covered by the current tests.  It would be
best if that code were unreachable at all, since a reference count of -1
doesn't make sense.
2020-11-21 10:36:01 +00:00
rillig 27b9e4c5e6 make(1): add test for incomplete transformation rule 2020-11-21 10:32:42 +00:00
rillig 8f33a92f2e make(1): add debug logging when adding a suffix to the global list 2020-11-21 09:53:40 +00:00
rillig 99a15640c4 make(1): rename local variable s to suff
The name s was ambiguous.  It could have meant suffix, src, str, and
probably more.
2020-11-21 09:51:00 +00:00
rillig 6adf3573af make(1): make debug logging more precise in Suff_EndTransform 2020-11-21 09:19:46 +00:00
rillig 71013d7845 make(1): flatten Suff_EndTransform
This avoids the duplicate code for testing OP_TRANSFORM.
2020-11-21 09:16:44 +00:00
rillig 6950342b0d make(1): make output of test suff-rebuild more verbose 2020-11-21 08:51:57 +00:00
rillig dadca80717 make(1): rename SuffScanTargets to SuffUpdateTarget
The word "scan" no longer applies to this function since that is done by
SuffUpdateTargets instead.
2020-11-21 08:23:36 +00:00
rillig c6c7de4990 make(1): clean up parameter names for SuffScanTargets
The prefix "gs" came from a time when SuffScanTargets was called via
Lst_ForEach, passing it a struct GNodeSuff.  The "gs" had just been the
abbreviation for "GNode + Suff", which was already non-expressive.  On
top of that, the struct had a third field "r", also with an unclear name,
which was not even mentioned in the name of the struct.

For now, just remove the needless prefix since it has absolutely no
meaning anymore.  Maybe it will become clear what the "r" was supposed to
mean, it could be some kind of "result".
2020-11-21 08:01:20 +00:00
rillig 91454f41a4 make(1): make string iterator in ParseDependencyTargetWord const 2020-11-20 20:01:16 +00:00
rillig b87e92bb19 make(1): fix local variable name in ParseDoDependencyTargets 2020-11-20 00:24:56 +00:00
rillig 92ae6bc227 make(1): run tests with different shells as well, reduce output 2020-11-20 00:24:21 +00:00
rillig 8550207eb8 make(1): fix test opt-debug-jobs for native shell
Even after substituting the actual shell name with <shell>, the trailing
optional -q option needs to be normalized.
2020-11-19 23:50:26 +00:00
rillig fea3262579 make(1): fix test opt-debug-jobs when compiled with dash as shell
make USER_CPPFLAGS=-DDEFSHELL_CUSTOM='\"/usr/pkg/bin/dash\"'
2020-11-19 21:46:10 +00:00
rillig ae7cf2829a make(1): remove redundant postprocessing for test var-op-shell
The regular expression from the previous line already matches everything
that the removed line could ever match.
2020-11-19 21:39:50 +00:00
rillig 67b2defe63 make(1): remove postprocessing for test directive-export-gmake
Since revision 1.3, directive-export-gmake.mk takes care of handling this
case.  Removing the "error" lines from the output of the tests only makes
the test harder to understand and may also hide future bugs.
2020-11-19 21:35:46 +00:00
rillig 654eeac9fe make(1): mark srclist as a bad global variable
The previous comment "List of sources" didn't tell anything about the
purpose of the variable, it was only useful before July 2020, when its
data type was still Lst, without any type information.

Having a global variable here seems pointless, but all the code about
suffix transformations is so tricky and not well covered by tests that I
don't dare to convert the global variable to a local variable in
Suff_FindDeps.  The change itself would be trivial, but the hidden and
undocumented intentions of the original author probably aren't.
2020-11-19 21:27:29 +00:00
rillig f0e1eb8794 make(1): compare pointers against NULL instead of implicit conversion 2020-11-19 14:42:33 +00:00
rillig ccaefb7637 make(1): fix compilation error in -DDEBUG_SRC mode 2020-11-19 14:32:25 +00:00
wiz a1209b298d Sort options.
Prompted by pgoyette.
2020-11-18 20:00:15 +00:00
sjg ab5d64cce8 Cleanup - colliding fixes for same issue 2020-11-18 04:10:34 +00:00
sjg b70d869915 Some tests need help with dash 2020-11-18 01:12:00 +00:00
sjg b4116ceb0f Always use -r -f /dev/null when not intending to read a makefile 2020-11-18 01:06:59 +00:00
rhialto d36fee1ba5 Remove heuristic for dealing with trailing newlines being truncated by mailers.
Patch and explanation taken from bsdimp:
https://bsdimp.blogspot.com/2020/08/a-35-year-old-bug-in-patch-found-in.html
https://svnweb.freebsd.org/base?view=revision&revision=364291

Every version of patch since the first one posted to mod.sources in 1985 have
included a heuristic for coping with the state of email messaging at the
time. This heuristic would add up to 4 blank lines to a patch if it thought it
needed it. The trouble is, though this causes at least one bug.

The bug in my case is that if you have a context diff whose last hunk only
deletes 3 or fewer lines, then if you try to reverse apply it with -R, it will
fail. The reason for this is the heuristic builds an internal representation
that includes those blank lines. However, it should really replicate the lines
from the pattern lines line it would any other time, not assume they are blank
lines. Removing this heuristic will prevent patch from misapplying the lines
removed after applying a 'fuzz' factor to the previous blank line in the file. I
believe this will only affect 'new-style' 4.3BSD context diffs and not the
older-style 4.2BSD diffs and plain, non-context diffs. It won't affect any of
the newer formats, since they don't use the 'omitted' construct in the same way.

Since this heuristic was put into patch at a time when email / etc ate trailing
white space on a regular basis, and since it's clear that this heuristic is the
wrong thing to do at least some of the time, it's better to remove it
entirely. It's not been needed for maybe 20 years since patch files are not
usually corrupted. If there are a small number of patch files that would benefit
from this corruption fixing, those already-currupt patches can be fixed by the
addition of blank lines. I'd wager that no one will ever come to me with an
example of a once-working patch file that breaks with this change. However, I
have 2 patches from the first 195 patches to 2.11BSD that are affected by this
bug, suggesting that the relative frequency of the issue has changed
signficantly since the original heuristic was put into place.
2020-11-17 20:49:12 +00:00
rillig edf9ffaa2c make(1): make test vardebug independent from the shell 2020-11-17 20:27:35 +00:00
rillig 89f92ad9db make(1): fix test output of var-op-shell for dash
Dash is helpful and outputs the line number in case of an error.  The
other shells don't do this.  Accept both variants.
2020-11-17 20:19:24 +00:00
rillig 64445dba48 make(1): fix test directive-export-gmake for dash
Dash only accepts environment variables whose names follow the usual
naming conventions.  (I didn't look up the exact details.)  In
particular, it rejects environment variables whose names start or end
with spaces.

This would result in an empty output from grep, in which case the exit
status from the shell command is non-zero, thus make prints an error
about this.  This error message should not appear in the test output, to
keep the test output the same for all platforms.
2020-11-17 20:16:44 +00:00
rillig 55e719e944 make(1): fix error message of failed :!cmd! modifier (since 2000-04-29) 2020-11-17 20:11:02 +00:00
rillig bb60fb97ce make(1): document 20-year-old bug in the :!cmd! modifier 2020-11-17 20:08:09 +00:00
rillig bd79c8fd13 make(1): rename local functions in suffix handling
Name these functions after their main object, which is the suffix list.
2020-11-16 23:27:41 +00:00
rillig c848b17077 make(1): merge duplicate calls to SuffInsert 2020-11-16 23:23:57 +00:00