Fix incorrect "function in Table but not functionsInTableMap" assertions
by adding new entries in the table from a side module to
functionsInTableMap.
Fixes#13347Fixes#13040
* Add support for emmalloc for 4GB heap sizes. Fix an issue that caused -s MAXIMUM_MEMORY=4G -s ABORTING_MALLOC=0 to crash, instead of returning zero on failed growth operation. Remove the unnecessary 16MB minimum heap growth size clamp: heap growth is not that costly, and 16MB can be excessive for tiny applications. Add emmalloc-debug and emmalloc-debug-log MALLOC options that allow building emmalloc with its debugging options, without needing to manually edit emmalloc.cpp sources to activate. Remove old asm.js/32-bit only code in emmalloc. Remove old workaround for wasm2js codegen bug in emmalloc.
* Update embuilder.py.
* Rename emmalloc special targets to "memvalidate" and "verbose", and adjust their variations to fix embuilder.py.
* Update tests.
* Update variations.
* Fix emmalloc system lib naming.
* Fix memory region merging check and test_emmalloc naming.
* Address review
* Fix case on test_zzz_zzz_4gb_fail
* Rebaseline code size tests
Since we don't have many users who use RELOCATABLE directly it
went unnoticed that setting this option on its own was causing all
symbols to be included and exported.
Fixes#13029
This extra argument (include_internal) and the extra complexity
it entailed had only a single call site in the test suite.
Calling llvm-nm directly in the test suite is much simpler.
Remove the optimization (again) for the special case of single object
input, which skips the linker and directly copies the input object file
to output.
This behavior interferes with linking (merging) all objects in a
library archive into a single object, done with the following command:
cc -o lib.o -r -Wl,--whole-archive lib.a
The optimization was once useful when no clear distinction was made
between compile mode and link-only mode. It was also required for
compatibility (see #9510 and #9571).
However, #9510 was addressed by #9511, and #9600 introduced the '-r'
flag that allows to explicitly indicate linking to an object, making the
optimization less useful.
Although not strictly defined by POSIX, it is done by most (all?)
other implementations, most often in patches over the years as
places got forgotten.
This is mostly useful to allow quick comparing between sockaddr_in
to see if they are the same address.
Fixes#12998
As part of the pending musl update we can no longer (or at least it
becomes problematic) to compile internal musl headers alongside the
public headers. To avoid this, this change updates gen_struct_info.py
to compile internal headers separately.
To facilitate this, this change adds support for compiling groups of
headers and merging the results into a single json output.
As part of debugging this I added support for compiling every header
file in isolation. While this is slow, it uncovered a couple of
issues where structs and defines that were listed under the wrong
header and also a header that could not be compiled on its own
(SDL_pixels.h).
We had a bug that only showed up with symbols that start with `$_`.
These happen to exist in `library_fetch.js` e.g:
`$__emscripten_fetch_xhr`. In this case, when we mangle, we remove the
leading `$` giving `__emscripten_fetch_xhr`, and then if we demangle we
do that wrong thing and end up removing the `_` instead of re-adding the
`$`.
This change avoids the round trip by always storing both the mangled
and demangled version of a given symbol.
See #12268
Rather than adding various include paths, copy any needed headers into
the sysroot along with any libraries.
This means that emscripten can work a lot more like the
traditional cross compiler (e.g. clang -target=xxx --sysroot=yyy),
and we can start to think of the emscripten driver as a seperate
thing to the sysroot.
Fixes: #9353
Since some build tools run `emcc -v` regularly we want to be fast. This
change avoid running sanity checks which means fewer subprocesses.
On my machine this takes `emcc -v ` from ~300 to ~200 ms.
Add a new options `--check` which will force the running of sanity
checks.
See: #13004
Adds an INITIAL_MEMORY option that can be used to ensure that the instrumented
and split modules use the same table size. This is necessary because the table
is created in JS when using dynamic linking, so the table size is baked in to
the JS shared by the instrumented and split builds.
Also makes the dynamic linking infrastructure ignore all exports that start with
`%`. Users should pass --export-prefix='%' to wasm-split so that all of its
synthesized exports will make it through to the secondary module without
interference from the dynamic linker.
Generated using:
`perl -pi -e "s/('-s', '[A-Z_]*)=1'/\1'/g" tests/*.py`
This is good because it is less noise in the test commands, but it also
serves to remind folks reading the tests that this is the easiest
(prefered) way to set settings.
For now, the proxy handler synchronously instantiates the deferred module, then
forwards the original call to the newly patched table slot. This PR extracts the
`instantiateSync` function out of `createWasm` so that the proxy handler can use
it as well.
Updates the existing SPLIT_MODULE test so that the profile will be empty,
causing all functions to be placed in the deferred module.
Explictly depend on the internal thread functions that we need, and
allow unused ones to be DCE'd.
The biggest win here was removing the forced dependency on vsnprintf
which was being pulled in via
`emscripten_sync_run_in_main_thread_xprintf_varargs`. Interestingly
this function doesn't seem to have any callers at all but I assume
it has some use so leaving it in the code for now.
Calling realpath with SAFE_HEAP enabled was causing a read of
address zero because realpath calls sys_open with a third argument
and therefor without any varargs at all
Fixes: #12999
This test needs to be disaled so that a recent llvm change
can roll: https://reviews.llvm.org/D93066
It causes the following diff/failure:
```
AssertionError: Unexpected difference:
--- /b/s/w/ir/k/install/emscripten/tests/other/metadce/hello_world_O3_MAIN_MODULE_2.funcs
+++ /b/s/w/ir/k/install/emscripten/tests/other/metadce/hello_world_O3_MAIN_MODULE_2.funcs.new
@@ -4,7 +4,8 @@
$__overflow
$__stdio_write
$__towrite
-$__wasm_apply_relocs
+$__wasm_apply_data_relocs
+$__wasm_apply_global_relocs
$__wasm_call_ctors
$dlmalloc
$fwrite
```
Modifying this global state seems wrong. Its probably safe because when
we run tests in parallel we use seperate processes, but it wouldn't work
if we switched to using threads.
Instead maintain test-local list of JS engines, and also a seperate list
of extra arguments for node and/v8.
This prevents the user from seeing backtraces like:
```
Traceback (most recent call last):
File "./emcc.py", line 3310, in <module>
sys.exit(main(sys.argv))
File "./emcc.py", line 3303, in main
ret = run(args)
File "./emcc.py", line 916, in run
options, settings_changes, user_js_defines, newargs = parse_args(newargs)
File "./emcc.py", line 2446, in parse_args
options.pre_js += open(consume_arg_file()).read() + '\n'
FileNotFoundError: [Errno 2] No such file or directory: 'foo.js'
```
Just like emcc and other tools we don't need to know internally
that this is python tool. Plus using the launcher script means
we are testing whata our users will run.
This option uses the new wasm-split tool in binaryen to generate profile
data and then split a module into a primary and secondary component
modules that can be linked together at runtime.
Also rename to test_html5_core so that running test_html5_core*
can be used to run all the variants without matching other tests
that exist with that prefix.