Skip to content

Unable to run wasm in iPhone SE with iOS 14.7. #23612

Open
@hardik124

Description

@hardik124

I have a wasm which is singlethreaded and with SIMD disabled.
It runs on other iPhones but we are encountering a problem that it does not compile on iPhone SE.
The error we get is : RuntimeError: Aborted(CompileError: WebAssembly.Module doesn't parse at byte 92417: "references are not enabled"
I am not able to find why this error comes. This is a debug build with Assertions enabled.

I know Wasm is not wrong because it works on other devices. Any help would be appreciated.
Thanks

Activity

sbc100

sbc100 commented on Feb 6, 2025

@sbc100
Collaborator

Can you attach the offending wasm file?

Also, using wasm-dis to disassembly it might give you a clue as to how references crept in. I don't think emscripten itself generates any uses of reference types yet.

hardik124

hardik124 commented on Feb 6, 2025

@hardik124
Author

Hey @sbc100 , apologies, but i am not allowed to share the wasm file .
Could you guide me what references are ? And its weird that this file works on iPhone SE2,13,14,15 but not on SE

sbc100

sbc100 commented on Feb 6, 2025

@sbc100
Collaborator

I imagine that references are not enabled is safari's way of saying that you have a reference type in your code.

What version of safari is running the device? The default minimum version of safari that we generated output for is v15. If you are targeting a version of safari older than that you can use -sMIN_SAFARI_VERSION=14000 (for example, to target safari v14)

hardik124

hardik124 commented on Feb 7, 2025

@hardik124
Author

Hey @sbc100 I did make -sMIN_SAFARI_VERSION=12000 But that did not help.
Even tried with -sMIN_SAFARI_VERSION=14000.

hardik124

hardik124 commented on Feb 7, 2025

@hardik124
Author

does "references" mean what i think it means? When we pass a variable by reference using "&" ? Because i have loads of those in my code.

sbc100

sbc100 commented on Feb 7, 2025

@sbc100
Collaborator

No, it has nothing to do with C++ or & in your code.

What version of safari is running on the device that rejects the binary?

hardik124

hardik124 commented on Feb 10, 2025

@hardik124
Author

It is 14.7.1.
I have a different code base which builds with 3.1.4 emsdk, and it works fine.
but this code base i have tried using even 3.1.25 and i get same error.

sbc100

sbc100 commented on Feb 10, 2025

@sbc100
Collaborator

Interesting, so 3.1.25 itself is more than 2 years old, so I'm somewhat supprised that it wouldn't work with Safari 14.

Can you try building with the very latest version of emscripten (4.0.3) with -sMIN_SAFARI_VERSION=14000?

hardik124

hardik124 commented on Feb 13, 2025

@hardik124
Author

build fail with 4.0.3 with error
[ 15%] Built target pdfium_core_fxcrt
In file included from /wrk/build_wasm/_deps/zxing-cpp-src/core/src/Utf.cpp:8:
In file included from /wrk/build_wasm/_deps/zxing-cpp-src/core/src/Utf.h:8:
In file included from /emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:647:
/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string_view:300:42: error: implicit instantiation of undefined template 'std::char_traits'
300 | static_assert(is_same<_CharT, typename traits_type::char_type>::value,
| ^
/wrk/build_wasm/_deps/zxing-cpp-src/core/src/Utf.cpp:72:42: note: in instantiation of template class 'std::basic_string_view' requested here
72 | static size_t Utf8CountCodePoints(utf8_t utf8)
| ^
/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
45 | struct char_traits;

On one of the imported library i have (ZXing). And it would require me to modify that library to build it. Any other version can i try with ? PReviously i was setting sMIN_SAFARI_VERSION=12000

sbc100

sbc100 commented on Feb 13, 2025

@sbc100
Collaborator

The compilation failure looks related to recent changes to libc++ regarding std::string. See #23070.

Regarding the error you are seeing on the phone, can you find out what is at the offset in your wasm binary? i.e. what is at offset 92417 from the error RuntimeError: Aborted(CompileError: WebAssembly.Module doesn't parse at byte 92417: "references are not enabled"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sbc100@hardik124

        Issue actions

          Unable to run wasm in iPhone SE with iOS 14.7. · Issue #23612 · emscripten-core/emscripten