diff --git a/Makefile b/Makefile index 2c928354f..654c777f9 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ .PHONY: all build build-rust build-go test # Builds the Rust library libwasmvm -BUILDERS_PREFIX := cosmwasm/go-ext-builder:0015 +BUILDERS_PREFIX := cosmwasm/go-ext-builder:0016 # Contains a full Go dev environment in order to run Go tests on the built library -ALPINE_TESTER := cosmwasm/go-ext-builder:0015-alpine +ALPINE_TESTER := cosmwasm/go-ext-builder:0016-alpine USER_ID := $(shell id -u) USER_GROUP = $(shell id -g) @@ -66,7 +66,9 @@ test-safety: # Creates a release build in a containerized build environment of the static library for Alpine Linux (.a) release-build-alpine: - rm -rf libwasmvm/target/release + # Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437) + rm -rf libwasmvm/target/aarch64-unknown-linux-musl/release + rm -rf libwasmvm/target/x86_64-unknown-linux-musl/release # build the muslc *.a file docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-alpine cp libwasmvm/artifacts/libwasmvm_muslc.a internal/api @@ -75,14 +77,17 @@ release-build-alpine: # Creates a release build in a containerized build environment of the shared library for glibc Linux (.so) release-build-linux: - rm -rf libwasmvm/target/release - docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-centos7 + # Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437) + rm -rf libwasmvm/target/x86_64-unknown-linux-gnu/release + rm -rf libwasmvm/target/aarch64-unknown-linux-gnu/release + docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-centos7 build_linux.sh cp libwasmvm/artifacts/libwasmvm.x86_64.so internal/api cp libwasmvm/artifacts/libwasmvm.aarch64.so internal/api make update-bindings # Creates a release build in a containerized build environment of the shared library for macOS (.dylib) release-build-macos: + # Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437) rm -rf libwasmvm/target/x86_64-apple-darwin/release rm -rf libwasmvm/target/aarch64-apple-darwin/release 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: # Creates a release build in a containerized build environment of the static library for macOS (.a) release-build-macos-static: + # Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437) rm -rf libwasmvm/target/x86_64-apple-darwin/release rm -rf libwasmvm/target/aarch64-apple-darwin/release 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: # Creates a release build in a containerized build environment of the shared library for Windows (.dll) release-build-windows: - rm -rf libwasmvm/target/release + # Builders should not write their target folder into the host file system (https://github.com/CosmWasm/wasmvm/issues/437) + rm -rf libwasmvm/target/x86_64-pc-windows-gnu/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 internal/api make update-bindings diff --git a/builders/Dockerfile.alpine b/builders/Dockerfile.alpine index 03fb017ea..8ba3cbb8b 100644 --- a/builders/Dockerfile.alpine +++ b/builders/Dockerfile.alpine @@ -18,7 +18,7 @@ RUN set -eux \ RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init" \ && chmod +x rustup-init \ - && ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.68.2 \ + && ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.69.0 \ && rm rustup-init \ && chmod -R a+w $RUSTUP_HOME $CARGO_HOME diff --git a/builders/Dockerfile.centos7 b/builders/Dockerfile.centos7 index d4169cc38..c95318092 100644 --- a/builders/Dockerfile.centos7 +++ b/builders/Dockerfile.centos7 @@ -26,25 +26,21 @@ ENV RUSTUP_HOME=/usr/local/rustup \ RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init" \ && chmod +x rustup-init \ - && ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.68.2 \ + && ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.69.0 \ && rm rustup-init \ && chmod -R a+w $RUSTUP_HOME $CARGO_HOME \ && rustup --version \ && cargo --version \ - && rustc --version - -# Add aarch64 as a target of compilation -RUN rustup target add aarch64-unknown-linux-gnu - -# allow non-root user to download more deps later -RUN chmod -R 777 /usr/local/cargo + && rustc --version \ + && chmod -R 777 /usr/local/cargo \ + && rustup target add aarch64-unknown-linux-gnu ## COPY BUILD SCRIPTS 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 @@ -57,4 +53,4 @@ RUN wget http://mirror.centos.org/altarch/7/os/aarch64/Packages/libgcc-4.8.5-44. && cp /code/lib64/libgcc_s-4.8.5-20150702.so.1 /usr/lib/gcc/aarch64-linux-gnu/4.8.5/libgcc_s.so \ && rm libgcc-*.el7.aarch64.rpm -CMD ["/opt/build_linux.sh"] +CMD ["bash", "-c", "echo 'Argument missing. Pass one build script (e.g. build_linux.sh) to docker run' && exit 1"] diff --git a/builders/Dockerfile.cross b/builders/Dockerfile.cross index 10d1d5d4f..bcabb747a 100644 --- a/builders/Dockerfile.cross +++ b/builders/Dockerfile.cross @@ -1,4 +1,4 @@ -FROM rust:1.68.2-bullseye +FROM rust:1.69.0-bullseye # Install build dependencies RUN apt-get update \ diff --git a/builders/Makefile b/builders/Makefile index e7467f70a..3d18e0d31 100644 --- a/builders/Makefile +++ b/builders/Makefile @@ -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:0015 +BUILDERS_PREFIX := cosmwasm/go-ext-builder:0016 .PHONY: docker-image-centos7 docker-image-centos7: diff --git a/builders/README.md b/builders/README.md index 8f7e9a06f..4a568eef6 100644 --- a/builders/README.md +++ b/builders/README.md @@ -14,6 +14,11 @@ any machine that can run Docker can do the cross-compilation. ## Changelog +**Version 0016:** + +- Update Rust to 1.69.0. +- Let `build_muslc.sh` use `--example wasmvmstatic` instead of `--example muslc` + **Version 0015:** - Update Rust to 1.68.2. diff --git a/builders/guest/build_gnu_aarch64.sh b/builders/guest/build_gnu_aarch64.sh new file mode 100644 index 000000000..2723c11ab --- /dev/null +++ b/builders/guest/build_gnu_aarch64.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail + +export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse + +# See https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-880616953 for two approaches to +# enable stripping through cargo (if that is desired). + +echo "Starting aarch64-unknown-linux-gnu build" +export CC=clang +export CXX=clang++ +export qemu_aarch64="qemu-aarch64 -L /usr/aarch64-linux-gnu" +export CC_aarch64_unknown_linux_gnu=clang +export AR_aarch64_unknown_linux_gnu=llvm-ar +export CFLAGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu" +export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc +export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="$qemu_aarch64" +cargo build --release --target aarch64-unknown-linux-gnu +cp target/aarch64-unknown-linux-gnu/release/libwasmvm.so artifacts/libwasmvm.aarch64.so diff --git a/builders/guest/build_gnu_x86_64.sh b/builders/guest/build_gnu_x86_64.sh new file mode 100644 index 000000000..78067bb77 --- /dev/null +++ b/builders/guest/build_gnu_x86_64.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail + +export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse + +# See https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-880616953 for two approaches to +# enable stripping through cargo (if that is desired). + +echo "Starting x86_64-unknown-linux-gnu build" +export CC=clang +export CXX=clang++ +cargo build --release --target x86_64-unknown-linux-gnu +cp target/x86_64-unknown-linux-gnu/release/libwasmvm.so artifacts/libwasmvm.x86_64.so diff --git a/builders/guest/build_linux.sh b/builders/guest/build_linux.sh old mode 100755 new mode 100644 index c3f59e22a..4d66b3728 --- a/builders/guest/build_linux.sh +++ b/builders/guest/build_linux.sh @@ -1,23 +1,5 @@ #!/bin/bash set -o errexit -o nounset -o pipefail -export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse - -# See https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-880616953 for two approaches to -# enable stripping through cargo (if that is desired). - -echo "Starting x86_64-unknown-linux-gnu build" -export CC=clang -export CXX=clang++ -cargo build --release --target x86_64-unknown-linux-gnu -cp target/x86_64-unknown-linux-gnu/release/libwasmvm.so artifacts/libwasmvm.x86_64.so - -echo "Starting aarch64-unknown-linux-gnu build" -export qemu_aarch64="qemu-aarch64 -L /usr/aarch64-linux-gnu" -export CC_aarch64_unknown_linux_gnu=clang -export AR_aarch64_unknown_linux_gnu=llvm-ar -export CFLAGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu" -export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc -export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="$qemu_aarch64" -cargo build --release --target aarch64-unknown-linux-gnu -cp target/aarch64-unknown-linux-gnu/release/libwasmvm.so artifacts/libwasmvm.aarch64.so +build_gnu_x86_64.sh +build_gnu_aarch64.sh diff --git a/builders/guest/build_macos.sh b/builders/guest/build_macos.sh old mode 100755 new mode 100644 diff --git a/builders/guest/build_macos_static.sh b/builders/guest/build_macos_static.sh old mode 100755 new mode 100644 diff --git a/builders/guest/build_muslc.sh b/builders/guest/build_muslc.sh index fb77dc56a..3777d2ff3 100644 --- a/builders/guest/build_muslc.sh +++ b/builders/guest/build_muslc.sh @@ -8,11 +8,11 @@ export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse echo "Starting aarch64-unknown-linux-musl build" export CC=/opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc -cargo build --release --target aarch64-unknown-linux-musl --example muslc +cargo build --release --target aarch64-unknown-linux-musl --example wasmvmstatic unset CC echo "Starting x86_64-unknown-linux-musl build" -cargo build --release --target x86_64-unknown-linux-musl --example muslc +cargo build --release --target x86_64-unknown-linux-musl --example wasmvmstatic -cp target/aarch64-unknown-linux-musl/release/examples/libmuslc.a artifacts/libwasmvm_muslc.aarch64.a -cp target/x86_64-unknown-linux-musl/release/examples/libmuslc.a artifacts/libwasmvm_muslc.a +cp target/aarch64-unknown-linux-musl/release/examples/libwasmvmstatic.a artifacts/libwasmvm_muslc.aarch64.a +cp target/x86_64-unknown-linux-musl/release/examples/libwasmvmstatic.a artifacts/libwasmvm_muslc.a diff --git a/docs/COMPILER_VERSIONS.md b/docs/COMPILER_VERSIONS.md index 1cb0b66da..25dec7ad8 100644 --- a/docs/COMPILER_VERSIONS.md +++ b/docs/COMPILER_VERSIONS.md @@ -63,6 +63,6 @@ We currently use the following version: | Type | Rust version | Note | | ------------------------ | ------------ | --------------------------------- | -| Production Rust compiler | 1.68.2 | Builders version 0015 | +| Production Rust compiler | 1.69.0 | Builders version 0016 | | Min Rust compiler | 1.60.0 | Supports builder versions >= 0012 | | Tooling Rust compiler | 1.69.0 | | diff --git a/libwasmvm/Cargo.toml b/libwasmvm/Cargo.toml index 35362fefc..cee21ec86 100644 --- a/libwasmvm/Cargo.toml +++ b/libwasmvm/Cargo.toml @@ -15,11 +15,6 @@ crate-type = ["cdylib", "rlib"] # the example is to allow us to compile a muslc static lib with the same codebase as we compile the # normal dynamic libs (best workaround I could find to override crate-type on the command line) -[[example]] -name = "muslc" -path = "src/lib.rs" -crate-type = ["staticlib"] - [[example]] name = "wasmvmstatic" path = "src/examples/wasmvmstatic.rs" diff --git a/libwasmvm/src/examples/wasmvmstatic.rs b/libwasmvm/src/examples/wasmvmstatic.rs index 42db554fe..cb664e2d4 100644 --- a/libwasmvm/src/examples/wasmvmstatic.rs +++ b/libwasmvm/src/examples/wasmvmstatic.rs @@ -1 +1,5 @@ +// This is an entry point into the library in order to set +// crate-type = ["staticlib"] via a command line arument. +// See `--example wasmvmstatic` + pub use wasmvm::*;