summaryrefslogtreecommitdiff
path: root/src/tools/wasm-emscripten-finalize.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add some tracing to wasm-emscripten-finalize (#2505)Sam Clegg2019-12-051-8/+13
| | | | | Also fix, but in splitting the names of the trace channels. Obviously I can't write string.split correctly in C first time around.
* Convert to using DEBUG macros (#2497)Sam Clegg2019-12-041-4/+2
| | | | | | This means that debugging/tracing can now be enabled and controlled centrally without managing and passing state around the codebase.
* Support --pass-arg in ToolOptions. (#2429)Alon Zakai2019-11-111-0/+1
| | | | | | This will allow us to pass pass args to wasm-emscripten-finalize, which runs legalize-js-interface internally, which recently added an optional argument.
* Don't add __wasm_call_ctors to startup function list in wasm standalone mode ↵Sam Clegg2019-10-141-2/+6
| | | | | (#2384) In this mode crt1 takes care of calling it.
* wasm-emscripten-finalize: Add more checking of __data_end global (#2352)Sam Clegg2019-09-231-0/+3
|
* Add a --standalone-wasm flag to wasm-emscripten-finalize (#2333)Alon Zakai2019-09-181-1/+17
| | | The flag indicates that we want to run the wasm by itself, without JS support. In that case we don't emit JS dynCalls etc., and we also emit a wasi _start if there is a main, i.e., we try to use the current conventions in the wasm-only space.
* wasm-emscripten-finalize: Remove reliance on name section (#2285)Sam Clegg2019-08-061-1/+1
| | | | | | | | There were a couple of places where we were relying on internal names and therefore a name section. After this change wasm-emscripten-finalize works correctly on binaries without a name section at all and only relies on the names of imports and exports.
* Implement --check-stack-overflow flag for wasm-emscripten-finalize (#2278)Guanzhong Chen2019-08-021-0/+12
|
* wasm-emscripten-finalize: Internalize mutable __stack_pointer import (#2213)Sam Clegg2019-07-101-0/+1
| | | | | | | | | | | I'm working on a change to lld that will cause `-pie` binaries to import __stack_pointer, just like -shared do already. Because we don't yet support mutable globals everywhere this change will internalize the import and create a new immutable import that is used to initialize the internal one. This change is part of the fix for: https://github.com/emscripten-core/emscripten/issues/8915
* Ignore --initial-stack-pointer arg to wasm-emscripten-finalize (#2201)Sam Clegg2019-07-101-9/+4
| | | | | | | | | | | | | We were passing bad value in --initial-stack-pointer which did not include the STATIC_BUMP (since STATIC_BUMP is determinted by the output of finalize). If emscripten wants to set the stack pointer position it can do so by calling the stackRestore() function at startup. This argument will be removed completely once we stop passing it on the emscripten side. See https://github.com/emscripten-core/emscripten/issues/8905
* Allow color API to enable and disable colors (#2111)Siddharth2019-05-171-1/+1
| | | | | | This is useful for front-ends which wish to selectively enable or disable coloring. Also expose these APIs from the C API.
* clang-tidy braces changes (#2075)Alon Zakai2019-05-011-2/+4
| | | Applies the changes in #2065, and temprarily disables the hook since it's too slow to run on a change this large. We should re-enable it in a later commit.
* Apply format changes from #2048 (#2059)Alon Zakai2019-04-261-61/+89
| | | Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
* Move features from passOptions to Module (#2001)Thomas Lively2019-04-121-2/+2
| | | | | This allows us to emit a (potentially modified) target features section and conditionally emit other sections such as the DataCount section based on the presence of features.
* Add feature options to emscripten metadata (#1982)Thomas Lively2019-04-051-5/+13
| | | Emscripten runs wasm-emscripten-finalize before running wasm-opt, so the target features section is stripped out before optimizations are run. One option would have been to add another wasm-opt invocation at the very end to strip the target features section, but dumping the features as metadata avoids the extra tool invocation. In the long run, it would be nice to have only as single binaryen invocation to do all the work that needs doing.
* wasm-emscripten-finalize: add namedGlobals to output metadata (#1979)Sam Clegg2019-04-041-6/+5
| | | | | | This key is used by emscripten when building with MAIN_MODULE in order to export global variables from the main module to the side modules.
* wasm-emscripten-finalize: Improve shared library support (#1961)Sam Clegg2019-04-021-12/+13
| | | | | | | | | | | | | | | | | Convert PIC code generated by llvm to work with the current emscripten ABI for dynamic linking: - Convert mutable global imports from GOT.mem and GOT.func into internal globals. - Initialize these globals on started up in g$foo and f$foo imported functions to calculate addresses at runtime. Also: - Add a test case for linking and finalizing a shared library - Allow __stack_pointer global to be non-existent as can be case for a shared library. - Allow __stack_pointer global to be an import, as can be the case for a shared library.
* Add strip-target-features pass (#1946)Thomas Lively2019-03-141-0/+1
| | | And run it in wasm-emscripten-finalize. This will prevent the emscripten output from changing when the target features section lands in LLVM.
* wasm-emscripten-finalize: Remove JSCall thunk generation (#1938)Sam Clegg2019-03-121-11/+1
| | | | We now implement addFunction by creating a wasm module to wrap that JS function and simply adding it to the table.
* wasm-emscripten-finalize: separateDataSegments() fix (#1897)Alon Zakai2019-02-061-1/+4
| | | | | We should emit a file with only the data segments, starting from the global base, and not starting from zero (the data before is unneeded, and the emscripten loading code assumes it isn't there). Also fix the auto updater to work properly on .mem test updating.
* Fix EM_ASM+pthreads (#1891)Alon Zakai2019-02-041-6/+9
| | | To calculate the metadata, we must look at the segments. If we split them out earlier (which we do for threads), they aren't there.
* wasm-emscripten-finalize: Emit illegal dynCalls, and legalize them (#1890)Alon Zakai2019-01-291-12/+15
| | | Before this, we just did not emit illegal dynCalls. This was wrong as we do need them (e.g. if a function with a setjmp call calls a function with an i64 param - we'll have an invoke with that signature there). We just need to legalize them. This fixes that by first emitting them, and second by running legalization late, after dynCalls have been generated, so it legalizes them too.
* Handle EM_ASM/EM_JS in LLVM wasm backend O0 output (#1888)Alon Zakai2019-01-281-8/+10
| | | | | | | See emscripten-core/emscripten#7928 - we have been optimizing all wasms until now, and noticed this when the wasm object file path did not do so. When not optimizing, our methods of handling EM_ASM and EM_JS fail since the patterns are different. Specifically, for EM_ASM we hunt for emscripten_asm_const(X, where X is a constant, but without opts it may be a get of a local. For EM_JS, the function body may not just contain a const, but a block with a set of the const and a return of a get later. This adds logic to track gets and sets in basic blocks, which is sufficient to handle this.
* Emscripten stack simplification (#1870)Alon Zakai2019-01-161-3/+17
| | | | | | This takes advantage of the recent memory simplification in emscripten, where JS static allocation is done at compile time. That means we know the stack's initial location at compile time, and can apply it. This is the binaryen side of that: * asm2wasm support for asm.js globals with an initial value var X = Y; where Y is not 0 (which is what the stack now is). * wasm-emscripten-finalize support for a flag --initial-stack-pointer=X, and remove the old code to import the stack's initial location.
* Partial legalization (#1824) review followup (#1832)Alon Zakai2018-12-171-1/+2
|
* Minimal JS legalization (#1824)Alon Zakai2018-12-141-8/+9
| | | | | Even when we don't want to fully legalize code for JS, we should still legalize things that only JS cares about. In particular, dynCall_* methods are used from JS to call into the wasm table, and if they exist they are only for JS, so we should only legalize them. The use case motivating this is that in dynamic linking you may want to disable legalization, so that wasm=>wasm module calls are fast even with i64s, but you do still need dynCalls to be legalized even in that case, otherwise an invoke with an i64 parameter would fail.
* wasm-emscripten-finalize: import env.STACKTOP, like asm2wasm doesAlon Zakai2018-12-111-0/+1
|
* Format metadata json using mutliple lines for readability (#1804)Sam Clegg2018-12-051-1/+3
|
* Fix initializerFunctions output by wasm-emscripten-finalize (#1803)Sam Clegg2018-12-051-1/+2
| | | I broke this to be alwasy empty in #1795.
* wasm-emscripten-finalize: ensure table/memory imports use emscripten's ↵Sam Clegg2018-12-031-8/+17
| | | | | | | | expected names (#1795) This means lld can emscripten can disagree about the naming of these imports and emscripten-wasm-finalize will take care of paper over the differences.
* wasm-emscripten-finalize: Remove stack pointer global from shared libs (#1791)Sam Clegg2018-11-301-6/+15
| | | | | | | | | | | | | The wasm backend uses a wasm global (__stack_pointer) for the shadow stack location. In order to make this work with shared libraries the main module would have to export this global and shared libraries would need to import it. This means we'd be relying of mutable globals which are not yet implemented in all browsers. This change allows is to move forward with shared libraries without mutable global support by replacing all stack pointer access in shared libraries with functions calls.
* wasm-emscripten-finalize: Initial support for handling shared libraries (#1746)Sam Clegg2018-11-151-13/+26
| | | | In this case we won't want generate any of the normal memory helper functions (they come from the main module).
* Add wasm-emscripten-finalize flag to separate data segments into a file (#1741)Derek Schuff2018-11-141-0/+8
| | | | This writes the data section into a file suitable for use with emscripten's --memory-init-file flag
* Run legalize-js-interface during wasm-emscripten-finalize (#1653)Sam Clegg2018-08-291-0/+17
| | | | This ensures that 64-bit values are correctly handled on the JS boundary.
* wasm-emscripten-finalize: make _wasm_call_ctors optional (#1647)Sam Clegg2018-08-281-1/+3
|
* Remove s2wasm (#1607)Sam Clegg2018-06-281-1/+0
| | | | s2wasm is no longer used my emscripten and as far as I know now as no other users.
* Add source map handling to wasm-emscripten-finalize (#1595)Sam Clegg2018-06-101-5/+21
|
* Handle parse errors in wasm-emscripten-finalize (#1589)Sam Clegg2018-06-061-1/+7
|
* Add -g/--debuginfo flag to wasm-emscripten-finalize (#1584)Sam Clegg2018-06-041-3/+9
| | | | | This brings this tool into parity with the existing s2wasm
* Move the renaming of llvm-generated __invoke_XX functions from s2wasm into ↵Sam Clegg2018-05-101-0/+1
| | | | | | | | | wasm-emscripten (#1539) This allows the same functionality to be used also in wasm-emscripten-finalize (i.e. the lld path).
* Let s2wasm emit binary output (#1465)Jacob Gravelle2018-03-081-3/+4
| | | | | | | | | | | | | | | | | | | | * Emit invokeFuncs list as metadata * Refactor s2wasm to use ModuleWriter * Fix wasm-emscripten-finalize metadata output for binary output * Add a flag to emit binary from s2wasm NOTE: I chose to emit text by default, and binary behind a flag. This mismatches with asm2wasm (and the expectations of users of a "2wasm" tool), but doesn't break any existing users of s2wasm. If s2wasm is deprecated in favor of lld, this will be the least disruptive change, and we won't have to live with awkward defaults for too long. * Emit source maps in the binary output of s2wasm * Only emit binary with an outfile specified
* Fold wasm-link-metadata into wasm-emscripten-finalize (#1408)Jacob Gravelle2018-02-141-3/+31
| | | | | | | * wasm-link-metadata: Use `__data_end` symbol. * Add --global-base param to emscripten-wasm-finalize to compute staticBump properly * Let ModuleWriter write to a provided Output object
* Emscripten addFunction support for Wasm backend (#1395)Heejin Ahn2018-02-071-0/+10
| | | This adds necessary command line options for addFunction support, and generates required jsCall imports and generates jsCall thunk functions.
* 'std::string &' => 'std::string& ' (#1403)Alon Zakai2018-02-051-3/+3
| | | The & on the type is the proper convention.
* First pass at LLD support for Emscripten (#1346)Jacob Gravelle2018-01-221-0/+103
* Skeleton of a beginning of o2wasm, WIP and probably not going to be used * Get building post-cherry-pick * ast->ir, remove commented out code, include a debug module print because linking * Read linking section, print emscripten metadata json * WasmBinaryWriter emits user sections on Module * Remove debugging prints, everything that isn't needed to build metadata * Rename o2wasm to lld-metadata * lld-metadata support for outputting to file * Use tables index instead of function index for initializer functions * Add lld-emscripten tool to add emscripten-runtime functions to wasm modules (built with lld) * Handle EM_ASM in lld-emscripten * Add a list of functions to forcibly export (for initializer functions) * Disable incorrect initializer function reading * Add error printing when parsing .o files in lld-metadata * Remove ';; METADATA: ' prefix from lld-metadata, output is now standalone json * Support em_asm consts that aren't at the start of a segment * Initial test framework for lld-metadata tool * Add em_asm test * Add support for WASM_INIT_FUNCS in the linking section * Remove reloc section parsing because it's unused * lld-emscripten can read and write text * Add test harness for lld-emscripten * Export all functions for now * Add missing lld test output * Add support for reading object files differently Only difference so far is in importing mutable globals being an object file representation for symbols, but invalid wasm. * Update help strings * Update linking tests for stackAlloc fix * Rename lld-emscripten,lld-metadata to wasm-emscripten-finalize,wasm-link-metadata * Add help text to header comments * auto& instead of auto & * Extract LinkType to abi/wasm-object.h * Remove special handling for wasm object file reading, allow mutable globals * Add braces around default switch case * Fix flake8 errors * Handle generating dyncall thunks for imports as well * Use explicit bool for stackPointerGlobal * Use glob patterns for lld file iteration * Use __wasm_call_ctors for all initializer functions