To finish the pwasm ERC777 implementation at https://github.com/lab10-coop/pwasm-erc777 I need to check for granularity, involving multiplications of U256 values.
Attempting to multiply U256 values in pwasm contracts currently causes link conflicts between rlibc and compiler_builtins.
It is easy to reproduce the errors with the pwasm-tutorials "step-5" example by just adding a multiplication with 3 to the "total_supply" function:
// Reads balance by address
fn read_balance_of(owner: &Address) -> U256 {
U256::from_big_endian(&pwasm_ethereum::read(&balance_key(owner))) * U256::from(3u64)
}
The reported errors:
= note: rust-lld: error: duplicate symbol: memset
>>> defined in /home/davidf/branches/pwasm-tutorial/step-5/target/wasm32-unknown-unknown/release/deps/librlibc-4a3676c92aca5d34.rlib(rlibc-4a3676c92aca5d34.rlibc.3b5qwd65-cgu.0.rcgu.o)
>>> defined in /home/davidf/.rustup/toolchains/nightly-2018-11-12-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-a950277054e8795f.rlib(compiler_builtins-a950277054e8795f.compiler_builtins.9cyfw09r-cgu.0.rcgu.o)
rust-lld: error: duplicate symbol: memcpy
>>> defined in /home/davidf/branches/pwasm-tutorial/step-5/target/wasm32-unknown-unknown/release/deps/librlibc-4a3676c92aca5d34.rlib(rlibc-4a3676c92aca5d34.rlibc.3b5qwd65-cgu.0.rcgu.o)
>>> defined in /home/davidf/.rustup/toolchains/nightly-2018-11-12-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-a950277054e8795f.rlib(compiler_builtins-a950277054e8795f.compiler_builtins.9cyfw09r-cgu.0.rcgu.o)
rust-lld: error: duplicate symbol: memmove
>>> defined in /home/davidf/branches/pwasm-tutorial/step-5/target/wasm32-unknown-unknown/release/deps/librlibc-4a3676c92aca5d34.rlib(rlibc-4a3676c92aca5d34.rlibc.3b5qwd65-cgu.0.rcgu.o)
>>> defined in /home/davidf/.rustup/toolchains/nightly-2018-11-12-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-a950277054e8795f.rlib(compiler_builtins-a950277054e8795f.compiler_builtins.9cyfw09r-cgu.0.rcgu.o)
rust-lld: error: duplicate symbol: memcmp
>>> defined in /home/davidf/branches/pwasm-tutorial/step-5/target/wasm32-unknown-unknown/release/deps/librlibc-4a3676c92aca5d34.rlib(rlibc-4a3676c92aca5d34.rlibc.3b5qwd65-cgu.0.rcgu.o)
>>> defined in /home/davidf/.rustup/toolchains/nightly-2018-11-12-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-a950277054e8795f.rlib(compiler_builtins-a950277054e8795f.compiler_builtins.9cyfw09r-cgu.0.rcgu.o)
Multiplying with 1, 2 and 4 do not reproduce the link error interestingly, neither does multiplication in the "step-0" project, unless a contract is added with at least one function with at least one return type (can be as simple as a bool) - so it may be triggered by using the pwasm-abi library.
Optimizations in the release builds make the issue appear and disappear depending on the setup, but removing the "--release" option reproduces the link error immediately, even in a build of the unmodified "step-0" pwasm-tutorial example.
I would like to help with tracing this issue down, it currently keeps me from finishing the erc777 implementation, but also from implementing a number of internal, math-heavy contracts in the pwasm environment.
To finish the pwasm ERC777 implementation at https://github.com/lab10-coop/pwasm-erc777 I need to check for granularity, involving multiplications of U256 values.
Attempting to multiply U256 values in pwasm contracts currently causes link conflicts between rlibc and compiler_builtins.
It is easy to reproduce the errors with the pwasm-tutorials "step-5" example by just adding a multiplication with 3 to the "total_supply" function:
The reported errors:
Multiplying with 1, 2 and 4 do not reproduce the link error interestingly, neither does multiplication in the "step-0" project, unless a contract is added with at least one function with at least one return type (can be as simple as a bool) - so it may be triggered by using the pwasm-abi library.
Optimizations in the release builds make the issue appear and disappear depending on the setup, but removing the "--release" option reproduces the link error immediately, even in a build of the unmodified "step-0" pwasm-tutorial example.
I would like to help with tracing this issue down, it currently keeps me from finishing the erc777 implementation, but also from implementing a number of internal, math-heavy contracts in the pwasm environment.