Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compilation to NodeJS module #111

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

smiasojed
Copy link
Collaborator

@smiasojed smiasojed commented Nov 6, 2024

Cross-compile the resolc binary to WebAssembly (WASM) using Emscripten.

@athei
Copy link
Member

athei commented Nov 8, 2024

I guess it was an accident that you checked in the build outputs?

Copy link
Member

@athei athei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think after this initial PR you should look into cross language LTO to bring the code size down (for web). As of right now the release profile isn't even using LTO for the rust code. Adding wasm-opt to the pipeline will also help a lot.

js/resolc.wasm Outdated Show resolved Hide resolved
.github/workflows/build-revive-wasm.yml Outdated Show resolved Hide resolved
.github/workflows/build-revive-wasm.yml Outdated Show resolved Hide resolved
@smiasojed
Copy link
Collaborator Author

I guess it was an accident that you checked in the build outputs?

I did it to share the output with @pgherveou

Comment on lines +45 to +49
# Install LLVM required for the compiler runtime, runtime-api and stdlib
curl -sSL --output llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.4/clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04.tar.xz
tar Jxf llvm.tar.xz
mv clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04 llvm18/
echo "$(pwd)/llvm18/bin" >> $GITHUB_PATH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I still don't understand what we need it for. Don't we build LLVM completely from source with emscripten? What is this binary version needed for? Shouldn't the emscripten build version be used for everything?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the RISC-V compiler-rt and also we compile some shared code (for example our "stdlib") into LLVM bitcode at this stage. Those bitcodes are bundled with the compiler and just linked into into contract code. The emscripten version does compile contract code but not those things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These crates are compiled on the host to the RISC-V target, to be linked into the contract binary when it is built using the WASM version of revive.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants