Skip to content

Commit 73d66a7

Browse files
authored
Merge pull request #350 from CosmWasm/builders-13
Create builders version 0013
2 parents 5193273 + a5cf1a0 commit 73d66a7

File tree

8 files changed

+44
-12
lines changed

8 files changed

+44
-12
lines changed

Makefile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.PHONY: all build build-rust build-go test
22

33
# Builds the Rust library libwasmvm
4-
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0012
4+
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0013
55
# Contains a full Go dev environment in order to run Go tests on the built library
6-
ALPINE_TESTER := cosmwasm/go-ext-builder:0012-alpine
6+
ALPINE_TESTER := cosmwasm/go-ext-builder:0013-alpine
77

88
USER_ID := $(shell id -u)
99
USER_GROUP = $(shell id -g)
@@ -71,10 +71,6 @@ release-build-alpine:
7171
cp libwasmvm/artifacts/libwasmvm_muslc.a internal/api
7272
cp libwasmvm/artifacts/libwasmvm_muslc.aarch64.a internal/api
7373
make update-bindings
74-
# try running go tests using this lib with muslc
75-
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/mnt/testrun -w /mnt/testrun $(ALPINE_TESTER) go build -tags muslc ./...
76-
# Use package list mode to include all subdirectores. The -count=1 turns off caching.
77-
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/mnt/testrun -w /mnt/testrun $(ALPINE_TESTER) go test -tags muslc -count=1 ./...
7874

7975
# Creates a release build in a containerized build environment of the shared library for glibc Linux (.so)
8076
release-build-linux:
@@ -92,6 +88,13 @@ release-build-macos:
9288
cp libwasmvm/artifacts/libwasmvm.dylib internal/api
9389
make update-bindings
9490

91+
# Creates a release build in a containerized build environment of the shared library for Windows (.dll)
92+
release-build-windows:
93+
rm -rf libwasmvm/target/release
94+
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross build_windows.sh
95+
cp libwasmvm/target/x86_64-pc-windows-gnu/release/wasmvm.dll internal/api
96+
make update-bindings
97+
9598
update-bindings:
9699
# After we build libwasmvm, we have to copy the generated bindings for Go code to use.
97100
# We cannot use symlinks as those are not reliably resolved by `go get` (https://github.com/CosmWasm/wasmvm/pull/235).
@@ -102,8 +105,14 @@ release-build:
102105
make release-build-alpine
103106
make release-build-linux
104107
make release-build-macos
108+
make release-build-windows
105109

106110
test-alpine: release-build-alpine
111+
# try running go tests using this lib with muslc
112+
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/mnt/testrun -w /mnt/testrun $(ALPINE_TESTER) go build -tags muslc ./...
113+
# Use package list mode to include all subdirectores. The -count=1 turns off caching.
114+
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/mnt/testrun -w /mnt/testrun $(ALPINE_TESTER) go test -tags muslc -count=1 ./...
115+
107116
@# Build a Go demo binary called ./demo that links the static library from the previous step.
108117
@# Whether the result is a statically linked or dynamically linked binary is decided by `go build`
109118
@# and it's a bit unclear how this is decided. We use `file` to see what we got.

builders/Dockerfile.alpine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RUN set -eux \
1616

1717
RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init" \
1818
&& chmod +x rustup-init \
19-
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.60.0 \
19+
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.63.0 \
2020
&& rm rustup-init \
2121
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME
2222

builders/Dockerfile.cross

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
FROM rust:1.60.0-bullseye
1+
FROM rust:1.63.0-bullseye
22

33
# Install build dependencies
44
RUN apt-get update \
5-
&& apt install -y clang gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev build-essential cmake
5+
&& apt install -y clang gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev build-essential cmake \
6+
# Support for Windows cross-compile
7+
mingw-w64
68

79
## ADD MACOS SUPPORT
810

911
WORKDIR /opt
1012

11-
# Add macOS Rust targets
12-
RUN rustup target add x86_64-apple-darwin aarch64-apple-darwin
13+
# Add macOS and Windows Rust targets
14+
RUN rustup target add x86_64-apple-darwin aarch64-apple-darwin x86_64-pc-windows-gnu
1315

1416
# Build osxcross
1517
# See https://github.com/tpoechtrager/osxcross/blob/master/build.sh#L31-L49 for SDK overview.

builders/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Versioned by a simple counter that is not bound to a specific CosmWasm version
22
# See builders/README.md
3-
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0012
3+
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0013
44

55
.PHONY: docker-image-centos7
66
docker-image-centos7:

builders/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ can do the cross-compilation.
1414

1515
## Changelog
1616

17+
**Version 0013:**
18+
19+
- Update Rust to 1.63.0.
20+
- Add Windows support to cosmwasm/go-ext-builder:0013-cross. This image builds for macOS and Windows now.
21+
1722
**Version 0012:**
1823

1924
- Add cross-compilation setup to build `libwasmvm.x86_64.so` and `libwasmvm.aarch64.so`

builders/guest/build_windows.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -o errexit -o nounset -o pipefail
3+
4+
# ref: https://www.reddit.com/r/rust/comments/5k8uab/crosscompiling_from_ubuntu_to_windows_with_rustup/
5+
6+
cargo build --release --target x86_64-pc-windows-gnu

builders/guest/cargo-config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ ar = "aarch64-apple-darwin20.4-ar"
99
[target.aarch64-unknown-linux-gnu]
1010
linker = "/usr/aarch64-linux-gnu/bin/ld"
1111
ar = "/usr/aarch64-linux-gnu/bin/ar"
12+
13+
[target.x86_64-pc-windows-gnu]
14+
linker = "x86_64-w64-mingw32-gcc"
15+
ar = "x86_64-w64-mingw32-gcc-ar"

internal/api/link_windows.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//go:build windows && !sys_wasmvm
2+
3+
package api
4+
5+
// #cgo LDFLAGS: -Wl,-rpath,${SRCDIR} -L${SRCDIR} -lwasmvm
6+
import "C"

0 commit comments

Comments
 (0)