cargo-web icon indicating copy to clipboard operation
cargo-web copied to clipboard

cli: expose option use_system_emscripten - and/or allow to use cached download

Open milahu opened this issue 5 years ago • 1 comments

goal: save traffic and disk space

on a metered connection, the 200 MB download of emscripten-*.tgz costs around 30 cents, which is not-so-nice when the install fails, and the next try will download the same file again, and again ..

install failed on rust 1.48.0 with "type uninitialized"

$ cargo web start --target wasm32-unknown-emscripten Downloading emscripten-1.38.19-1-x86_64-unknown-linux-gnu.tgz... 201.71 MB / 201.71 MB [==================================] 100.00 % 962.31 KB/s thread 'main' panicked at 'attempted to leave type `digest::generic_array::GenericArray<std::string::String, digest::generic_array::typenum::UInt<digest::generic_array::typenum::UInt<digest::generic_array::typenum::UInt<digest::generic_array::typenum::UInt<digest::generic_array::typenum::UInt<digest::generic_array::typenum::UInt<digest::generic_array::typenum::UTerm, digest::generic_array::typenum::B1>, digest::generic_array::typenum::B0>, digest::generic_array::typenum::B0>, digest::generic_array::typenum::B0>, digest::generic_array::typenum::B0>, digest::generic_array::typenum::B0>>` uninitialized, which is invalid', /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/mem/mod.rs:658:9

possible solution: downgrade rust with rustup default 1.47.0

also, i already have emcc instsalled, version 2.0.5 cargo web prepare-emscripten wants to install emcc version 1.38.19

is there a good reason to use the old version?

edit, looks like something-somewhere is using the old API of emscripten so function signatures dont match, giving cryptic errors (Assertion failed: undefined)

with emcc version 2 assert(argbuf % 16 == 0) fails with argbuf == undefined called by function _emscripten_asm_const_int(code, sigPtr, argbuf) in emscripten/src/library.js called by js_shim_extern_code in stdweb/stdweb-internal-macros/src/js_shim.rs (arg_count should be 2, not 1) called by js_attr or js_raw_code or js_raw_attr in stdweb/stdweb-internal-macros called by .... ? called by stdweb::webapi::document::document::snippet::__cargo_web_snippet_.... .... produced by https://github.com/fkohlgrueber/tree-sitter-test

exception thrown: RuntimeError: abort(Assertion failed: undefined) at Error
    at jsStackTrace (http://[::1]:8000/tree-sitter-test.js:2236:19)
    at stackTrace (http://[::1]:8000/tree-sitter-test.js:2253:16)
    at abort (http://[::1]:8000/tree-sitter-test.js:1901:44)
    at assert (http://[::1]:8000/tree-sitter-test.js:1058:5)
    at readAsmConstArgs (http://[::1]:8000/tree-sitter-test.js:6287:7)
    at _emscripten_asm_const_int (http://[::1]:8000/tree-sitter-test.js:5132:18)
    at stdweb::webapi::document::document::snippet::__cargo_web_snippet_6fcce0aae651e2d748e085ff1f800f87625ff8c8::hd3722c2289766f8d (http://[::1]:8000/tree_sitter_test.wasm:wasm-function[2753]:0xd5cff)
    at stdweb::webapi::document::document::snippet::hca3bb87f1284bee0 (http://[::1]:8000/tree_sitter_test.wasm:wasm-function[2738]:0xd287f)
    at invoke_ii (http://[::1]:8000/tree-sitter-test.js:6505:32)
    at stdweb::webapi::document::document::hddd8273b71f00478 (http://[::1]:8000/tree_sitter_test.wasm:wasm-function[2737]:0xd25a8),RuntimeError: abort(Assertion failed: undefined) at Error
    at jsStackTrace (http://[::1]:8000/tree-sitter-test.js:2236:19)
    at stackTrace (http://[::1]:8000/tree-sitter-test.js:2253:16)
    at abort (http://[::1]:8000/tree-sitter-test.js:1901:44)
    at assert (http://[::1]:8000/tree-sitter-test.js:1058:5)
    at readAsmConstArgs (http://[::1]:8000/tree-sitter-test.js:6287:7)
    at _emscripten_asm_const_int (http://[::1]:8000/tree-sitter-test.js:5132:18)
    at stdweb::webapi::document::document::snippet::__cargo_web_snippet_6fcce0aae651e2d748e085ff1f800f87625ff8c8::hd3722c2289766f8d (http://[::1]:8000/tree_sitter_test.wasm:wasm-function[2753]:0xd5cff)
    at stdweb::webapi::document::document::snippet::hca3bb87f1284bee0 (http://[::1]:8000/tree_sitter_test.wasm:wasm-function[2738]:0xd287f)
    at invoke_ii (http://[::1]:8000/tree-sitter-test.js:6505:32)
    at stdweb::webapi::document::document::hddd8273b71f00478 (http://[::1]:8000/tree_sitter_test.wasm:wasm-function[2737]:0xd25a8)
    at abort (http://[::1]:8000/tree-sitter-test.js:1907:11)
    at assert (http://[::1]:8000/tree-sitter-test.js:1058:5)
    at readAsmConstArgs (http://[::1]:8000/tree-sitter-test.js:6287:7)
    at _emscripten_asm_const_int (http://[::1]:8000/tree-sitter-test.js:5132:18)
    at stdweb::webapi::document::document::snippet::__cargo_web_snippet_6fcce0aae651e2d748e085ff1f800f87625ff8c8::hd3722c2289766f8d (http://[::1]:8000/tree_sitter_test.wasm:wasm-function[2753]:0xd5cff)
    at stdweb::webapi::document::document::snippet::hca3bb87f1284bee0 (http://[::1]:8000/tree_sitter_test.wasm:wasm-function[2738]:0xd287f)
    at invoke_ii (http://[::1]:8000/tree-sitter-test.js:6505:32)
    at stdweb::webapi::document::document::hddd8273b71f00478 (http://[::1]:8000/tree_sitter_test.wasm:wasm-function[2737]:0xd25a8)
    at invoke_i (http://[::1]:8000/tree-sitter-test.js:6582:32)
    at yew::app::App$LT$COMP$GT$::mount_to_body::h8777b842d76c55ae (http://[::1]:8000/tree_sitter_test.wasm:wasm-function[126]:0x6ca3)

milahu avatar Dec 05 '20 19:12 milahu

found it: cargo web build --use-system-emscripten

$ cargo web start --help | grep system
        --use-system-emscripten    Won't try to download Emscripten; will always use the system one

$ cargo web build --help | grep system
        --use-system-emscripten    Won't try to download Emscripten; will always use the system one

but "allow to use cached download" is still needed

and/or allow to set path of emcc binary, for example --use-emcc /opt/emcc-1.38.19/bin/emcc

milahu avatar Dec 05 '20 20:12 milahu