use-ink/cargo-contract

Evaluate size savings of switching on certain Wasm target features

Open

#334 创建于 2021年8月25日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Rust (127 fork)github user discovery
help wanted

仓库指标

Star
 (280 star)
PR 合并指标
 (PR 指标待抓取)

描述

I've looked into how building contracts with the simd128 target feature affects contract sizes. The results can be found here. This is the cargo-contract branch I used for this: cmichi-build-contracts-with-simd-128.

The results look promising, though it would require implementing this feature in wasmi, as well as follow-up work in the contracts pallet to e.g. determine weights.

We should evaluate the other target features as well:

$ rustc --target=wasm32-unknown-unknown --print target-features
Features supported by rustc for this target:
    simd128             - Enable 128-bit SIMD.
    atomics             - Enable Atomics.
    nontrapping-fptoint - Enable non-trapping float-to-int conversion operators.
    crt-static          - Enables C Run-time Libraries to be statically linked.

Code-generation features supported by LLVM for this target:
    bulk-memory         - Enable bulk memory operations.
    exception-handling  - Enable Wasm exception handling.
    multivalue          - Enable multivalue blocks, instructions, and functions.
    mutable-globals     - Enable mutable globals.
    reference-types     - Enable reference types.
    sign-ext            - Enable sign extension operators.
    tail-call           - Enable tail call instructions.

My branch from above can basically just be adapted with switching on other target features.

I've also tried multivalue, but unfortunately it's currently broken in rustc due to https://github.com/rust-lang/rust/issues/73755. In order to get an idea of the changes in contract size we should use an older rustc where multivalue still works and build the contracts with it.

贡献者指南