This fixes a number problems with the old stream handling:
1. Not possible to set a custom errno (necessary for proper interrupt
handling and possibly for other things)
2. Inefficient: in a lot of cases we have data in one buffer and we need
it placed into a different buffer, but we have to implement a function
that gets one byte out of the source buffer and then call it repeatedly
to move one byte at a time to the target buffer.
3. Ease of implementation: in many cases we already have perfectly good
buffer manipulation APIs, so if we have direct access to the true source
or target buffer we can just use these. See: the node IO code, which got
much simpler.
This is backwards compatible, so you can still use the old input mechanism
or use buffered or raw output. But it adds a new method of directly implementing
read/write. For simplicity, we insure that the source/destination buffers are
always `Uint8Array` views that point to exactly the region that is meant to be
read/written.
The old mechanisms are faster than before and can correctly support keyboard
interrupts. Other than that I think the original behavior is unchanged. I added a
lot more test coverage to ensure backwards compatibility since there was pretty
anemic coverage before.
I think the read/write APIs are mostly pretty simple to use, with the exception
that someone might forget to return the number of bytes read. JavaScript's ordinary
behavior coerces the `undefined` to a 0, which leads to an infinite loop where the
filesystem repeatedly asks to read/write the same data since it sees no progress.
I added a check that writes an error message to the console and sets EIO when undefined
is returned so the infinite loop is prevented and the problem is explained.
Having to add `emsdk/upstream/emscripten` to all the emscripten patches is a
nuisance. If at some point we want to patch a file in a different folder, we can
separate the patches into multiple folders. In particular this should make it
easy to migrate patches using `git am`, `git rebase`, and `git format-patch`.
Binaryen now invokes cc instead of gcc, and the cc symlink isn't in
/usr/lib/ccache. This replaces the implementation in #1014.
This has the disadvantage that build is now broken if ccache is not
available.
1. Split long shell command into multiple commands
2. Make BINARYEN_VERSION a variable instead of hardcoding in Makefile
3. Set Makefile.envs and patches as dependencies
* Update to use sdk-fastcomp-tag-<version> for emscripten, as sdk-tag-<version> is no longer available upstream.
* Update code to use new path
* Replace Circle-CI CPU_CORES hack with environment variables (now supported upstream)
Co-authored-by: AndyLockhart <AndyLockhart@users.noreply.github.com>