rustbn.js icon indicating copy to clipboard operation
rustbn.js copied to clipboard

Request to support BIG Endian architecture

Open vishwabmc opened this issue 3 years ago • 2 comments

Hello,

I am building https://github.com/ProjectOpenSea/seaport#readme on s390x platform, which is a BIG Endian, and running into an issue where I get Runtime error: expected the system to be little-endian! error. I talked to Vasili Skurydzin (https://github.com/V-for-Vasili) and he figured out that the error was coming from node_modules/rustbn.js/lib/index.asm.js

Commands I ran :

git clone https://github.com/ProjectOpenSea/seaport && cd seaport
yarn set version 1.22.19
yarn install
yarn build
yarn test

The command that gives this error is yarn test.

node.js version : v10.19.0 yarn version : 1.22.19

Could you please help if you would be providing a version that supports BIG Endian architecture ?. Thank you very much for your support !.

!! Vishwa !!

vishwabmc avatar Jul 29 '22 12:07 vishwabmc

To give some context: I have previously looked into making Emscripten support BE architectures (by default it doesn't as WASM is Little Endian by definition).

Emscripten supports cross-compiling for BE machines since https://github.com/emscripten-core/emscripten/pull/13413. If you add -sSUPPORT_BIG_ENDIAN flag to emcc calls then the generated .wasm/.js files can be run on BE machines same way as they are run on x64 (Instead of giving the usual Runtime error: expected the system to be little-endian!).

V-for-Vasili avatar Jul 29 '22 13:07 V-for-Vasili

Would it make more sense to update this package to use a different WASM toolchain perhaps? I'm not super knowledgeable on rust but it looks like the emscripten target is pretty poorly supported and maybe we could update this to use wasm-unknown-unknown instead and compile with wasm-bindgen or else wasi? I'm not sure if that would get around this issue or not.

acolytec3 avatar Jul 29 '22 14:07 acolytec3