-
Notifications
You must be signed in to change notification settings - Fork 120
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 LLVM's opt tool to cargo contract build
#22
Comments
Note, that I was using a matching versions of LLVM and rustc. I am not sure that it will work if the versions of rustc's LLVM and LLVM of opt mismatch. |
Can you provide a pseudo Or even better a non pseudo one that works. |
I am afraid that I don't have anything at hand and the best info can be only found at the original issue. |
This can be closed since we found a much better solution to solve the underlying problem via Xargo. |
At the moment ink! smart contracts have all their panic messages included in the data segment of the Wasm binary even though execution aborts upon panic and will never output any panic messages.
This is due to a "bug" between Rust and LLVM translation.
We can manually optimize this superflous data away with LLVM's
opt
tool.The passes we need to enable from it are:
-deadargelim
: https://llvm.org/docs/Passes.html#deadargelim-dead-argument-elimination-globaldce
: https://llvm.org/docs/Passes.html#globaldce-dead-global-eliminationNote that
opt
works on LLVM IR, not on Rust nor WebAssembly. So this needs some adjustments to thecargo contract
build process.The
opt
tool usage should be enabled by default, however, if it does not exist on a user machine the build process should simply do what it currently does (not useopt
) and print a warning to the user stating that the resulting Wasm binary might not be optimal for the given reason.The text was updated successfully, but these errors were encountered: