Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: 2.1

orbs:
win: circleci/[email protected]

jobs:
# All checks on the codebase that can run in parallel to build_shared_library
libwasmvm_sanity:
Expand Down Expand Up @@ -179,6 +182,44 @@ jobs:
command: make test-safety
- run: make build-go

rust-unit-tests-windows:
executor:
name: win/default
shell: powershell.exe
environment:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
- checkout
- run:
name: Install Rustup
command: choco install rustup.install
- run:
name: Install Rust
command: rustup default 1.55.0
- run:
name: Show Rust version information
command: rustc --version; cargo --version; rustup --version
- run:
name: Run unit tests
working_directory: libwasmvm
command: cargo test

# Note: this is pretty limited right now because it only tests the checked-in
# wasmvm.dll without rebuilding it.
test-windows:
executor:
name: win/default
shell: powershell.exe
steps:
- checkout
- run: systeminfo
- run:
name: Install mingw
command: choco install mingw
- run:
name: Run go tests using wasmvm.dll
command: go test -v ./api ./types .

test_alpine_build:
machine:
image: ubuntu-2004:202101-01
Expand Down Expand Up @@ -206,6 +247,9 @@ jobs:
- run:
name: Build shared library for macOS
command: make release-build-macos
- run:
name: Build shared library for Windows
command: make release-build-windows
- run:
name: Debug build results
command: ls -l ./api
Expand Down Expand Up @@ -279,6 +323,8 @@ workflows:
- tidy-go
- format-scripts
- lint-scripts
- rust-unit-tests-windows
- test-windows
- build_shared_library:
filters: # required since other jobs with tag filters require this one
tags:
Expand Down
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.PHONY: all build build-rust build-go test

# Builds the Rust library libwasmvm
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0008
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0009
# Contains a full Go dev environment in order to run Go tests on the built library
ALPINE_TESTER := cosmwasm/go-ext-builder:0008-alpine
ALPINE_TESTER := cosmwasm/go-ext-builder:0009-alpine

USER_ID := $(shell id -u)
USER_GROUP = $(shell id -g)
Expand Down Expand Up @@ -74,11 +74,19 @@ release-build-linux:
# Creates a release build in a containerized build environment of the shared library for macOS (.dylib)
release-build-macos:
rm -rf libwasmvm/target/release
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross build_macos.sh
cp libwasmvm/target/x86_64-apple-darwin/release/deps/libwasmvm.dylib api
cp libwasmvm/bindings.h api
make update-bindings

# Creates a release build in a containerized build environment of the shared library for Windows (.dll)
release-build-windows:
rm -rf libwasmvm/target/release
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross build_windows.sh
cp libwasmvm/target/x86_64-pc-windows-gnu/release/wasmvm.dll api
cp libwasmvm/bindings.h api
make update-bindings

update-bindings:
# After we build libwasmvm, we have to copy the generated bindings for Go code to use.
# We cannot use symlinks as those are not reliably resolved by `go get` (https://github.com/CosmWasm/wasmvm/pull/235).
Expand Down
1 change: 0 additions & 1 deletion api/link_muslc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux && muslc
// +build linux,muslc

package api

Expand Down
3 changes: 1 addition & 2 deletions api/link_std.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build (linux && !muslc) || darwin
// +build linux,!muslc darwin
//go:build (linux && !muslc) || darwin || windows

package api

Expand Down
Binary file added api/wasmvm.dll
Binary file not shown.
30 changes: 17 additions & 13 deletions builders/Dockerfile.cross
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM rust:1.55.0-buster

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

# add some llvm configs for later - how to cross-compile this in wasmer-llvm-backend???
RUN echo deb http://deb.debian.org/debian buster-backports main >> /etc/apt/sources.list
Expand All @@ -15,15 +17,17 @@ ENV LLVM_SYS_80_PREFIX=/usr/lib/llvm-8

WORKDIR /opt

# Add macOS Rust target
RUN rustup target add x86_64-apple-darwin
# Add macOS and Windows Rust targets
RUN rustup target add x86_64-apple-darwin x86_64-pc-windows-gnu

# Build osxcross
RUN git clone https://github.com/tpoechtrager/osxcross
RUN cd osxcross && \
wget -nc https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz && \
mv MacOSX10.10.sdk.tar.xz tarballs/ && \
UNATTENDED=yes OSX_VERSION_MIN=10.10 ./build.sh
RUN git clone https://github.com/tpoechtrager/osxcross \
&& cd osxcross \
&& wget -nc https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz \
&& mv MacOSX10.10.sdk.tar.xz tarballs/ \
&& UNATTENDED=yes OSX_VERSION_MIN=10.10 ./build.sh \
# Cleanups before Docker layer is finalized
&& rm -r tarballs/
RUN chmod +rx /opt/osxcross
RUN chmod +rx /opt/osxcross/target
RUN chmod -R +rx /opt/osxcross/target/bin
Expand All @@ -35,11 +39,11 @@ RUN chmod -R 777 /usr/local/cargo

WORKDIR /code

COPY guest/*.sh /opt/
RUN chmod +x /opt/*.sh
COPY guest/*.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/*.sh

RUN mkdir /.cargo
RUN chmod +rx /.cargo
COPY guest/cargo-config /.cargo/config

CMD ["/opt/build_macos.sh"]
CMD ["bash", "-c", "echo 'Argument missing. Pass one of build_macos.sh or build_windows.sh to docker run' && exit 1"]
2 changes: 1 addition & 1 deletion builders/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Versioned by a simple counter that is not bound to a specific CosmWasm version
# See builders/README.md
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0008
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0009

.PHONY: docker-image-centos7
docker-image-centos7:
Expand Down
4 changes: 4 additions & 0 deletions builders/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ can do the cross-compilation.

## Changelog

**Version 0009:**

- Add Windows support to cosmwasm/go-ext-builder:0009-cross. This image builds for macOS and Windows now.

**Version 0008:**

- Update Rust to 1.55.0 and Go (for testing only) to 1.17.5.
Expand Down
1 change: 1 addition & 0 deletions builders/guest/build_linux.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail

# See https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-880616953 for two approaches to
# enable stripping through cargo (if that is desired).
Expand Down
1 change: 1 addition & 0 deletions builders/guest/build_macos.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail

# ref: https://wapl.es/rust/2019/02/17/rust-cross-compile-linux-to-macos.html
export PATH="/opt/osxcross/target/bin:$PATH"
Expand Down
6 changes: 6 additions & 0 deletions builders/guest/build_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail

# ref: https://www.reddit.com/r/rust/comments/5k8uab/crosscompiling_from_ubuntu_to_windows_with_rustup/

cargo build --release --target x86_64-pc-windows-gnu
6 changes: 5 additions & 1 deletion builders/guest/cargo-config
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[target.x86_64-apple-darwin]
linker = "x86_64-apple-darwin14-clang"
ar = "x86_64-apple-darwin14-ar"
ar = "x86_64-apple-darwin14-ar"

[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
ar = "x86_64-w64-mingw32-gcc-ar"