|
36 | 36 | from .utils import read_file, write_file, delete_file |
37 | 37 | from .utils import removeprefix, exit_with_error |
38 | 38 | from .shared import in_temp, safe_copy, do_replace, OFormat |
39 | | -from .shared import DEBUG, WINDOWS, DYNAMICLIB_ENDINGS, STATICLIB_ENDINGS |
| 39 | +from .shared import DEBUG, WINDOWS, DYNAMICLIB_ENDINGS |
40 | 40 | from .shared import unsuffixed, unsuffixed_basename, get_file_suffix |
41 | 41 | from .settings import settings, default_setting, user_settings, JS_ONLY_SETTINGS, DEPRECATED_SETTINGS |
42 | 42 | from .minimal_runtime_shell import generate_minimal_runtime_html |
@@ -2812,7 +2812,6 @@ def map_to_js_libs(library_name): |
2812 | 2812 |
|
2813 | 2813 | def process_libraries(state): |
2814 | 2814 | new_flags = [] |
2815 | | - suffixes = STATICLIB_ENDINGS + DYNAMICLIB_ENDINGS |
2816 | 2815 | system_libs_map = system_libs.Library.get_usable_variations() |
2817 | 2816 |
|
2818 | 2817 | # Process `-l` and `--js-library` flags |
@@ -2843,16 +2842,23 @@ def process_libraries(state): |
2843 | 2842 | if js_libs is not None: |
2844 | 2843 | continue |
2845 | 2844 |
|
2846 | | - path = None |
2847 | | - for suff in suffixes: |
2848 | | - name = 'lib' + lib + suff |
2849 | | - path = find_library(name, state.lib_dirs) |
2850 | | - if path: |
2851 | | - break |
| 2845 | + if not settings.RELOCATABLE: |
| 2846 | + # Normally we can rely on the native linker to expand `-l` args. |
| 2847 | + # However, emscripten also supports `.so` files that are actually just |
| 2848 | + # regular object file. This means we need to support `.so` files even |
| 2849 | + # when statically linking. The native linker (wasm-ld) will otherwise |
| 2850 | + # ignore .so files in this mode. |
| 2851 | + found_dylib = False |
| 2852 | + for ext in DYNAMICLIB_ENDINGS: |
| 2853 | + name = 'lib' + lib + ext |
| 2854 | + path = find_library(name, state.lib_dirs) |
| 2855 | + if path: |
| 2856 | + found_dylib = True |
| 2857 | + new_flags.append((i, path)) |
| 2858 | + break |
2852 | 2859 |
|
2853 | | - if path: |
2854 | | - new_flags.append((i, path)) |
2855 | | - continue |
| 2860 | + if found_dylib: |
| 2861 | + continue |
2856 | 2862 |
|
2857 | 2863 | new_flags.append((i, flag)) |
2858 | 2864 |
|
|
0 commit comments