| 534 | } |
| 535 | |
| 536 | function symbolHandler(symbol) { |
| 537 | // In LLVM, exceptions generate a set of functions of form |
| 538 | // __cxa_find_matching_catch_1(), __cxa_find_matching_catch_2(), etc. where |
| 539 | // the number specifies the number of arguments. In Emscripten, route all |
| 540 | // these to a single function 'findMatchingCatch' that takes an array |
| 541 | // of argument. |
| 542 | if (LINK_AS_CXX && !WASM_EXCEPTIONS && symbol.startsWith('__cxa_find_matching_catch_')) { |
| 543 | if (DISABLE_EXCEPTION_THROWING) { |
| 544 | error( |
| 545 | 'DISABLE_EXCEPTION_THROWING was set (likely due to -fno-exceptions), which means no C++ exception throwing support code is linked in, but exception catching code appears. Either do not set DISABLE_EXCEPTION_THROWING (if you do want exception throwing) or compile all source files with -fno-exceptions (so that no exceptions support code is required); also make sure DISABLE_EXCEPTION_CATCHING is set to the right value - if you want exceptions, it should be off, and vice versa.', |
| 546 | ); |
| 547 | return; |
| 548 | } |
| 549 | if (!(symbol in LibraryManager.library)) { |
| 550 | // Create a new __cxa_find_matching_catch variant on demand. |
| 551 | const num = +symbol.split('_').slice(-1)[0]; |
| 552 | compileTimeContext.addCxaCatch(num); |
| 553 | } |
| 554 | // Continue, with the code below emitting the proper JavaScript based on |
| 555 | // what we just added to the library. |
| 556 | } |
| 557 | |
| 558 | function addFromLibrary(symbol, dependent) { |
| 559 | // don't process any special identifiers. These are looked up when |
| 560 | // processing the base name of the identifier. |
| 561 | if (isDecorator(symbol)) { |
| 562 | return; |
| 563 | } |
| 564 | |
| 565 | // if the function was implemented in compiled code, there is no need to |
| 566 | // include the js version |
| 567 | if (WASM_EXPORTS.has(symbol)) { |
| 568 | return; |
| 569 | } |
| 570 | |
| 571 | if (symbol in addedLibraryItems) { |
| 572 | return; |
| 573 | } |
| 574 | addedLibraryItems[symbol] = true; |
| 575 | |
| 576 | const deps = LibraryManager.library[symbol + '__deps'] ??= []; |
| 577 | let sig = LibraryManager.library[symbol + '__sig']; |
| 578 | if (!WASM_BIGINT && sig && sig[0] == 'j') { |
| 579 | // Without WASM_BIGINT functions that return i64 depend on setTempRet0 |
| 580 | // to return the upper 32-bits of the result. |
| 581 | // See makeReturn64 in parseTools.py. |
| 582 | deps.push('setTempRet0'); |
| 583 | } |
| 584 | |
| 585 | const isAsyncFunction = LibraryManager.library[symbol + '__async']; |
| 586 | if (ASYNCIFY && isAsyncFunction) { |
| 587 | asyncFuncs.push(symbol); |
| 588 | } |
| 589 | |
| 590 | if (symbolsOnly) { |
| 591 | if (LibraryManager.library.hasOwnProperty(symbol)) { |
| 592 | // Resolve aliases before looking up deps |
| 593 | var transitiveDeps = getTransitiveDeps(symbol); |