Skip to content

Commit

Permalink
Merge pull request #128 from CosmWasm/update-binaryen-rust
Browse files Browse the repository at this point in the history
Use signext lowering in wasm-opt
  • Loading branch information
maurolacy authored Jul 28, 2023
2 parents 2662fe0 + bc393ba commit 35ee4b2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

- Update to binaryen v114.
- Bump Rust to current stable v1.71.0.
- Add the `--signext-lowering` flag to `wasm-opt`. ([#127])

## [0.13.0] - 2023-06-20

### Changed
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM rust:1.69.0-alpine as targetarch
FROM rust:1.71.0-alpine as targetarch

ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETARCH

ARG BINARYEN_VERSION="version_110"
ARG BINARYEN_VERSION="version_114"

RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM"

Expand Down Expand Up @@ -88,7 +88,7 @@ RUN cd build_workspace && \
#
# base-optimizer
#
FROM rust:1.69.0-alpine as base-optimizer
FROM rust:1.71.0-alpine as base-optimizer

# Download the crates.io index using the new sparse protocol to improve performance
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DOCKER_TAG := 0.13.0
# Native arch
BUILDARCH := $(shell uname -m)

# Build multi-CPU architecture images and publish them. rust alpine images support the linux/amd64 and linux/arm64/v8 architectures.
# Build the native CPU arch images and publish them. Rust alpine images support the linux/amd64 and linux/arm64/v8 architectures.
build: build-rust-optimizer build-workspace-optimizer

build-rust-optimizer-x86_64:
Expand Down
5 changes: 3 additions & 2 deletions optimize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mkdir -p artifacts
rm -f artifacts/checksums_intermediate.txt

# There are two cases here
# 1. All contracts (or one) are included in the root workspace (eg. `cosmwasm-template`, `cosmwasm-examples`, `cosmwasm-plus`)
# 1. All contracts (or one) are included in the root workspace (eg. `cosmwasm-template`, `cosmwasm-examples`, `cosmwasm-plus`)
# In this case, we pass no argument, just mount the proper directory.
# 2. Contracts are excluded from the root workspace, but import relative paths from other packages (only `cosmwasm`).
# In this case, we mount root workspace and pass in a path `docker run <repo> ./contracts/hackatom`
Expand All @@ -44,7 +44,8 @@ for CONTRACTDIR in "$@"; do
echo "Creating intermediate hash for $NAME ..."
sha256sum -- "$WASM" | tee -a artifacts/checksums_intermediate.txt
echo "Optimizing $NAME ..."
wasm-opt -Os "$WASM" -o "artifacts/$NAME"
# --signext-lowering is needed to support blockchains runnning CosmWasm < 1.3. It can be removed eventually
wasm-opt -Os --signext-lowering "$WASM" -o "artifacts/$NAME"
done
done

Expand Down
3 changes: 2 additions & 1 deletion optimize_workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ TMPARTIFACTS=$(mktemp -p "$(pwd)" -d artifacts.XXXXXX)
echo "$INTERMEDIATE_SHA" >>"$INTERMEDIATE_SHAS"

echo "Optimizing ${BASENAME}..."
wasm-opt -Os "$WASM" -o "$OPTIMIZED_WASM"
# --signext-lowering is needed to support blockchains runnning CosmWasm < 1.3. It can be removed eventually
wasm-opt -Os --signext-lowering "$WASM" -o "$OPTIMIZED_WASM"
echo "Moving ${OPTIMIZED_WASM}..."
mv "$OPTIMIZED_WASM" ../artifacts
fi
Expand Down

0 comments on commit 35ee4b2

Please sign in to comment.