summaryrefslogtreecommitdiff
path: root/usr.bin/make
AgeCommit message (Collapse)Author
2021-12-15make: amend leftover cleanups from the previous commitsrillig
No functional change.
2021-12-15make: format comments according to /usr/share/misc/stylerillig
Assisted by indent(1), with manual corrections due to its many remaining bugs. No functional change.
2021-12-15make: use consistent indentation for statements and continuationsrillig
No binary change, except for line numbers in assertions in suff.c.
2021-12-15make: remove redundant comments for multiple-inclusion guardsrillig
2021-12-15make: remove space after ':' in bit-field declarationsrillig
As seen in /usr/share/misc/style.
2021-12-15make: remove bmake_freerillig
It was only used in 2 places, and in both these places, the pointer was never null.
2021-12-15make: in CLEANUP mode, free interned strings at the very endrillig
Noticed by sjg.
2021-12-15make: in ParseDependencyCheckSpec, move default branch to the bottomrillig
No functional change.
2021-12-15make: change return type of HashTable_Set to voidrillig
None of the callers needs the HashEntry for further manipulation. No functional change.
2021-12-15make: change return type of Compat_RunCommand from int to boolrillig
The documentation was wrong before since status was not restricted to only 0 or 1. No functional change.
2021-12-15make: mark several functions whose result must be usedrillig
Suggested by sjg, to catch more bugs like the memory leak in cond.c 1.303 from 2021-12-13. No binary change.
2021-12-15make: prevent memory leaks from buffersrillig
The warning about unused function results would have prevented the memory leak that was fixed in cond.c 1.303 from 2021-12-13.
2021-12-14make: condense repetetive code in ParseDirectiverillig
No functional change.
2021-12-14tests/make: disable test that behaves differently in ATFrillig
2021-12-14make: remove dead code for handling traditional include directivesrillig
This code is not reached, a line containing only the word "include" is categorized as error before. No functional change.
2021-12-14tests/make: test traditional include directiverillig
2021-12-14make: clean up parsing of variable assignmentsrillig
Assign pairs of variables in a consistent order, as far as possible. Use string functions instead of raw byte access, to make the code more human-readable. GCC 10 optimizes the code reasonably. No functional change.
2021-12-14make: remove unreachable code for parsing the dependency operatorrillig
At the point where ParseDependencyOp is called, cp is guaranteed to point to either ':' or '!'. No functional change.
2021-12-13tests/make: extend tests for parsing makefilesrillig
2021-12-13make: convert debugging flags from enum to bit-fieldrillig
This gets rid of the magic numbers, making it possible to add another debug flag without renumbering the others. No functional change.
2021-12-13make: condense CondParser_ComparisonOprillig
No functional change.
2021-12-13make: fix memory leak when parsing '.if ${expr}' (since 2004-04-13)rillig
$ ( echo 'VAR=value' perl -e 'printf(".if \${VAR}\n.endif\n" x 5000);'; echo 'all:' printf '\t%s\n' \ '@pid=$$$$; \' \ 'ppid=$$(ps -o ppid -p "$$pid" | sed 1d); \' \ 'ps -o vsz,rsz -p $$ppid | sed 1d' ) > leak-cond2.mk $ make-2004.04.08.07.24.26 -r -f leak-cond.mk 2668 $ make-2004.04.13.16.06.23 -r -f leak-cond.mk 3964 $ echo $(((3964 - 2668) * 1000 / 5000)) 259 This 259 is close enough to the 256 from Buf_Init in CondParser_Leaf.
2021-12-13make: clean up loading of filesrillig
The call to Buf_DoneData was useless since ownership of the buffer data has already been passwed on to loadedfile_create and the local variable 'buf' goes out of scope after that statement. Except for cleaning up in debug mode, there is no reason to call Buf_DoneData and then discard the returned value. No functional change.
2021-12-13make: fix memory leak for filenames in .for loops (since 2013-06-18)rillig
Previously, each time a .for directive pushed its buffer on the input file stack, the current filename was duplicated. This was a waste of memory. The name of a file is typically only used while it is read in. There is one situation when the filename is needed for longer, which is when a target is defined. Since .for loops are implemented as a special form of included files, each .for loop duplicated the current filename as well. $ cat << EOF > for.mk .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .for i in 1 2 3 4 5 6 7 8 9 0 .endfor .endfor .endfor .endfor .endfor .endfor .endfor all: @ps -o rsz -p ${.MAKE.PID} EOF $ make-2021.12.13.03.55.16 -r -f for.mk RSZ 10720 $ ./make -r -f for.mk RSZ 1716 The difference is 8 MB, which amounts to 1 million .for loops.
2021-12-13make: fix memory leak when parsing a variable namerillig
To trigger the memory leak, the expanded variable name must not be a prefix of the textual variable name. textual name expanded name ok: UNDEF.${undef} UNDEF. leak: UNDEF.${undef}. UNDEF..
2021-12-13make: reduce memory allocation in modifier ':?'rillig
The memory allocation was in LazyBuf_DoneGet. The substring for the untaken branch had been allocated even though it was not necessary. No functional change.
2021-12-13make: reduce memory allocations in modifier ':C'rillig
The memory allocation was in the call to LazyBuf_DoneGet. No functional change.
2021-12-13make: condense RegexReplace for the modifier ':C'rillig
No functional change.
2021-12-13make: in the modifier ':C', don't call strlen unnecessarilyrillig
No functional change.
2021-12-13make: extract RegexReplaceBackref from RegexReplacerillig
No functional change.
2021-12-13make: merge duplicate code for memory handling in Var_Parserillig
No functional change.
2021-12-13make: fix remaining memory leak for .SUFFIXES (since yesterday)rillig
2021-12-13make: distinguish between short-lived and environment variablesrillig
No functional change.
2021-12-13make: rename VarFreeEnv to VarFreeShortLivedrillig
The newly added "variable" .SUFFIXES is short-lived as well, which makes it necessary to distinguish between environment variables and short-lived variables. No binary change.
2021-12-13make: fix indentation in meta.crillig
2021-12-13make: clean up code for freeing short-lived variablesrillig
Since yesterday's addition of the short-lived "variable" named .SUFFIXES, not only environment variables are short-lived. Clean up the code to prepare for fixing the remaining memory leaks. No functional change.
2021-12-13make: fix memory leak when evaluating ${.SUFFIXES} (since yesterday)rillig
perl -e ' printf(".SUFFIXES: %s\n", "x" x 224); printf("_:=\${.SUFFIXES}\n" x 100_000); printf("all:\n"); ' \ | MALLOC_CONF=stats_print:true \ ./make -r -f - 2>&1 \ | awk '/bins:/,/^ *256/ { print $1 "\t" $4}' Roughly 100000 less allocations for bin size 16, for the variable name.
2021-12-13make: fix memory leak when evaluating ${.SUFFIX} (since yesterday)rillig
2021-12-13make: fix memory leak in IncludeFilerillig
Previously, each .include leaked a copy of the file name.
2021-12-12make: in Arch_ParseArchive, rename libName to librillig
For symmetry with mem. No binary change.
2021-12-12make: remove unused type MFStrrillig
The only binary change is the line number of the assertion in Substring_Sub.
2021-12-12make: in Arch_ParseArchive, replace MFStr with FStrrillig
This was the only use of the type MFStr, which produced the same code as FStr. No binary change.
2021-12-12make: use simpler memory management for parsing archive membersrillig
No functional change.
2021-12-12tests/make: test and document the newly added "variable" .SUFFIXESrillig
2021-12-12Add .SUFFIXES as read-only variable.sjg
References to ${.SUFFIXES} are handled dynamically in ParseVarnameLong by calling Suff_NamesStr. The variable cannot be set normally. Reviewed by: rillig
2021-12-12ParseVarnameLong: minimize calls to LazyBuf_Getsjg
Reviewed by: rillig
2021-12-12make: rename Parse_SetInput to Parse_PushInputrillig
The word 'set' sounded too much like it would replace the current file, but instead the file is pushed to the stack, and the previous file is continued later. No functional change.
2021-12-12make: remove unused loadedfile.pathrillig
2021-12-12make: rename ForLoop.sub_next to nextItemrillig
This matches the naming style of the other ForLoop members. No functional change.
2021-12-12make: fix memory leak in LazyBufrillig
This affects many operations on variable expressions. Those using LazyBuf_Done are affected, those using LazyBuf_DoneGet aren't. $ cat <<'EOF' > lazybuf-memleak.mk .for i in ${:U:range=5} . for j in ${:U:range=1000} . for k in ${:U:range=1000} . if 0 && ${VAR:Dpattern\: that needs unescaping} . endif . endfor . endfor .endfor all: @ps -o vsz -p ${.MAKE.PID} | sed 1d EOF Before using LazyBuf for the modifier ':D': $ make-2021.04.14.16.12.26 -r -f lazybuf-memleak.mk VSZ RSZ 1357136 1336432 Using LazyBuf for the modifier ':D': $ make-2021.04.14.16.59.34 -r -f lazybuf-memleak.mk VSZ RSZ 1590864 1574164 This commit alone allocates around 150 MB more data, which matches 5_000_000 strings * 30 bytes/string. It looks very wrong that the above simple makefile uses 1.3 GB of RAM at all, and it had already done this in 2017, long before LazyBuf was introduced. Before 2017.01.30.02.46.20, the above test makefile reports way smaller numbers, but that's because the modifier ':range' did not exist back then.