Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use debian builders for Linux aarch64 #417

Closed
wants to merge 4 commits into from
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
7 changes: 4 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:0015
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0016-dev
# 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-dev-alpine

USER_ID := $(shell id -u)
USER_GROUP = $(shell id -g)
Expand Down Expand Up @@ -75,7 +75,8 @@ 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
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-centos7 build_gnu_x86_64.sh
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-debian build_gnu_aarch64.sh
cp libwasmvm/artifacts/libwasmvm.x86_64.so internal/api
cp libwasmvm/artifacts/libwasmvm.aarch64.so internal/api
make update-bindings
Expand Down
16 changes: 6 additions & 10 deletions builders/Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,16 @@ RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rust
&& 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
Expand All @@ -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"]
33 changes: 33 additions & 0 deletions builders/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM debian:11-slim

RUN apt update -y \
&& apt install -y gcc make gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu wget

# GET FROM https://github.com/rust-lang/docker-rust-nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

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 \
&& rm rustup-init \
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
&& rustup --version \
&& cargo --version \
&& rustc --version \
&& chmod -R 777 /usr/local/cargo \
&& rustup target add aarch64-unknown-linux-gnu

## COPY BUILD SCRIPTS

WORKDIR /code

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 ["bash", "-c", "echo 'Argument missing. Pass one build script (e.g. build_linux.sh) to docker run' && exit 1"]
9 changes: 7 additions & 2 deletions builders/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# 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-dev

.PHONY: docker-image-centos7
docker-image-centos7:
docker build --pull . -t $(BUILDERS_PREFIX)-centos7 -f ./Dockerfile.centos7

.PHONY: docker-image-debian
docker-image-debian:
docker build --pull . -t $(BUILDERS_PREFIX)-debian -f ./Dockerfile.debian

.PHONY: docker-image-cross
docker-image-cross:
docker build --pull . -t $(BUILDERS_PREFIX)-cross -f ./Dockerfile.cross
Expand All @@ -15,10 +19,11 @@ docker-image-alpine:
docker build --pull . -t $(BUILDERS_PREFIX)-alpine -f ./Dockerfile.alpine

.PHONY: docker-images
docker-images: docker-image-centos7 docker-image-cross docker-image-alpine
docker-images: docker-image-centos7 docker-image-debian docker-image-cross docker-image-alpine

.PHONY: docker-publish
docker-publish: docker-images
docker push $(BUILDERS_PREFIX)-cross
docker push $(BUILDERS_PREFIX)-centos7
docker push $(BUILDERS_PREFIX)-debian
docker push $(BUILDERS_PREFIX)-alpine
19 changes: 19 additions & 0 deletions builders/guest/build_gnu_aarch64.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions builders/guest/build_gnu_x86_64.sh
Original file line number Diff line number Diff line change
@@ -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
22 changes: 2 additions & 20 deletions builders/guest/build_linux.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -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
Empty file modified builders/guest/build_macos.sh
100755 → 100644
Empty file.
Empty file modified builders/guest/build_macos_static.sh
100755 → 100644
Empty file.