(dylibs, lib_dirs)
| 2865 | |
| 2866 | |
| 2867 | def process_dynamic_libs(dylibs, lib_dirs): |
| 2868 | extras = [] |
| 2869 | seen = set() |
| 2870 | to_process = dylibs.copy() |
| 2871 | while to_process: |
| 2872 | dylib = to_process.pop() |
| 2873 | dylink = webassembly.parse_dylink_section(dylib) |
| 2874 | for needed in dylink.needed: |
| 2875 | if needed in seen: |
| 2876 | continue |
| 2877 | path = find_library(needed, lib_dirs) |
| 2878 | if path: |
| 2879 | extras.append(path) |
| 2880 | seen.add(needed) |
| 2881 | else: |
| 2882 | exit_with_error(f'{os.path.normpath(dylib)}: shared library dependency not found in library path: `{needed}`. (library path: {lib_dirs}') |
| 2883 | to_process.append(path) |
| 2884 | |
| 2885 | dylibs += extras |
| 2886 | for dylib in dylibs: |
| 2887 | exports = webassembly.get_exports(dylib) |
| 2888 | exports = {e.name for e in exports} |
| 2889 | # EM_JS function are exports with a special prefix. We need to strip |
| 2890 | # this prefix to get the actual symbol name. For the main module, this |
| 2891 | # is handled by extract_metadata.py. |
| 2892 | exports = [e.removeprefix('__em_js__') for e in exports] |
| 2893 | settings.SIDE_MODULE_EXPORTS.extend(sorted(exports)) |
| 2894 | |
| 2895 | imports = webassembly.get_imports(dylib) |
| 2896 | imports = [i.field for i in imports if i.kind in {webassembly.ExternType.FUNC, webassembly.ExternType.GLOBAL, webassembly.ExternType.TAG}] |
| 2897 | # For now we ignore `invoke_` functions imported by side modules and rely |
| 2898 | # on the dynamic linker to create them on the fly. |
| 2899 | # TODO(sbc): Integrate with metadata.invoke_funcs that comes from the |
| 2900 | # main module to avoid creating new invoke functions at runtime. |
| 2901 | imports = set(imports) |
| 2902 | imports = {i for i in imports if not i.startswith('invoke_')} |
| 2903 | weak_imports = webassembly.get_weak_imports(dylib) |
| 2904 | strong_imports = sorted(imports.difference(weak_imports)) |
| 2905 | logger.debug('Adding symbols requirements from `%s`: %s', dylib, imports) |
| 2906 | |
| 2907 | mangled_imports = [shared.asmjs_mangle(e) for e in sorted(imports)] |
| 2908 | mangled_strong_imports = [shared.asmjs_mangle(e) for e in strong_imports] |
| 2909 | for sym in weak_imports: |
| 2910 | mangled = shared.asmjs_mangle(sym) |
| 2911 | if mangled not in settings.SIDE_MODULE_IMPORTS and mangled not in building.user_requested_exports: |
| 2912 | settings.WEAK_IMPORTS.append(sym) |
| 2913 | settings.SIDE_MODULE_IMPORTS.extend(mangled_imports) |
| 2914 | settings.EXPORT_IF_DEFINED.extend(sorted(imports)) |
| 2915 | settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.extend(sorted(imports)) |
| 2916 | building.user_requested_exports.update(mangled_strong_imports) |
| 2917 | |
| 2918 | |
| 2919 | def unmangle_symbols_from_cmdline(symbols): |
no test coverage detected