From 35d86bd0f3b5db32d03217d919cde49fbdcd87ae Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 22 Mar 2022 17:51:39 +0100 Subject: [PATCH] Use libwasmvm_muslc.aarch64.a in docker image --- Dockerfile | 14 +++++++++++--- Makefile | 3 +++ go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ddbaab817..9bfb0a22f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ # docker build . -t cosmwasm/wasmd:latest # docker run --rm -it cosmwasm/wasmd:latest /bin/sh FROM golang:1.17-alpine3.15 AS go-builder +ARG arch=x86_64 # this comes from standard alpine nightly file # https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile @@ -15,11 +16,18 @@ WORKDIR /code COPY . /code/ # See https://github.com/CosmWasm/wasmvm/releases -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0-beta7/libwasmvm_muslc.a /lib/libwasmvm_muslc.a -RUN sha256sum /lib/libwasmvm_muslc.a | grep d0152067a5609bfdfb3f0d5d6c0f2760f79d5f2cd7fd8513cafa9932d22eb350 +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0-beta9/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0-beta9/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a +RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 922ca7aa0057da68ab49572c3d3294fb2b0d1eb12786276fdb2ca099058074b0 +RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 2aed14e6d6f4df2a7a5d23cab4da13262e740ca51160cb9be1f2d86bd34292f2 + +# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc` +RUN cp /lib/libwasmvm_muslc.${arch}.a /lib/libwasmvm_muslc.a # force it to use static lib (from above) not standard libgo_cosmwasm.so file -RUN LEDGER_ENABLED=false BUILD_TAGS=muslc make build +RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build +RUN echo "Ensuring binary is statically linked ..." \ + && (file /code/build/wasmd | grep "statically linked") # -------------------------------------------------------- FROM alpine:3.15 diff --git a/Makefile b/Makefile index e11ea1b456..b9433d972b 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,9 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=wasm \ ifeq ($(WITH_CLEVELDB),yes) ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb endif +ifeq ($(LINK_STATICALLY),true) + ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static" +endif ldflags += $(LDFLAGS) ldflags := $(strip $(ldflags)) diff --git a/go.mod b/go.mod index b20b01c5b7..6c415ee1a5 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/CosmWasm/wasmd go 1.17 require ( - github.com/CosmWasm/wasmvm v1.0.0-beta7 + github.com/CosmWasm/wasmvm v1.0.0-beta9 github.com/cosmos/cosmos-sdk v0.45.1 github.com/cosmos/iavl v0.17.3 github.com/cosmos/ibc-go/v2 v2.2.0 diff --git a/go.sum b/go.sum index 6357a041e8..03eca5b3f6 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,8 @@ github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= -github.com/CosmWasm/wasmvm v1.0.0-beta7 h1:hCa6P8tUTh8viabzeXfede5iPlopSav9Guh+hupXjvU= -github.com/CosmWasm/wasmvm v1.0.0-beta7/go.mod h1:y+yd9piV8KlrB7ISRZz1sDwH4UVm4Q9rEX9501dBNog= +github.com/CosmWasm/wasmvm v1.0.0-beta9 h1:yQJ3vQZxWyWGSyOYNvgTOMq+g8ZEB9f4OOy/2+XfYDo= +github.com/CosmWasm/wasmvm v1.0.0-beta9/go.mod h1:y+yd9piV8KlrB7ISRZz1sDwH4UVm4Q9rEX9501dBNog= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=