Skip to content

Commit f1bab34

Browse files
authored
Merge pull request #438 from CosmWasm/use-wasmvmstatic-example
Use wasmvmstatic example and create builders version 0016
2 parents d558963 + 5b9970c commit f1bab34

15 files changed

+71
-50
lines changed

Makefile

Lines changed: 13 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:0015
4+
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0016
55
# Contains a full Go dev environment in order to run Go tests on the built library
6-
ALPINE_TESTER := cosmwasm/go-ext-builder:0015-alpine
6+
ALPINE_TESTER := cosmwasm/go-ext-builder:0016-alpine
77

88
USER_ID := $(shell id -u)
99
USER_GROUP = $(shell id -g)
@@ -66,7 +66,9 @@ test-safety:
6666

6767
# Creates a release build in a containerized build environment of the static library for Alpine Linux (.a)
6868
release-build-alpine:
69-
rm -rf libwasmvm/target/release
69+
# Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437)
70+
rm -rf libwasmvm/target/aarch64-unknown-linux-musl/release
71+
rm -rf libwasmvm/target/x86_64-unknown-linux-musl/release
7072
# build the muslc *.a file
7173
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-alpine
7274
cp libwasmvm/artifacts/libwasmvm_muslc.a internal/api
@@ -75,14 +77,17 @@ release-build-alpine:
7577

7678
# Creates a release build in a containerized build environment of the shared library for glibc Linux (.so)
7779
release-build-linux:
78-
rm -rf libwasmvm/target/release
79-
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-centos7
80+
# Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437)
81+
rm -rf libwasmvm/target/x86_64-unknown-linux-gnu/release
82+
rm -rf libwasmvm/target/aarch64-unknown-linux-gnu/release
83+
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-centos7 build_linux.sh
8084
cp libwasmvm/artifacts/libwasmvm.x86_64.so internal/api
8185
cp libwasmvm/artifacts/libwasmvm.aarch64.so internal/api
8286
make update-bindings
8387

8488
# Creates a release build in a containerized build environment of the shared library for macOS (.dylib)
8589
release-build-macos:
90+
# Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437)
8691
rm -rf libwasmvm/target/x86_64-apple-darwin/release
8792
rm -rf libwasmvm/target/aarch64-apple-darwin/release
8893
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross build_macos.sh
@@ -91,6 +96,7 @@ release-build-macos:
9196

9297
# Creates a release build in a containerized build environment of the static library for macOS (.a)
9398
release-build-macos-static:
99+
# Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437)
94100
rm -rf libwasmvm/target/x86_64-apple-darwin/release
95101
rm -rf libwasmvm/target/aarch64-apple-darwin/release
96102
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross build_macos_static.sh
@@ -99,7 +105,8 @@ release-build-macos-static:
99105

100106
# Creates a release build in a containerized build environment of the shared library for Windows (.dll)
101107
release-build-windows:
102-
rm -rf libwasmvm/target/release
108+
# Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437)
109+
rm -rf libwasmvm/target/x86_64-pc-windows-gnu/release
103110
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross build_windows.sh
104111
cp libwasmvm/target/x86_64-pc-windows-gnu/release/wasmvm.dll internal/api
105112
make update-bindings

builders/Dockerfile.alpine

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

1919
RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init" \
2020
&& chmod +x rustup-init \
21-
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.68.2 \
21+
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.69.0 \
2222
&& rm rustup-init \
2323
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME
2424

builders/Dockerfile.centos7

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,21 @@ ENV RUSTUP_HOME=/usr/local/rustup \
2626

2727
RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init" \
2828
&& chmod +x rustup-init \
29-
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.68.2 \
29+
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.69.0 \
3030
&& rm rustup-init \
3131
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
3232
&& rustup --version \
3333
&& cargo --version \
34-
&& rustc --version
35-
36-
# Add aarch64 as a target of compilation
37-
RUN rustup target add aarch64-unknown-linux-gnu
38-
39-
# allow non-root user to download more deps later
40-
RUN chmod -R 777 /usr/local/cargo
34+
&& rustc --version \
35+
&& chmod -R 777 /usr/local/cargo \
36+
&& rustup target add aarch64-unknown-linux-gnu
4137

4238
## COPY BUILD SCRIPTS
4339

4440
WORKDIR /code
4541

46-
COPY guest/*.sh /opt/
47-
RUN chmod +x /opt/*.sh
42+
COPY guest/*.sh /usr/local/bin/
43+
RUN chmod +x /usr/local/bin/*.sh
4844

4945
RUN mkdir /.cargo
5046
RUN chmod +rx /.cargo
@@ -57,4 +53,4 @@ RUN wget http://mirror.centos.org/altarch/7/os/aarch64/Packages/libgcc-4.8.5-44.
5753
&& cp /code/lib64/libgcc_s-4.8.5-20150702.so.1 /usr/lib/gcc/aarch64-linux-gnu/4.8.5/libgcc_s.so \
5854
&& rm libgcc-*.el7.aarch64.rpm
5955

60-
CMD ["/opt/build_linux.sh"]
56+
CMD ["bash", "-c", "echo 'Argument missing. Pass one build script (e.g. build_linux.sh) to docker run' && exit 1"]

builders/Dockerfile.cross

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust:1.68.2-bullseye
1+
FROM rust:1.69.0-bullseye
22

33
# Install build dependencies
44
RUN apt-get update \

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:0015
3+
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0016
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 @@ any machine that can run Docker can do the cross-compilation.
1414

1515
## Changelog
1616

17+
**Version 0016:**
18+
19+
- Update Rust to 1.69.0.
20+
- Let `build_muslc.sh` use `--example wasmvmstatic` instead of `--example muslc`
21+
1722
**Version 0015:**
1823

1924
- Update Rust to 1.68.2.

builders/guest/build_gnu_aarch64.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -o errexit -o nounset -o pipefail
3+
4+
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
5+
6+
# See https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-880616953 for two approaches to
7+
# enable stripping through cargo (if that is desired).
8+
9+
echo "Starting aarch64-unknown-linux-gnu build"
10+
export CC=clang
11+
export CXX=clang++
12+
export qemu_aarch64="qemu-aarch64 -L /usr/aarch64-linux-gnu"
13+
export CC_aarch64_unknown_linux_gnu=clang
14+
export AR_aarch64_unknown_linux_gnu=llvm-ar
15+
export CFLAGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu"
16+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
17+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="$qemu_aarch64"
18+
cargo build --release --target aarch64-unknown-linux-gnu
19+
cp target/aarch64-unknown-linux-gnu/release/libwasmvm.so artifacts/libwasmvm.aarch64.so

builders/guest/build_gnu_x86_64.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -o errexit -o nounset -o pipefail
3+
4+
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
5+
6+
# See https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-880616953 for two approaches to
7+
# enable stripping through cargo (if that is desired).
8+
9+
echo "Starting x86_64-unknown-linux-gnu build"
10+
export CC=clang
11+
export CXX=clang++
12+
cargo build --release --target x86_64-unknown-linux-gnu
13+
cp target/x86_64-unknown-linux-gnu/release/libwasmvm.so artifacts/libwasmvm.x86_64.so

builders/guest/build_linux.sh

100755100644
Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
33

4-
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
5-
6-
# See https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-880616953 for two approaches to
7-
# enable stripping through cargo (if that is desired).
8-
9-
echo "Starting x86_64-unknown-linux-gnu build"
10-
export CC=clang
11-
export CXX=clang++
12-
cargo build --release --target x86_64-unknown-linux-gnu
13-
cp target/x86_64-unknown-linux-gnu/release/libwasmvm.so artifacts/libwasmvm.x86_64.so
14-
15-
echo "Starting aarch64-unknown-linux-gnu build"
16-
export qemu_aarch64="qemu-aarch64 -L /usr/aarch64-linux-gnu"
17-
export CC_aarch64_unknown_linux_gnu=clang
18-
export AR_aarch64_unknown_linux_gnu=llvm-ar
19-
export CFLAGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu"
20-
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
21-
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="$qemu_aarch64"
22-
cargo build --release --target aarch64-unknown-linux-gnu
23-
cp target/aarch64-unknown-linux-gnu/release/libwasmvm.so artifacts/libwasmvm.aarch64.so
4+
build_gnu_x86_64.sh
5+
build_gnu_aarch64.sh

builders/guest/build_macos.sh

100755100644
File mode changed.

builders/guest/build_macos_static.sh

100755100644
File mode changed.

builders/guest/build_muslc.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
88

99
echo "Starting aarch64-unknown-linux-musl build"
1010
export CC=/opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
11-
cargo build --release --target aarch64-unknown-linux-musl --example muslc
11+
cargo build --release --target aarch64-unknown-linux-musl --example wasmvmstatic
1212
unset CC
1313

1414
echo "Starting x86_64-unknown-linux-musl build"
15-
cargo build --release --target x86_64-unknown-linux-musl --example muslc
15+
cargo build --release --target x86_64-unknown-linux-musl --example wasmvmstatic
1616

17-
cp target/aarch64-unknown-linux-musl/release/examples/libmuslc.a artifacts/libwasmvm_muslc.aarch64.a
18-
cp target/x86_64-unknown-linux-musl/release/examples/libmuslc.a artifacts/libwasmvm_muslc.a
17+
cp target/aarch64-unknown-linux-musl/release/examples/libwasmvmstatic.a artifacts/libwasmvm_muslc.aarch64.a
18+
cp target/x86_64-unknown-linux-musl/release/examples/libwasmvmstatic.a artifacts/libwasmvm_muslc.a

docs/COMPILER_VERSIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ We currently use the following version:
6363

6464
| Type | Rust version | Note |
6565
| ------------------------ | ------------ | --------------------------------- |
66-
| Production Rust compiler | 1.68.2 | Builders version 0015 |
66+
| Production Rust compiler | 1.69.0 | Builders version 0016 |
6767
| Min Rust compiler | 1.60.0 | Supports builder versions >= 0012 |
6868
| Tooling Rust compiler | 1.69.0 | |

libwasmvm/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ crate-type = ["cdylib", "rlib"]
1515

1616
# the example is to allow us to compile a muslc static lib with the same codebase as we compile the
1717
# normal dynamic libs (best workaround I could find to override crate-type on the command line)
18-
[[example]]
19-
name = "muslc"
20-
path = "src/lib.rs"
21-
crate-type = ["staticlib"]
22-
2318
[[example]]
2419
name = "wasmvmstatic"
2520
path = "src/examples/wasmvmstatic.rs"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
// This is an entry point into the library in order to set
2+
// crate-type = ["staticlib"] via a command line arument.
3+
// See `--example wasmvmstatic`
4+
15
pub use wasmvm::*;

0 commit comments

Comments
 (0)