cosmos / developer-portal

Other
21 stars 12 forks source link

exec /usr/bin/simd: exec format error #55

Open pluveto opened 9 months ago

pluveto commented 9 months ago

What tutorial are you working in? Paste the URL of the Cosmos SDK tutorial.

Describe the bug it reports this error

exec /usr/bin/simd: exec format error

To reproduce I strictly follow the steps.

I found simd is executeable outside but not inside:

(HOST)

$  ./build/simd version
0.45.4

(CONTAINER)

$ sudo  docker run --rm -it simd:v0.45.4 simd version
exec /usr/bin/simd: exec format error

$ sudo docker run --rm -it simd:v0.45.4 sh  
~ # simd
/usr/bin/simd: line 3: syntax error: unexpected ")"

What versions of software are you running?

What is your version of the Cosmos SDK?

v0.45.4

Include the output of these commands.

Go: go version

go version go1.20.10 linux/amd64

Ignite CLI: ignite version

zsh: command not found: ignite

Gaia: gaiad version --long

zsh: command not found: gaiad

Tell us about your environment

Your system: uname -a

Linux archsys 6.5.9-arch2-1 #1 SMP PREEMPT_DYNAMIC Thu, 26 Oct 2023 00:52:20 +0000 x86_64 GNU/Linux

Solution

pluveto commented 9 months ago

Build log:

$ sudo docker build . -t simd:v0.45.4

DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  352.7MB
Step 1/12 : FROM golang:alpine AS build-env
alpine: Pulling from library/golang
96526aa774ef: Pull complete 
834bccaa730c: Pull complete 
dc4665a42a98: Pull complete 
7bacadf07636: Pull complete 
Digest: sha256:96a8a701943e7eabd81ebd0963540ad660e29c3b2dc7fb9d7e06af34409e9ba6
Status: Downloaded newer image for golang:alpine
 ---> 137e17c1b298
Step 2/12 : ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3
 ---> Running in 067136abf86c
Removing intermediate container 067136abf86c
 ---> a6927731e806
Step 3/12 : RUN apk add --no-cache $PACKAGES
 ---> Running in 593b00c25d31
fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/community/x86_64/APKINDEX.tar.gz
(1/47) Upgrading musl (1.2.4-r1 -> 1.2.4-r2)
(2/47) Installing ncurses-terminfo-base (6.4_p20230506-r0)
(3/47) Installing libncursesw (6.4_p20230506-r0)
(4/47) Installing readline (8.2.1-r1)
(5/47) Installing bash (5.2.15-r5)
Executing bash-5.2.15-r5.post-install
(6/47) Installing brotli-libs (1.0.9-r14)
(7/47) Installing libunistring (1.1-r1)
(8/47) Installing libidn2 (2.3.4-r1)
(9/47) Installing nghttp2-libs (1.57.0-r0)
(10/47) Installing libcurl (8.4.0-r0)
(11/47) Installing curl (8.4.0-r0)
(12/47) Installing udev-init-scripts (35-r1)
(13/47) Installing eudev-libs (3.2.11-r8)
(14/47) Installing libblkid (2.38.1-r8)
(15/47) Installing xz-libs (5.4.3-r0)
(16/47) Installing zstd-libs (1.5.5-r4)
(17/47) Installing kmod-libs (30-r3)
(18/47) Installing eudev (3.2.11-r8)
(19/47) Installing pkgconf (1.9.5-r0)
(20/47) Installing eudev-dev (3.2.11-r8)
(21/47) Installing libgcc (12.2.1_git20220924-r10)
(22/47) Installing libstdc++ (12.2.1_git20220924-r10)
(23/47) Installing binutils (2.40-r7)
(24/47) Installing libgomp (12.2.1_git20220924-r10)
(25/47) Installing libatomic (12.2.1_git20220924-r10)
(26/47) Installing gmp (6.2.1-r3)
(27/47) Installing isl26 (0.26-r1)
(28/47) Installing mpfr4 (4.2.0_p12-r0)
(29/47) Installing mpc1 (1.3.1-r1)
(30/47) Installing gcc (12.2.1_git20220924-r10)
(31/47) Installing libexpat (2.5.0-r1)
(32/47) Installing pcre2 (10.42-r1)
(33/47) Installing git (2.40.1-r0)
(34/47) Installing musl-dev (1.2.4-r2)
(35/47) Installing libc-dev (0.7.2-r5)
(36/47) Installing linux-headers (6.3-r0)
(37/47) Installing make (4.4.1-r1)
(38/47) Installing libbz2 (1.0.8-r5)
(39/47) Installing libffi (3.4.4-r2)
(40/47) Installing gdbm (1.23-r1)
(41/47) Installing mpdecimal (2.5.1-r2)
(42/47) Installing libpanelw (6.4_p20230506-r0)
(43/47) Installing sqlite-libs (3.41.2-r2)
(44/47) Installing python3 (3.11.6-r0)
(45/47) Installing python3-pycache-pyc0 (3.11.6-r0)
(46/47) Installing pyc (0.1-r0)
(47/47) Installing python3-pyc (3.11.6-r0)
Executing busybox-1.36.1-r2.trigger
Executing eudev-3.2.11-r8.trigger
OK: 213 MiB in 62 packages
Removing intermediate container 593b00c25d31
 ---> dfc7b1f2e60e
Step 4/12 : WORKDIR /go/src/github.com/cosmos/cosmos-sdk
 ---> Running in 7d1f61424931
Removing intermediate container 7d1f61424931
 ---> 5a2c29585cf2
Step 5/12 : COPY . .
 ---> 2fe1445200f4
Step 6/12 : RUN make build-linux
 ---> Running in bfa3fa917d3d
GOOS=linux GOARCH=arm64 LEDGER_ENABLED=false make build
make[1]: Entering directory '/go/src/github.com/cosmos/cosmos-sdk'
mkdir -p /go/src/github.com/cosmos/cosmos-sdk/build/
go build -mod=readonly -tags "netgo" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version=0.45.4 -X github.com/cosmos/cosmos-sdk/version.Commit=ad9e5620fb3445c716e9de45cfcdb56e8f1745bf -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo," -X github.com/tendermint/tendermint/version.TMCoreSemVer=v0.34.19 -w -s' -trimpath -o /go/src/github.com/cosmos/cosmos-sdk/build/ ./...
go: downloading github.com/spf13/cobra v1.4.0
go: downloading github.com/rakyll/statik v0.1.7
go: downloading github.com/tendermint/tendermint v0.34.19
go: downloading github.com/bgentry/speakeasy v0.1.0
go: downloading github.com/mattn/go-isatty v0.0.14
go: downloading github.com/regen-network/protobuf v1.3.3-alpha.regen.1
go: downloading github.com/gorilla/mux v1.8.0
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/grpc-ecosystem/grpc-gateway v1.16.0
go: downloading google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb
go: downloading google.golang.org/grpc v1.33.2
go: downloading github.com/spf13/viper v1.10.1
go: downloading github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
go: downloading github.com/cosmos/go-bip39 v1.0.0
go: downloading github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15
go: downloading github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/tendermint/tm-db v0.6.6
go: downloading google.golang.org/protobuf v1.27.1
go: downloading github.com/tendermint/go-amino v0.16.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/btcsuite/btcd v0.22.0-beta
go: downloading golang.org/x/crypto v0.0.0-20210915214749-c084706c2272
go: downloading github.com/tendermint/btcd v0.1.1
go: downloading github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87
go: downloading github.com/gogo/gateway v1.1.0
go: downloading github.com/rs/zerolog v1.23.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/gorilla/handlers v1.5.1
go: downloading github.com/improbable-eng/grpc-web v0.14.1
go: downloading github.com/spf13/cast v1.4.1
go: downloading github.com/regen-network/cosmos-proto v0.3.1
go: downloading github.com/hashicorp/golang-lru v0.5.4
go: downloading github.com/cosmos/iavl v0.17.3
go: downloading golang.org/x/sys v0.0.0-20220114195835-da31bd327af9
go: downloading github.com/armon/go-metrics v0.3.10
go: downloading github.com/prometheus/client_golang v1.12.1
go: downloading github.com/prometheus/common v0.32.1
go: downloading golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b
go: downloading github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d
go: downloading github.com/cosmos/btcutil v1.0.4
go: downloading github.com/fsnotify/fsnotify v1.5.1
go: downloading github.com/magiconair/properties v1.8.5
go: downloading github.com/spf13/afero v1.6.0
go: downloading github.com/mitchellh/mapstructure v1.4.3
go: downloading github.com/spf13/jwalterweatherman v1.1.0
go: downloading github.com/subosito/gotenv v1.2.0
go: downloading gopkg.in/ini.v1 v1.66.2
go: downloading github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2
go: downloading github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b
go: downloading github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c
go: downloading github.com/mtibben/percent v0.2.1
go: downloading github.com/google/btree v1.0.0
go: downloading github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca
go: downloading github.com/go-kit/kit v0.12.0
go: downloading github.com/go-kit/log v0.2.0
go: downloading github.com/coinbase/rosetta-sdk-go v0.7.0
go: downloading github.com/go-logfmt/logfmt v0.5.1
go: downloading filippo.io/edwards25519 v1.0.0-beta.2
go: downloading github.com/confio/ics23/go v0.6.6
go: downloading github.com/gorilla/websocket v1.5.0
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/stretchr/testify v1.7.1
go: downloading github.com/golang/mock v1.6.0
go: downloading github.com/lib/pq v1.10.4
go: downloading github.com/rs/cors v1.8.2
go: downloading github.com/felixge/httpsnoop v1.0.1
go: downloading github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f
go: downloading nhooyr.io/websocket v1.8.6
go: downloading github.com/hashicorp/go-immutable-radix v1.3.1
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/procfs v0.7.3
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/pelletier/go-toml v1.9.4
go: downloading github.com/gtank/merlin v0.1.1
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/gtank/ristretto255 v0.1.2
go: downloading golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
go: downloading golang.org/x/text v0.3.7
go: downloading github.com/libp2p/go-buffer-pool v0.0.2
go: downloading github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0
go: downloading github.com/Workiva/go-datastructures v1.0.53
go: downloading github.com/minio/highwayhash v1.0.2
go: downloading github.com/google/orderedcode v0.0.1
go: downloading github.com/klauspost/compress v1.13.6
go: downloading github.com/golang/snappy v0.0.3
go: downloading github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
make[1]: Leaving directory '/go/src/github.com/cosmos/cosmos-sdk'
Removing intermediate container bfa3fa917d3d
 ---> 821189a6fced
Step 7/12 : FROM alpine:edge
edge: Pulling from library/alpine
b790c763077d: Pull complete 
Digest: sha256:f2d1645cd73c7e54584dc225da0b5229d19223412d719669ebda764f41396853
Status: Downloaded newer image for alpine:edge
 ---> 23d4cb6bdebe
Step 8/12 : RUN apk add --update ca-certificates
 ---> Running in 2b9f57d6dfe4
fetch https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
(1/1) Installing ca-certificates (20230506-r0)
Executing busybox-1.36.1-r6.trigger
Executing ca-certificates-20230506-r0.trigger
OK: 8 MiB in 16 packages
Removing intermediate container 2b9f57d6dfe4
 ---> 821f120b48d5
Step 9/12 : WORKDIR /root
 ---> Running in 18b12d1ab224
Removing intermediate container 18b12d1ab224
 ---> 5352f65e8fe1
Step 10/12 : COPY --from=build-env /go/src/github.com/cosmos/cosmos-sdk/build/simd /usr/bin/simd
 ---> 21f870e372ed
Step 11/12 : EXPOSE 26656 26657 1317 9090
 ---> Running in e2dddcfbd580
Removing intermediate container e2dddcfbd580
 ---> 9c3831ca9fd8
Step 12/12 : CMD ["simd"]
 ---> Running in 1cff2fa42928
Removing intermediate container 1cff2fa42928
 ---> a806f8323876
Successfully built a806f8323876
Successfully tagged simd:v0.45.4
xavierlepretre commented 9 months ago

Well, from the look of it there is a mismatch between the machine where you built the Docker image and the machine where you ran it:

  1. You say your system is Linux archsys 6.5.9-... x86_64 GNU/Linux. So this is an Intel CPU.
  2. The make build command is called with GOARCH=arm64. So this is an ARM CPU.

They are incompatible.

pluveto commented 9 months ago

But I only have one x64 pc, and I don't know who set GOARCH=arm64 here.

https://github.com/search?q=org%3Acosmos%20build-linux-arm64&type=code

pluveto commented 9 months ago

It looks like Docker mistakenly identified mine as an Arm arch machine? https://github.com/cosmos/cosmos-sdk/blob/9463a32aae640e04fecb7f036808b9b27c21e681/Dockerfile#L40

xavierlepretre commented 9 months ago

It looks like this line:

build-linux:
    GOOS=linux GOARCH=$(if $(findstring aarch64,$(shell uname -m)) || $(findstring arm64,$(shell uname -m)),arm64,amd64) LEDGER_ENABLED=false $(MAKE) build

Is not working as expected. Since you have ArchLinux I think, it could be an edge case that this complicated line failed to identify. What does uname -m give you?

If you can reproduce the error with a recent version, that would be worth opening an issue on the cosmos-sdk repo.