Commit Graph

275 Commits

Author SHA1 Message Date
Paolo Bonzini
0c44ca2683 Do not use STOP_SET for singleton compares.
Compare against '$' directly rather than using MAP_VARIABLE.
This saves ~10% for find_map_function, which is the top hotspot in
QEMU's no-op build.  The build is sped up overall by about 1.5%
more (from 11.1s to 10.95s).

* read.c (find_map_function): Do not compare against singleton sets.
2017-11-11 10:08:30 -05:00
Paolo Bonzini
9860296198 Remove MAP_PERCENT as strchr is faster.
* read.c (find_percent_cached): Use strchr instead of STOP_SET
to find % or nul.
* makeint.h (MAP_PERCENT): Remove.
* main.c (initialize_stopchar_map): Remove.
2017-11-11 10:08:30 -05:00
Paolo Bonzini
0ca31088dc Use strchr for simple case of find_char_unquote.
In most cases, find_char_unquote has a single stopchar.  In that
case we can look for it using strchr's optimized implementation.

This saves 3.5% on QEMU's noop build (from 11.78s to 11.37s).

* read.c (find_char_unquote): Rename to find_map_unquote.  Replace
with an implementation optimized for the case where the stopchar
is a singleton.  Adjust all callers.
2017-11-11 09:38:51 -05:00
Paul Smith
7ef56bc8dc Update copyright statements for 2017. 2017-07-09 21:52:28 -04:00
Paul Smith
ac97214635 Remove uses of unnecessary "register" keyword. 2017-07-09 21:24:41 -04:00
Paul Smith
5345adf82f [SV 50823] Support filenames containing '$' in MAKEFILE_LIST
* variable.h (enum variable_flavor: Add a new flavor for appended
values that shouldn't be expanded.
* variable.c (do_variable_definition): If given this new flavor,
do not expand the value before appending it.
* read.c (eval_makefile): Use this new flavor for MAKEFILE_LIST
* tests/scripts/variables/MFILE_LIST: Test filenames containing '$'.
2017-06-04 18:37:21 -04:00
Enrique Olaizola
816a867ff5 * read.c (read_all_makefiles): [SV 50909] Add MAKEFILES to strcache
Copyright-paperwork-exempt: yes
2017-06-04 18:37:21 -04:00
Paul Smith
68be4f74fc [SV 13651] Handle out-of-memory conditions slightly more gracefully.
* makeint.h: Change OUT_OF_MEM() macro to out_of_memory() function.
* output.h, job.h: Move FD_* macros from job.h to output.h.
* output.c (output_write): Write a buffer to an FD directly.
(out_of_memory): Use output_write() to avoid allocating more
memory while writing the error, and call exit() instead of die().
This does mean we can't translate the error string, though.
* misc.c (xmalloc, xcalloc, xrealloc, xstrdup, xstrndup): Call new
out_of_memory() rather than OUT_OF_MEM().
* read.c (parse_file_seq): Ditto.
2017-06-04 18:37:20 -04:00
Paul Smith
2b8e3bb23f Clean up close-on-exec, particularly with jobserver pipes.
* configure.ac: Check sys/file.h and assume fileno() always exists.
* output.h: Move output-specific content from job.h to output.h.
* os.h (fd_inherit, fd_noinherit): New functions manage FD inheritance.
* posixos.c (fd_inherit, fd_noinherit): Implement for POSIX systems.
(jobserver_setup): Force jobserver FDs to not be inherited by default.
(jobserver_pre_child): Enable inheritance in recursive invocations.
(jobserver_post_child): Disable inheritance after recursive invocations.
* w32/w32os.c (fd_inherit, fd_noinherit): Implement for W32 systems.
* job.h (CLOSE_ON_EXEC): Remove macro in deference to new fd_noinherit.
* function.c (func_shell_base): Convert CLOSE_ON_EXEC to fd_noinherit.
* job.c (child_execute_job): Ditto.
* output.c (setup_tmpfile): Ditto.
* read.c (eval_makefile): Ditto, plus remove HAVE_FILENO check.
* w32/include/sub_proc.h: Remove process_noinherit for fd_noinherit.
* w32/subproc/sub_proc.c: Ditto.
2017-06-04 18:37:20 -04:00
Paul Smith
c4f30e6012 [SV 50300] Use CFLAGS value of "-O1" in POSIX mode.
* read.c (record_files): Use "-O1" not "-O" for CFLAGS and FFLAGS.
* tests/scripts/targets/POSIX: Test for the new value.
2017-06-04 18:37:20 -04:00
Paul Smith
c5ccc4930c [SV 40236] Handle included file open failures properly.
* read.c (eval_makefile): Set deps->error if we discovered any
error reading makefiles, and set NONEXISTENT_MTIME so we know
it needs to be rebuilt.
* main.c (main): Clean up management of makefile_mtimes.
* tests/scripts/features/include: Add open failure testcases.
2016-12-26 09:01:59 -05:00
Paul Smith
c6966b3238 [SV 20513] Un-escaped # are not comments in function invocations
* NEWS: Document the change, as a backward-incompatible change.
* main.c (main): Add 'nocomment' to the .FEATURES variable.
* read.c (remove_comments): Skip variable references during remove.
(find_char_unquote): Fix comments for new STOPMAP support.
* tests/scripts/features/escape: Test new escape syntax.
* tests/scripts/functions/guile: Ditto.
* tests/scripts/functions/shell: Ditto.
2016-12-26 09:01:59 -05:00
Paul Smith
80861cce43 * read.c (get_next_mword): [SV 49865] Make fallthrough explicit. 2016-12-26 09:01:59 -05:00
Paul Smith
e4a9c9b825 [SV 45477] [SV 49115] Parse DOS/Windows drivespecs correctly.
* read.c (parse_file_seq) [WINDOWS32]: Only consider a colon part of
a path if it's in a valid Windows drivespec.
2016-12-26 08:59:58 -05:00
Paul Smith
bc9d72beb0 Resolve issues discovered by static code analysis.
* maintMakefile: Add a rule to submit code for analysis.
* configure.ac: Check for availability of the umask() function.
* output.c (output_tmpfd, output_tmpfile): Use umask on temp files.
* makeint.h (PATH_VAR): Reserve an extra character for nul bytes.
* function.c (func_error): Initialize buffer to empty string.
* job.c (child_execute_job): Verify validity of fdin.
* main.c (main): Simplify code for makefile updating algorithm.
* arscan.c (ar_scan): Verify member name length before reading.
* read.c (readline): Cast pointer arithmetic to avoid warnings.
* remake.c (update_file): Remove unreachable code.
(name_mtime): Verify symlink name length.
2016-12-14 17:56:24 -05:00
Paul Smith
e2ebea35f1 * read.c (eval): [SV 47960] Skip record waiting files when ignoring.
* tests/scripts/features/conditionals: Test this scenario.
2016-05-21 16:22:32 -04:00
Paul Smith
c73ed7dd1c Separate the GNU make load ABI from internal types.
Create an internal type "floc" and convert all users to that type.
* gnumake.h (gmk_floc): Remove the offset field from this type.
* loadapi.c (gmk_eval): Convert gmk_floc to internal floc.
2016-05-21 16:22:32 -04:00
Paul Eggert
ba8383efd8 Fixes for enhanced GCC warnings.
Move function prototypes into header files and out of .c files.
Use void argument lists for functions that accept no args.
Remove unused macros.  Make private functions static.  Align
types with printf format characters.
2016-05-21 16:22:25 -04:00
Paul Smith
047bd5a16f [SV 46433] Show recipe line offsets in line number messages.
While displaying line numbers, show the relevant line number inside
the recipe not just the first line of the entire recipe.
Sample changes suggested by Brian Vandenberg <phantall@gmail.com>

* gnumake.h (gmk_floc): Add an 'offset' to track the recipe offset.
* read.c (eval, eval_makefile, eval_buffer): Initialize 'offset'.
(record_files, install_pattern_rule): Ditto.
* job.c (new_job, job_next_command): Update 'offset' based on the
line of the recipe we're expanding or invoking.
(child_error): Add 'offset' when showing the line number.
* function.c (func_shell_base): Ditto.
* output.c (error, fatal): Ditto.
* NEWS: Mention the new ability.
* tests/scripts/features/errors: Check the line number on errors.
* tests/scripts/functions/warning: Check the line number on warnings.
* tests/scripts/features/output-sync,
tests/scripts/features/parallelism, tests/scripts/functions/shell,
tests/scripts/functions/error: Update line numbers.
2016-04-11 07:51:05 -04:00
Paul Smith
87a5f98d24 [SV 102] Don't show unnecessary include file errors.
Delay the generation of error messages for included files until we
are sure that we can't rebuild that included file.
* dep.h (struct dep): Don't reuse "changed"; make a separate field
to keep "flags".  Get rid of dontcare and use the flag.
(struct goaldep): Create a new structure for goal prereqs
that tracks an errno value and the floc where the include happened.
Rework the structures to ensure they are supersets as expected.
In maintainer mode with GCC, use inline to get type checking.
* read.c (eval_makefile): Return a struct goaldep for the new
makefile.  Ensure errno is set properly to denote a failure.
(read_all_makefiles): Switch to goaldep and check errno.
(eval): Don't show included file errors; instead remember them.
* remake.c (update_goal_chain): Set global variables to the current
goaldep we're building, and the entire chain.
(show_goal_error): Check if the current failure is a consequence
of building an included makefile and if so print an error.
(complain): Call show_goal_error() on rule failure.
* job.c (child_error): Call show_goal_error() on child error.
* main.c (main): Switch from struct dep to goaldep.
* misc.c (free_dep_chain): Not used; make into a macro.
* tests/scripts/features/include: Update and include new tests.
* tests/scripts/options/dash-B, tests/scripts/options/dash-W,
tests/scripts/options/print-directory,
tests/scripts/variables/MAKE_RESTARTS: Update known-good-output.
2016-04-09 20:06:46 -04:00
Paul Smith
e97159745d [SV 46995] Strip leading/trailing space from variable names
* makeint.h: Change MAP_SPACE to MAP_NEWLINE, and add MAP_PATHSEP
and MAP_SPACE which is now MAP_BLANK|MAP_NEWLINE.  Create
NEW_TOKEN(), END_OF_TOKEN(), ISBLANK(), ISSPACE() macros.
* main.c (initialize_stopchar_map): Set MAP_NEWLINE only for
newline characters.
* Convert all uses of isblank() and isspace() to macros.
* Examine all uses of isblank() (doesn't accept newlines) and
change them wherever possible to ISSPACE() (does accept newlines).
* function.c (func_foreach): Strip leading/trailing space.
* variable.c (parse_variable_definition): Clean up.
* tests/scripts/functions/foreach: Test settings and errors.
* tests/scripts/functions/call: Rewrite to new-style.
* tests/scripts/misc/bs-nl: Add many more tests for newlines.
2016-03-23 01:25:51 -04:00
Paul Smith
8164c8ab3d Clean up some compiler warnings.
* commands.c, commands.h: Use unsigned char for flags.
* dir.c: Use time_t and size_t, and char for a boolean value.
* job.c: Use unsigned and char.
* read.c: Return a signed type since -1 is a valid return code.
2016-03-08 23:40:46 -05:00
Paul Smith
798ebd241b Update Copyright statements for the new year. 2016-02-28 12:55:20 -05:00
Paul Smith
0205d3d08c [SV 45049] Check for '$' being the last character in a string.
* expand.c (variable_expand_string): Add a single '$' if '$' ends the
string.
* read.c (find_char_unquote, get_next_mword): Stop if '$' ends the
string.
* variable.c (parse_variable_definition): Ditto.
2015-07-12 13:25:16 -04:00
Paul Smith
9ef06be018 * read.c (unescape_char): [SV 45050] Handle final backslashes.
If the last thing in the string to be unescaped is a backslash,
stop without reading beyond the end of the string.
2015-07-12 12:39:59 -04:00
John Malmberg
c0380823a2 Fix VMS implicit rules and UNIX paths.
This fixes VMS implicit rules and UNIX style pathname handling.
It also fixes some of the VMS style pathname handling, more work
there will be needed later.
TODO: There are other case insensitive platforms besides VMS.
We need to find out why there is extra VMS code for this.  This
indicates either the extra VMS code is not needed, or the case
insensitive support may not be complete on the other case
insensitive platforms.

* default.c: Add missing definitions to default_suffix_rules[] and
default_variables[].
TODO: As it is important that VMS DCL mode definitions must always
be a superset of UNIX definitions, a better way of maintaining the
VMS DCL mode definitions should be devised.
* dir.c (downcase_inplace): Add a reentrant downcase() routine.
Add future support for VMS 8.2+ _USE_STD_STAT macro which will
disable a lot of VMS specific code from compiling.
(dir_file_exists_p): vmsify filename only if directory name has VMS
directory delimiters.
(file_exists_p): Handle both VMS and UNIX directories.
(file_impossible): Handle both VMS and Unix directories.  Track
whether a VMS format path is needed for the return value.
* file.c (lookup_file): Check if vmsify is needed; handle UNIX paths.
* implicit.c (pattern_search): Enable UNIX paths.
* read.c (parse_file_seq): Enable UNIX paths.
* remake.c (f_mtime): Fix gpath_search call for VMS paths.
* rule.c (count_implicit_rule): Enable UNIX paths, Fix VMS paths.
* vpath.c (selective_vpath_search): Enable UNIX paths.
2014-10-20 01:31:42 -04:00
Paul Smith
0a3a0756b9 Update Copyright statements for 2014. 2014-09-30 09:32:42 -04:00
Eli Zaretskii
1f2fd22fec Change the order of "makefile" and "Makefile" to match the manual. 2014-08-30 10:43:34 +03:00
Eli Zaretskii
ab1210b1fe Fix regression with "makefile" not being found on MS-Windows.
* read.c (read_all_makefiles) [WINDOWS32]: Recognize "makefile",
all-lowercase, as a makefile.  Reported by Michael Waeber
<waeber@gmail.com>.
2014-08-30 10:40:12 +03:00
Jonny Grant
cab353d1dd Fix defalt_makefiles[] for MS-Windows.
* read.c (read_all_makefiles) [WINDOWS32]: Remove the redundant
"makefile" and add "makefile.mak".

Copyright-paperwork-exempt: yes
2014-07-12 12:53:59 +03:00
Paul Smith
55c00544cc * read.c (eval): [SV 41677] Correct test for TAB vs. 8 spaces. 2014-07-07 03:43:57 -04:00
Paul Smith
423c3955d9 * various: Assume ISO C89-compliant free() implementation. 2014-07-07 01:59:03 -04:00
Paul Smith
ac67346d0f * maintMakefile, various: Improve constification of the codebase. 2014-07-07 01:59:03 -04:00
Paul Smith
30b25acc4e * read.c (unescape_char): Use memmove() for overlapping memory. 2013-11-24 03:45:38 -05:00
Paul Smith
757849cd93 [SV 40361] Don't use vsnprintf(), which is an ISO C99 function.
* output.c (error, fatal, message): Take an extra argument specifying
how many bytes are used by the formatted arguments.
(get_buffer): New function that allocates the requested buffer size.
Remove msc_vsnprintf(), vfmtconcat(), and fmtconcat() as unneeded.
* makeint.h: Declare various helper macros for generating output.
* *.c: Change all error(), fatal(), message() calls to use the macros,
or pass the extra length argument directly.
2013-11-23 22:23:52 -05:00
Paul Smith
53b4a9e668 * read.c (record_files): [SV 33034] Change fatal() to error()
Allows deprecated syntax.  However we don't guarantee this syntax
will continue to be legal in the future.
Change suggested by David Boyce <david.s.boyce@gmail.com>
2013-10-20 13:08:27 -04:00
Paul Smith
d654bff457 * read.c (eval): Avoid GCC warning to add braces. 2013-10-19 12:07:31 -04:00
Paul Smith
70df3c35bf [SV 40139] Modify "missing separator" for better translation 2013-10-13 16:48:23 -04:00
Paul Smith
dc9ae5e017 [SV 39709] Fix some typos. 2013-10-09 01:53:55 -04:00
Paul Smith
0296e40fc7 Allow loaded objects to opt out of the "auto-rebuild" feature. 2013-09-22 17:10:35 -04:00
Paul Smith
1a991ada47 Add VMS port updates from Hartmut Becker. 2013-09-22 17:10:34 -04:00
Paul Smith
1b90248893 [SV 27374] Fatal immediately on unrecoverable fopen() errors. 2013-09-15 17:09:01 -04:00
Paul Smith
40a49f244d [Bug #39310] Parse simple pattern prereqs for globbing.
We tried to get some efficiency by avoiding a parse_file_seq() for simple
pattern prerequisites, but this also means no wildcard expansion was
happening, so add it back.  Add regression tests for wildcards in target and
prerequisite lists.
2013-07-22 02:23:02 -04:00
Paul Smith
87ac68fe79 [Bug #39158] Source cleanups suggested by cppcheck utility. 2013-07-21 17:52:13 -04:00
Paul Smith
cc85b927cd Create a character map to use for locating stop-points in strings.
In various places we were passing flags and characters to compare, then
using complex conditionals to see where to stop in string searches.
Performance numbers reveal that we were spending as much as 23% of our
processing time in these functions, most of it in the comparison lines.
Instead create a character map and use a single bitwise comparison to
determine if this is any one of the stop characters.
2013-06-22 00:22:08 -04:00
Paul Smith
c11024b3b3 [SV #38945] Copy the entire buffer back when overwriting CR 2013-05-26 14:41:45 -04:00
Paul Smith
2fc0f614be [SV #39028] Fix some small typos in messages. 2013-05-26 14:06:25 -04:00
Paul Smith
a674abe702 Make MFLAGS and MAKEFLAGS more reliable and predictable.
Ensure all simple flags are kept in the initial batch of flags.
Do not allow any flags with options in that batch.
If there are only non-simple flags ensure MAKEFLAGS begins with " ".
Don't let MFLAGS start with "- ".
2013-05-22 02:14:19 -04:00
Paul Smith
96cf67bd29 Update source file format: remove TABs, use GNU coding styles. 2013-05-17 02:29:46 -04:00
Paul Smith
5370238316 Update copyright for changes in 2013. 2013-05-17 01:47:42 -04:00