Commit Graph

2396 Commits

Author SHA1 Message Date
Paul Smith
8b54c5cff9 * job.c (child_execute_job): Fix $(shell...) under NO_OUTPUT_SYNC.
* main.c (decode_output_sync_flags): Use NONE for NO_OUTPUT_SYNC.
2016-04-04 01:38:32 -04:00
Paul Smith
65c447289e * main.c (main): Restrict disabling debugging for MAKEFILES. 2016-04-04 01:36:08 -04:00
Paul Smith
86b20728fe * Makefile.am, w32/Makefile.am: Fix *os.c for Windows builds.
Original change provided by Luke Allardyce <lukeallardyce@gmail.com>
2016-04-04 01:36:08 -04:00
Paul Smith
b8a8af6550 * make.texi: Confirm that CURDIR contains an absolute path. 2016-04-04 01:36:08 -04:00
Paul Smith
360b76af84 * docs/make.texi: [SV 47392] Add "Integrating make" chapter. 2016-04-04 01:36:08 -04:00
Paul Smith
c9e6ab9ac7 Change --jobserver-fds to more generic --jobserver-auth.
* NEWS: Mention the change.
* main.c: Rename jobserver_fds variable to jobserver_auth and
--jobserver-fds option to --jobserver-auth.
* os.h, posixos.c, w32/w32os.c: Rename jobserver_parse_arg() and
jobserver_get_arg() to jobserver_parse_auth()/jobserver_get_auth().
2016-04-04 01:36:08 -04:00
Paul Smith
40277b8850 * tests/run_make_tests.pl: Preserve $make_command
* tests/scripts/options/dash-n: Use $make_command.  This fixes
a spurious failure when running tests with valgrind enabled.
2016-03-23 01:26:55 -04:00
Paul Smith
35047f824a * variable.c: Clean up some memory leaks. 2016-03-23 01:26:04 -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
2b9dd215d5 * function.c (func_file): Support reading from files.
* NEWS: Add information about reading files.
* make.texi (File Function): Describe reading files.
* tests/scripts/functions/file: Test new features for $(file ...)
2016-03-21 00:44:53 -04:00
Paul Smith
fc2ddebdae * doc/make.texi (Setting Variables): Fix typo (add comma). 2016-03-20 14:23:46 -04:00
Paul Smith
b4682cb479 * job.c (child_error): Combine file info with error message.
* tests/scripts/...: Update error message matches.
2016-03-20 14:23:22 -04:00
Paul Smith
09202bc880 * variable.c: Align type of variable_changenum. 2016-03-19 17:23:19 -04:00
Paul Smith
9ae02b7916 [SV 45728] Detect changes in .VARIABLES more accurately.
For performance, we only recompute .VARIABLES when (a) it's expanded
and (b) when its value will change from a previous expansion.  To
determine (b) we were checking the number of entries in the hash
table which used to work until we started undefining entries: now if
you undefine and redefine the same number of entries in between
expanding .VARIABLES, it doesn't detect any change.  Instead, keep
an increasing change number.
* variables.c: Add variable_changenum.
(define_variable_in_set, merge_variable_sets): Increment
variable_changenum if adding a new variable to the global set.
(undefine_variable_in_set): Increment variable_changenum if
undefining a variable from the global set.
(lookup_special_var): Test variable_changenum not the hash table.
* tests/scripts/variables/special: Test undefining variables.
2016-03-13 18:23:20 -04:00
Paul Smith
247b71e690 * main.c(main): Disable output sync without parallel builds. 2016-03-13 15:59:12 -04:00
Paul Smith
e33f3d72bf [SV 46581] Pre-define .LOADED to avoid warnings.
* main.c (main): Pre-define .LOADED as a default-level variable.
* load.c (load_file): Set the value rather than append it.  Avoid
adding an extra initial whitespace.
* tests/scripts/features/load: Run with --warn-undefined-variables.
2016-03-13 03:02:00 -04:00
Paul Smith
fd1dd7c398 [SV 44555] Use vfork() instead of fork() where available.
Testing has shown that vfork() is actually significantly
more efficient on systems where it's supported, even for
copy-on-write implementations.  If make is big enough,
duplicating the page tables is significant overhead.

* configure.ac: Check for fork/vfork.
* makeint.h: Include vfork.h and set up #define for it.
* os.h, posixos.c (get_bad_stdin): For children who can't use
the normal stdin file descriptor, get a broken one.
* job.c (start_job_command): Avoid so many ifdefs and simplify
the invocation of child_execute_job()
(child_execute_job): move the fork operation here so it can
return early for the parent process.  Switch to use vfork().
* function.c (func_shell_base): Use new child_execute_job() and
simplify ifdefs.
* job.h, main.c, remote-cstms.c, vmsjobs.c, w32os.c: Update
declarations and calls.
2016-03-13 01:12:07 -05:00
Paul Smith
14b2d7effb * job.c (exec_command): [SV 47365] Show error on exec failure. 2016-03-09 00:18:57 -05:00
Paul Smith
85c788572d [SV 46261] Use pselect() for jobserver where supported.
* Makefile.am, configure.ac: Check for pselect() and sys/select.h.
* main.c (main): Block SIGCHLD if we have pselect() support.
* posixos.c (jobserver_acquire): If we support pselect() then use
it to query the jobserver pipe, while also listening for SIGCHLD.
Also pselect() supports a timeout so avoid alarm() calls.
2016-03-08 23:40:46 -05: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
fb7a7adc8a Extract jobserver implementation into OS-specific files.
* os.h, posixos.c, w32/w32os.c: New files implementing jobserver.
* job.c, job.h, main.c, makeint.h: Move content to new files.
* w32/include/sub_proc.h, w32/subproc/sub_proc.c: Ditto.
* Makefile.am: Build and package OS-specific files.
* build_w32.bat, make_msvc_net2003.vcproj, README.W32.template:
Update for new files, and clean up the build.
* POTFILES.in, maintMakefile, NMakefile.template: Ditto.
* w32/subproc/build.bat: Delete as unused.
2016-03-08 23:40:46 -05:00
Paul Smith
4f8be4bb28 [SV 46261] Add more EINTRLOOP wrappers.
This cannot be a perfect solution because there are always other
possible places EINTR can happen, including external libraries
such as gettext, Guile etc.
2016-03-08 00:31:47 -05:00
Paul Smith
e2b39edc22 * strcache.c (add_hugestring): [SV 46832] Support huge strings.
The strcache was limited to strings of length 65535 or less,
because the length is kept in an unsigned short.  To support
huge strings add a new simple linked list, which we don't try
to hash.
2016-02-29 01:35:02 -05:00
Paul Smith
8530d77c68 * strcache.c (add_string): [SV 47071] Handle huge initial string.
If the very first string added to the string cache is more than
half the maximum size, we failed when moving the only strcache
buffer to the full list.
2016-02-29 01:35:02 -05:00
Paul Smith
89e18c12eb [SV 47151] Exit with 1 when checking recursive make -q
* job.h (struct child): New bit to mark recursive command lines.
* job.c (start_job_command): Set the recursive command line bit.
(reap_children): If the child is a recursive command and it exits
with 1 during question mode, don't print an error and exit with 1.
* tests/scripts/options/dash-q: Add a regression test.
2016-02-29 01:33:50 -05:00
Paul Smith
bccd01354b * main.c (define_makeflags): Add parens to avoid GCC warning. 2016-02-29 01:32:12 -05:00
Paul Smith
5f9d341160 * tests/scripts/features/archives: Handle deterministic archives.
Newer versions of binutils allow ar to be compiled to generate
"deterministic archives" by default: in this mode no timestamp
information is generated in the static archive, which utterly
breaks GNU make's archive updating capability.  Debian and Ubuntu
have turned this feature on by default in their distributions
which causes the regression tests to fail.

Update the regression tests to check for the availability of the
"U" option to ar which disables deterministic archives and allows
GNU make's archive support to work properly again.
2016-02-29 01:31:16 -05:00
Paul Smith
798ebd241b Update Copyright statements for the new year. 2016-02-28 12:55:20 -05:00
Paul Smith
4db6d0c694 * doc/make.texi: [SV 47163] Fix typo in 'ifdef' documentation. 2016-02-28 12:41:41 -05:00
Paul Smith
b754a35df7 * doc/make.texi: [SV 35455] Add more uses for Empty Recipes. 2016-02-28 12:35:15 -05:00
Gisle Vanem
168f12375d Fix diagnostics on MS-Windows when environment is too large
* w32/subproc/sub_proc.c (process_begin): Fix test of the error
	cause when the environment block is too large.

Copyright-paperwork-exempt: yes.
2015-11-07 11:27:03 +02:00
Eli Zaretskii
83443c706a Update README.W32.template
* README.W32.template: Update for latest developments.  Make it
clear we don't recommend using HAVE_CASE_INSENSITIVE_FS in
general.
2015-10-27 20:51:43 +02:00
Eli Zaretskii
4a5377aef7 [SV 46304] Don't invoke C++ compiler on C sources on MS-Windows
* default.c (default_variables) [HAVE_CASE_INSENSITIVE_FS]: Make
COMPILE.C and LINK.C be synonyms for COMPILE.c and LINK.c,
respectively.
2015-10-27 20:47:27 +02:00
Eli Zaretskii
48391c2817 [SV 45838] When invoking w32 programs, don't use free'd memory.
* w32/subproc/sub_proc.c (process_begin): Freeing argv[0] makes
the other argv[i] pointers invalid, so need to allocate a new
array and copy argv[i] for i != 0 first, replacing argv[0] with
the batch file name, before we can free argv[0].
2015-09-23 11:42:53 +03:00
Paul Smith
42745a900f * implicit.c (pattern_search): [SV 43677] Mark files secondary.
In order to fix SV 12267 we were marking the prerequisites of
implicit (pattern) targets that existed elsewhere in the makefile
as precious to keep them from being deleted as intermediate files.
However this also keeps them from being deleted on error.  Instead
mark them as secondary.
* tests/scripts/targets/DELETE_ON_ERROR: Test DELETE_ON_ERROR.
2015-07-13 00:51:35 -04:00
Paul Smith
43181f1f82 [SV 28092] Preserve the exit status of the $(shell...) function.
Add a new variable .SHELLSTATUS which holds the exit status of the
last-invoked shell function or != assignment.

* NEWS, doc/make.texi: Document the change.
* function.c (shell_completed, msdos_openpipe, func_shell_base): Add
shell_completed() to handle the completion of the shell, by setting
.SHELLSTATUS.  Call it where needed.
* job.c (child_handler): Call shell_completed().
* tests/scripts/functions/shell: Add tests for .SHELLSTATUS.
2015-07-12 21:03:24 -04:00
Paul Smith
c18b23f7b2 * tests/scripts/misc/fopen-fail: [SV 42390] Increase test timeout.
* Makefile.am (check-regression): Force ulimit -n for fopen-fail test.
2015-07-12 18:19:01 -04:00
Paul Smith
fe5585528f * job.c: [SV 43936] Check sigaction for error return. 2015-07-12 17:29:05 -04: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
Paul Smith
ac9a39dad7 * strcache.c: [SV 45275] Handle very long strings.
Our previous behavior for handling too-long strings involved
increasing the size of the default string cache buffer, but the
implementation was incomplete.  Instead, create a one-off large
string cache entry and add it directly to the full cache list
without changing the default buffer size.
2015-07-12 00:14:19 -04:00
Duncan Moore
c6ac580785 * job.c [RISCOS]: Remove logic that is no longer required.
Signed-off-by: Paul Smith <psmith@gnu.org>
Copyright-paperwork-exempt: yes
2015-07-12 00:14:19 -04:00
Paul Smith
9efd477e98 * remake.c (update_file): [SV 44742] Keep double-colon rule status.
Fix suggested by Everett Boyer <EvBoyer@aol.com>
2015-07-12 00:14:14 -04:00
James Johnston
5036dd120a [SVN 45515] Check exit status of sub-make in subproc.bat
* subproc.bat: Exit when sub-make invocation fails.

Copyright-paperwork-exempt: yes
2015-07-10 09:56:27 +03:00
Eli Zaretskii
7e849f3b81 [SV 45515] Ignore Windows-specific build artifacts
* .gitignore: Ignore *.exe, *.dll.a, *.lib, *pdb, and a few more MSVC
specific artifacts.
Suggested by James Johnston <johnstonj.public@codenest.com>
2015-07-10 09:50:27 +03:00
Eli Zaretskii
a80a8b8a10 [SV 44348] Fix handling of shell widlcards on MS-Windows.
* job.c (construct_command_argv_internal): If shell wildcard
	characters are found inside a string quoted with "..", give up the
	fast route and go through the shell.  Fixes Savannah bug #44348.
2015-02-28 14:34:51 +02:00
John Malmberg
e4ac28e830 Fix bs-nl handling, exit and Environment for VMS.
This fix required a complete rewrite of the command parser vmsjobs.c
child_execute_job.  The old parser had too many incorrect assumptions
about DCL commands and could not be repaired to extended.

The parser now more closely parses VMS commands and handles quoted
commands and redirection.  Command File mode has been improved, but can
not fully support bs-nl syntax.

VMS Unix shell simulation has been improved.

* commands.c: vms_comma_separator is now a run-time setting.
* function.c: vms_comma_separator is now a run-time setting.
* function.c(func_basename_dir) now reports "[]" or "./" based on
  VMS crtl runtime setting.
* job.c(start_job_command): VMS Handle empty commands propery.
* main.c: Add VMS environment variables for run-time settings.
  * vms_legacy_behavior - Force older behavior.
  * vms_comma_separator - Commas or spaces for separators.
  * vms_unix_simulation - Enhanced Posix shell simulation features.
  * Detect if VMS CRTL is set to report Unix paths instead of VMS.
  * ':' and '>' are also MAP_DIRSEP on VMS.
* makeint.h: Add VMS run-time option variables.
* readme.vms: Update to current behavior.
* variable.c(define_variable_in_set): Fix VMS Environment variable
  lookup.
* variable.c(define_automatic_variables): Remove some VMS specific
  automatic variables and use the Unix ones instead.
* vms_export_symbol.c: Set max symbol size correctly.
* vmsjobs.c: child_execute_job() complete rewrite of VMS comand
  parsing.
* vmsjobs.c(build_vms_cmd): VMS commmand building with shell simulation.

Signed-off-by: Paul Smith <psmith@gnu.org>
2015-01-27 21:43:16 -05:00
Christian Boos
1fae20a2b7 Fix $(shell) on hosts with 64-bit pid_t.
* function.c: Use pid_t for shell_function_pid.
* job.c: Likewise.

Copyright-paperwork-exempt: yes
2014-12-27 10:55:01 +02:00
Paul Smith
292da6f686 * main.c (main): [SV 43434] Handle NULL returns from ttyname(). 2014-10-20 01:54:56 -04:00
Benedikt Morbach
3c487e7ed5 * tests/scripts/features/archives: [SV 43405] override AR variable.
Copyright-paperwork-exempt: yes
2014-10-20 01:45:09 -04:00