Components built on apple silicon don't run in browser

Đang mở
#398 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
rust, wasm
Lĩnh vực
build-system, web-dev

Hướng nghiên cứu

Bắt đầu với môi trường minimal-transpile được liên kết và tái hiện lỗi trình duyệt bằng cargo-component v0.21.0 trên Apple silicon. So sánh các Build artifact bị lỗi và hoạt động, đồng thời kiểm tra jco issue ban đầu và Zulip discussion để xem hướng điều tra đã được thiết lập. Được xem là hoàn tất khi xác định và sửa được vấn đề Build đặc thù theo kiến trúc, để component được tạo chạy trong trình duyệt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Impact

It seems this error means that anyone running Apple silicon (M1+ laptops) is currently unable to build/transpile a wasm component and run it in the browser.

Brief

v0.21.0 introduces issues building on M1, M2 Macbook Pros and results in errors calling into a WASM component in the browser. The expression of the error can be found below.

Rewrote this issue to account for all we learned up to this point...
Original jco issue: https://github.com/bytecodealliance/jco/issues/634
Original zulip discussion: https://bytecodealliance.zulipchat.com/#narrow/channel/409526-jco/topic/Sudden.20transpiled.20wasm.20component.20error.20in.20browser/with/514479119

Minimal env that reproduces the problem (for MBPs it seems):

https://github.com/James-Mart/minimal-transpile

We tracked the problem down to cargo-component v0.21.0. On my M1, I can solve the problem 2 ways

  • downgrade to cargo-component v0.20.0 and recompile OR
  • get the compiled WASM from someone else's computer who was able to build it on a system that doesn't see this error.

Observations

  • The is a build-time problem. Results follow build products when swapped between machines, i.e., errors aren't environment-tied; they are build product related.
  • Apple Macbook Pros see the problem (M1, M2) aarch64; Lnux doesn't (Windows linux subsystem) amd64
  • This problem does not appear/disappear based on Rust version (I tried all rust versions that supported Rust ed. 2024 / WASM preview1).
  • wit-bindgen-rt version didn't have an impact

What's it look like?

In the referenced minimal env linked above, with cargo-component v0.20.0 (and various Rust versions), I see 2 different errors:

  1. when the wasm calls println!(), I see the following
> wasm.core.wasm:0x4da7 Uncaught RuntimeError: unreachable
    at wasm.wasm.__rust_start_panic (wasm.core.wasm:0x4da7)
    at wasm.wasm.rust_panic (wasm.core.wasm:0x4c1e)
    at wasm.wasm._ZN3std9panicking20rust_panic_with_hook17h79071f5fb265d1d9E (wasm.core.wasm:0x4bf1)
    at wasm.wasm._ZN3std9panicking19begin_panic_handler28_$u7b$$u7b$closure$u7d$$u7d$17h410c57f452410813E (wasm.core.wasm:0x3c9f)
    at wasm.wasm._ZN3std3sys9backtrace26__rust_end_short_backtrace17h514500abf2a2d0caE (wasm.core.wasm:0x3c0b)
    at wasm.wasm.rust_begin_unwind (wasm.core.wasm:0x4585)
    at wasm.wasm._ZN4core9panicking9panic_fmt17he306018bf71f8e67E (wasm.core.wasm:0x9562)
    at wasm.wasm._ZN3std2io5stdio6_print17h4ef99727a983bb66E (wasm.core.wasm:0x325e)
    at wasm.wasm.hello (wasm.core.wasm:0x2c6)
    at Module.Be (wasm.js:1:17452)
  1. when the wasm calls into rand and returns the result (no call to println!()), I get the following in the browser console
> assertion failed at adapter line
	Ie	@	wasm.js:1
    $indirect-wasi:io/[email protected][method]output-stream.blocking-write-and-flush	@	wit-component:shim-f1fd1512:0x16a
    $_ZN22wasi_snapshot_preview18bindings4wasi2io7streams12OutputStream24blocking_write_and_flush17h4f9b86b3d19bf6d5E	@	wasm.core2.wasm:0x1154
    $_ZN22wasi_snapshot_preview16macros5print17h319e9b3e6f2e5d09E	@	wasm.core2.wasm:0x9ee
    $_ZN22wasi_snapshot_preview16macros11assert_fail17h67fe26dc6b70f78bE	@	wasm.core2.wasm:0x585
    $cabi_import_realloc	@	wasm.core2.wasm:0x641
    Ee	@	wasm.js:1
    $indirect-wasi:random/[email protected]	@	wit-component:shim-f1fd1512:0x176
    $random_get	@	wasm.core2.wasm:0x181a
    $adapt-wasi_snapshot_preview1-random_get	@	wit-component:shim-f1fd1512:0xb8
    $_ZN3std3sys12thread_local6statik20LazyStorage$LT$T$GT$10initialize17h9d56f353d90c9518E	@	wasm.core.wasm:0x1b09
    $_ZN4rand4rngs6thread3rng17h1309d710195068edE	@	wasm.core.wasm:0x1d18
    $hello	@	wasm.core.wasm:0x1641
    Ze	@	wasm.js:1
    handleClick	@	App.tsx:22
> 3 [repeated callstacks skipped]
> 7
> 6
> Uncaught RuntimeError: unreachable
    at wit-component:adapter:wasi_snapshot_preview1._ZN22wasi_snapshot_preview16macros11assert_fail17h67fe26dc6b70f78bE (wasm.core2.wasm:0x58b)
    at wit-component:adapter:wasi_snapshot_preview1.cabi_import_realloc (wasm.core2.wasm:0x641)
    at Ee (wasm.js:1:16790)
    at wit-component:shim.indirect-wasi:random/[email protected] (wit-component:shim-f1fd1512:0x176)
    at wit-component:adapter:wasi_snapshot_preview1.random_get (wasm.core2.wasm:0x181a)
    at wit-component:shim.adapt-wasi_snapshot_preview1-random_get (wit-component:shim-f1fd1512:0xb8)
    at wasm.wasm._ZN3std3sys12thread_local6statik20LazyStorage$LT$T$GT$10initialize17h9d56f353d90c9518E (wasm.core.wasm:0x1b09)
    at wasm.wasm._ZN4rand4rngs6thread3rng17h1309d710195068edE (wasm.core.wasm:0x1d18)
    at wasm.wasm.hello (wasm.core.wasm:0x1641)
    at Module.Ze (wasm.js:1:17825)

Build artifacts

build-artifacts.broken.zip
build-artifacts.working.zip

Ngôn ngữ chính
Rust
Star
593
Fork
68
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bytecodealliance/cargo-component

Tất cả issue của bytecodealliance/cargo-component

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.