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

chore(goreleaser): static amd64 #78

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Lazar955
Copy link
Member

@Lazar955 Lazar955 commented Oct 11, 2024

run make release-snapshot, the amd64 build fails due some misconfiguration in static linking [help needed]. I am running this on M3 mac

command-line-arguments
/usr/local/go/pkg/tool/linux_arm64/link: running x86_64-linux-gnu-gcc failed: exit status 1
/usr/bin/x86_64-linux-gnu-gcc -m64 -s -o $WORK/b001/exe/a.out -Wl,--export-dynamic-symbol=_cgo_panic -Wl,--export-dynamic-symbol=_cgo_topofstack -Wl,--export-dynamic-symbol=cCanonicalizeAddress -Wl,--export-dynamic-symbol=cDelete -Wl,--export-dynamic-symbol=cGet -Wl,--export-dynamic-symbol=cHumanizeAddress -Wl,--export-dynamic-symbol=cNext -Wl,--export-dynamic-symbol=cNextKey -Wl,--export-dynamic-symbol=cNextValue -Wl,--export-dynamic-symbol=cQueryExternal -Wl,--export-dynamic-symbol=cScan -Wl,--export-dynamic-symbol=cSet -Wl,--export-dynamic-symbol=cValidateAddress -Wl,--export-dynamic-symbol=crosscall2 -Wl,--export-dynamic-symbol=secp256k1GoPanicError -Wl,--export-dynamic-symbol=secp256k1GoPanicIllegal -Wl,--compress-debug-sections=zlib /tmp/go-link-2183027264/go.o /tmp/go-link-2183027264/000000.o /tmp/go-link-2183027264/000001.o /tmp/go-link-2183027264/000002.o /tmp/go-link-2183027264/000003.o /tmp/go-link-2183027264/000004.o /tmp/go-link-2183027264/000005.o /tmp/go-link-2183027264/000006.o /tmp/go-link-2183027264/000007.o /tmp/go-link-2183027264/000008.o /tmp/go-link-2183027264/000009.o /tmp/go-link-2183027264/000010.o /tmp/go-link-2183027264/000011.o /tmp/go-link-2183027264/000012.o /tmp/go-link-2183027264/000013.o /tmp/go-link-2183027264/000014.o /tmp/go-link-2183027264/000015.o /tmp/go-link-2183027264/000016.o /tmp/go-link-2183027264/000017.o /tmp/go-link-2183027264/000018.o /tmp/go-link-2183027264/000019.o /tmp/go-link-2183027264/000020.o /tmp/go-link-2183027264/000021.o /tmp/go-link-2183027264/000022.o /tmp/go-link-2183027264/000023.o /tmp/go-link-2183027264/000024.o /tmp/go-link-2183027264/000025.o /tmp/go-link-2183027264/000026.o /tmp/go-link-2183027264/000027.o /tmp/go-link-2183027264/000028.o /tmp/go-link-2183027264/000029.o /tmp/go-link-2183027264/000030.o /tmp/go-link-2183027264/000031.o -O2 -g -O2 -g -O2 -g -lpthread -O2 -g -Wl,-rpath,/root/go/pkg/mod/github.com/!cosm!wasm/wasmvm/[email protected]/internal/api -L/root/go/pkg/mod/github.com/!cosm!wasm/wasmvm/[email protected]/internal/api -lwasmvm_muslc.x86_64 -O2 -g -lrt -no-pie -Wl,-z,muldefs -static
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(std-742797dd06d019e7.std.e4c3ebae17ee837d-cgu.0.rcgu.o): in function `std::sys::pal::unix::os::home_dir::fallback':
/rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys/pal/unix/os.rs:732: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(std-742797dd06d019e7.std.e4c3ebae17ee837d-cgu.0.rcgu.o): in function `<std::sys_common::net::LookupHost as core::convert::TryFrom<(&str,u16)>>::try_from::{{closure}}':
/rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/net.rs:207: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(wasmer_compiler-00c72df1dcee60df.wasmer_compiler.c346b283a3dbd616-cgu.04.rcgu.o): in function `wasmer_compiler::engine::unwind::systemv::UnwindRegistry::publish':
wasmer_compiler.c346b283a3dbd616-cgu.04:(.text._ZN15wasmer_compiler6engine6unwind7systemv14UnwindRegistry7publish17h938519e06edbd158E+0xc1): undefined reference to `dlsym'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(std-742797dd06d019e7.std.e4c3ebae17ee837d-cgu.0.rcgu.o): in function `std::sys::pal::unix::thread::Thread::new':
/rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys/pal/unix/thread.rs:71: undefined reference to `pthread_attr_setstacksize'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys/pal/unix/thread.rs:82: undefined reference to `pthread_attr_setstacksize'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(std-742797dd06d019e7.std.e4c3ebae17ee837d-cgu.0.rcgu.o): in function `std::sys::pal::unix::thread::Thread::set_name':
/rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys/pal/unix/thread.rs:140: undefined reference to `pthread_setname_np'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(std-742797dd06d019e7.std.e4c3ebae17ee837d-cgu.0.rcgu.o): in function `std::sys::pal::unix::thread::guard::current':
/rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys/pal/unix/thread.rs:925: undefined reference to `pthread_attr_getguardsize'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(wasmer_vm-c529e0c1d2ca8ce6.wasmer_vm.310c87423edf2eaf-cgu.13.rcgu.o): in function `wasmer_vm_f32_ceil':
wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f32_ceil+0x2): undefined reference to `ceilf'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(wasmer_vm-c529e0c1d2ca8ce6.wasmer_vm.310c87423edf2eaf-cgu.13.rcgu.o): in function `wasmer_vm_f32_floor':
wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f32_floor+0x2): undefined reference to `floorf'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(wasmer_vm-c529e0c1d2ca8ce6.wasmer_vm.310c87423edf2eaf-cgu.13.rcgu.o): in function `wasmer_vm_f32_trunc':
wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f32_trunc+0x2): undefined reference to `truncf'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(wasmer_vm-c529e0c1d2ca8ce6.wasmer_vm.310c87423edf2eaf-cgu.13.rcgu.o): in function `wasmer_vm_f32_nearest':
wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f32_nearest+0x1e): undefined reference to `ceilf'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f32_nearest+0x2d): undefined reference to `floorf'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f32_nearest+0x75): undefined reference to `floorf'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(wasmer_vm-c529e0c1d2ca8ce6.wasmer_vm.310c87423edf2eaf-cgu.13.rcgu.o): in function `wasmer_vm_f64_ceil':
wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f64_ceil+0x2): undefined reference to `ceil'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(wasmer_vm-c529e0c1d2ca8ce6.wasmer_vm.310c87423edf2eaf-cgu.13.rcgu.o): in function `wasmer_vm_f64_floor':
wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f64_floor+0x2): undefined reference to `floor'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(wasmer_vm-c529e0c1d2ca8ce6.wasmer_vm.310c87423edf2eaf-cgu.13.rcgu.o): in function `wasmer_vm_f64_trunc':
wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f64_trunc+0x2): undefined reference to `trunc'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.x86_64.a(wasmer_vm-c529e0c1d2ca8ce6.wasmer_vm.310c87423edf2eaf-cgu.13.rcgu.o): in function `wasmer_vm_f64_nearest':
wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f64_nearest+0x24): undefined reference to `ceil'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f64_nearest+0x35): undefined reference to `floor'
/usr/lib/gcc-cross/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/ld: wasmer_vm.310c87423edf2eaf-cgu.13:(.text.wasmer_vm_f64_nearest+0x88): undefined reference to `floor'
collect2: error: ld returned 1 exit status

@Lazar955 Lazar955 requested a review from maurolacy October 11, 2024 13:42
@maurolacy
Copy link
Contributor

maurolacy commented Oct 12, 2024

The problem is that the static build requires alpine Linux, and you're using a Debian / Ubuntu variant.

The build-docker target builds a docker image with a static vigilante with no issues. It would then be a matter of reproducing this in the goreleaser setup.

A quick search for alpine in the go releaser site: https://goreleaser.com/customization/cloudsmith/?h=alpine.
Seems that it requires some kind of subscription or paid Pro service (https://goreleaser.com/pro/) :-/

@maurolacy
Copy link
Contributor

What's wrong with plain old Makefile and docker builds btw? Why introduce a new tool (that asks for / requires a paid service), for something that is in the end available for free?

@Lazar955
Copy link
Member Author

The problem is that the static build requires alpine Linux, and you're using a Debian / Ubuntu variant.

The build-docker target builds a docker image with a static vigilante with no issues. It would then be a matter of reproducing this in the goreleaser setup.

A quick search for alpine in the go releaser site: https://goreleaser.com/customization/cloudsmith/?h=alpine. Seems that it requires some kind of subscription or paid Pro service (https://goreleaser.com/pro/) :-/

I think that is for publishing package to apk, apt etc. Than the issue is with the docker image in which we are invoking the goreleser.
Goreleaser is quite standard in go world and very convenient to build binaries/docker/publish package, but once CGO is involved it gets messy

@Lazar955
Copy link
Member Author

Also was wondering why we don't have a static link for debian here's the reason

@maurolacy
Copy link
Contributor

maurolacy commented Oct 14, 2024

Also was wondering why we don't have a static link for debian here's the reason

Yes. This is old stuff, but since static wasmd / wasmvm were in the end never released for Debian / Ubuntu, I think it'll be a long stretch to try to have a static build based on them in these distros.

Long story short: Better to stick to Alpine for static builds, for those involving these projects. Problem now is gorelease doesn't seem to support Alpine containers...

@Lazar955
Copy link
Member Author

Also was wondering why we don't have a static link for debian here's the reason

Yes. This is old stuff, but since static wasmd / wasmvm were in the end never released for Debian / Ubuntu, I think it'll be a long stretch to try to have a static build based on them in these distros.

Long story short: Better to stick to Alpine for static builds, for those involving these projects. Problem now is gorelease doesn't seem to support Alpine containers...

Alpine in not a goreleaser thing, I think the problem we are facing here is goreleaser-cross image being debian based. If we use our Dockerfile which is: 1. Alpine based, 2. Cross-platform built 3. Has goreleaser installed inside. This should work.

I still wonder how this works for Osmosis tho.

@maurolacy
Copy link
Contributor

Alpine in not a goreleaser thing, I think the problem we are facing here is goreleaser-cross image being debian based. If we use our Dockerfile which is: 1. Alpine based, 2. Cross-platform built 3. Has goreleaser installed inside. This should work.

Yes indeed. goreleaser should have a golinuxdistr or so parameter, that allows you to choose the Linux distribution from a set.

I still wonder how this works for Osmosis tho.

Maybe it doesn't. Maybe they've just stick to dynamic builds? Or, they tried to add this, failed, and kept it anyway for reference / future work?

@Lazar955
Copy link
Member Author

Alpine in not a goreleaser thing, I think the problem we are facing here is goreleaser-cross image being debian based. If we use our Dockerfile which is: 1. Alpine based, 2. Cross-platform built 3. Has goreleaser installed inside. This should work.

Yes indeed. goreleaser should have a golinuxdistr or so parameter, that allows you to choose the Linux distribution from a set.

I still wonder how this works for Osmosis tho.

Maybe it doesn't. Maybe they've just stick to dynamic builds? Or, they tried to add this, failed, and kept it anyway for reference / future work?

Looking at their gorelease.yaml those are static links, but not sure if they actually use them in their action. I don't think osmosis would keep dead code/features 🤷

@Lazar955
Copy link
Member Author

I guess this is proof it works for them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants