flush() must not do anything more than necessary. Determining the type
of input files must be done only once, before flush. Fortunately, we
don't even need any file system accesses to do this since that
information is statically known in most cases, and in the rest of the
cases can be determined by file extension alone.
This commit also updates the nearby code to conform to the convention
for error handling where there is exactly one error code to represent
the fact that error messages have already been emitted. This had the
side effect of improving the error message for a linker script parse
error.
"positionals" is not a linker concept; it is a command line interface
concept. Zig's linker implementation should not mention "positionals".
This commit deletes that array list in favor of directly making function
calls, eliminating that heap allocation during flush().
The goal is to minimize as much as possible how much logic is inside
flush(). So let's start by moving out obvious stuff. This data can be
preformatted before flush().
This commit changes how `std.io.poll` is implemented on Windows. The new
implementation unfortunately incurs a little extra system call overhead,
but fixes several bugs in the old implementation:
* The `lpNumberOfBytesRead` parameter of `ReadFile` was used with
overlapped I/O. This is explicitly disallowed by the documentation, as
the value written to this pointer is "potentially erroneous"; instead,
`GetOverlappedResult` must always be used, even if the operation
immediately returns. Documentation states that `lpNumberOfBytesRead`
cannot be passed as null on Windows 7, so for compatibility, the
parameter is passed as a pointer to a dummy global.
* If the initial `ReadFile` returned data, and the next read returned
`BROKEN_PIPE`, the received data was silently ignored in the sense
that `pollWindows` did not `return`, instead waiting for data to come
in on another file (or for all files to close).
* The asynchronous `ReadFile` calls which were left pending between
calls to `pollWindows` pointed to a potentially unstable buffer, since
the user of `poll` may use part of the `LinearFifo` API which rotate
its ring buffer. This race condition was causing CI failures in some
uses of the compiler server protocol.
These issues are all resolved. Now, `pollWindows` will queue an initial
read to a small (128-byte) stable buffer per file. When this read is
completed, reads directly into the FIFO's writable slice are performed
until one is left pending, at which point that read is cancelled (with a
check to see if it was completed between the `ReadFile` and `CancelIo`
calls) and the next read into the small stable buffer is queued. These
small buffer reads are the ones left pending between `pollWindows`
calls, avoiding the race condition described above.
Related: #21565
Throw another target in there just to spice things up a little!
Running the incremental cases with the C backend is pretty slow due to
the need to recompile the whole output from scratch on every update; for
this reason, we probably don't want to keep many of these targeting CBE
long-term. However, for now, while we have relatively few tests and
things are still changing quite a lot, it's better to have this little
bit of extra test coverage.
If no external executor is available for a successful binary, its
execution is silently skipped. This allows the CI to test, to the
fullest extent possible, incremental cross-compilation to targets whose
binaries can't be executed on the host.
This is contained in the `test` step, so is tested by CI.
This commit also includes some enhancements to the `incr-check` tool to
make this work correctly.