Skip to content

Commit

Permalink
Merge pull request #2 from poplexity/patch-1
Browse files Browse the repository at this point in the history
Remove sign-extending instructions via wasm-opt
  • Loading branch information
learnforpractice authored Apr 14, 2024
2 parents 518e010 + b3d454e commit f91ad17
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pysrc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def build_contract(package_name, build_mode, target_dir, stack_size):
sys.exit(-1)

if shutil.which('wasm-opt'):
cmd = f'wasm-opt {target_dir}/wasm32-wasi/release/{package_name}.wasm -O3 --strip-debug -o {target_dir}/{package_name}.wasm'
cmd = f'wasm-opt {target_dir}/wasm32-wasi/release/{package_name}.wasm --signext-lowering -O3 --strip-debug -o {target_dir}/{package_name}.wasm'
cmd = shlex.split(cmd)
ret_code = subprocess.call(cmd, stdout=sys.stdout, stderr=sys.stderr)
if not ret_code == 0:
Expand All @@ -76,6 +76,7 @@ def build_contract(package_name, build_mode, target_dir, stack_size):
print_warning('''
wasm-opt not found! Make sure the binary is in your PATH environment.
We use this tool to optimize the size of your contract's Wasm binary.
It is also used to remove some instructions which are not supported in WASM 1.0
wasm-opt is part of the binaryen package. You can find detailed
installation instructions on https://github.com/WebAssembly/binaryen#tools.
There are ready-to-install packages for many platforms:
Expand Down

0 comments on commit f91ad17

Please sign in to comment.