neutron-org / neutron

Smart Contract platform secured by Cosmos Hub
https://neutron.org
Apache License 2.0
104 stars 79 forks source link

Link neutron against muslc #606

Open dzianisv opened 1 week ago

dzianisv commented 1 week ago

Hey team! Could you please help me to link neutrond againas muslc and static libwasmvm on ubuntu 22?

Docker image: ubuntu:22.04 Apps installed:

apt update -yq && \
    apt-get install -yq --no-install-recommends \
    make \
    git \
    musl \
    musl-dev \
    musl-tools \
    bash \
    gcc-multilib \
    linux-headers-generic \
    jq \
    wget && \
    apt clean -yq

Build command:

ARCH=$(uname -m)
# since v4.0.1, wasmvm/v2 is used
WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | sed "s/.* //") || WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed "s/.* //")
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a -O /lib/libwasmvm_muslc.$ARCH.a
EDGER_ENABLED=false BUILD_TAGS=muslc make install

Build failure:

#22 7.423 go: downloading go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0
#22 43.64 # github.com/neutron-org/neutron/v4/cmd/neutrond
#22 43.64 /usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
#22 43.64 /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib/libwasmvm_muslc.x86_64.a(cranelift_codegen-3991b3e4bad3dbb2.cranelift_codegen.9681e040c034dd47-cgu.07.rcgu.o): in function `cranelift_codegen::ir::immediates::Ieee32::ceil':
#22 43.64 cranelift_codegen.9681e040c034dd47-cgu.07:(.text._ZN17cranelift_codegen2ir10immediates6Ieee324ceil17h862ba0997491db23E+0x7): undefined reference to `ceilf'
#22 43.64 /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib/libwasmvm_muslc.x86_64.a(cranelift_codegen-3991b3e4bad3dbb2.cranelift_codegen.9681e040c034dd47-cgu.07.rcgu.o): in function `cranelift_codegen::ir::immediates::Ieee32::floor':
dzianisv commented 1 week ago

gpt4o suggested to add CC=musl-gcc, and now it fails to localte linux headers

#21 7.493 go: downloading go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0
#21 7.494 go: downloading github.com/googleapis/enterprise-certificate-proxy v0.3.2
#21 11.40 # github.com/zondax/hid
#21 11.40 In file included from /go/pkg/mod/github.com/zondax/hid@v0.9.2/libusb/libusb/os/linux_usbfs.c:43,
#21 11.40                  from /go/pkg/mod/github.com/zondax/hid@v0.9.2/hid_enabled.go:26:
#21 11.40 /go/pkg/mod/github.com/zondax/hid@v0.9.2/libusb/libusb/os/linux_usbfs.h:24:10: fatal error: linux/types.h: No such file or directory
#21 11.40    24 | #include <linux/types.h>
#21 11.40       |          ^~~~~~~~~~~~~~~
#21 11.40 compilation terminated.
#21 28.38 make: *** [Makefile:101: install] Error 1
pr0n00gler commented 6 days ago

Try make build-static-linux-amd64 command, it requires docker but you can see what it does inside so you can modify it for your system and build without docker