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

Unable to utilise for AWS Lambda #66

Open
N4r35h opened this issue Feb 20, 2024 · 3 comments
Open

Unable to utilise for AWS Lambda #66

N4r35h opened this issue Feb 20, 2024 · 3 comments
Assignees

Comments

@N4r35h
Copy link

N4r35h commented Feb 20, 2024

im not able to compile the function while using the library as it utilizes CGO, is there any workaround or anything in the works to support compiling without CGO enabled so i can get this working in a AWS Lambda ?

i get the below error when compiling
github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go: build constraints exclude all Go files in /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3

@zhenlu
Copy link
Contributor

zhenlu commented Feb 23, 2024

Unfortunately our crypto lib is a Rust based library and CGO is required to create go bindings. Could you try with CGO_ENABLED=1 setting while compiling?

@N4r35h
Copy link
Author

N4r35h commented Feb 24, 2024

with CGO_ENABLED=1 it wont work as Lambda functions run with restrictions and amazon linux image i get GLIBC (perticular version not found error) this is related to other deps i use it would be perfered to some how statically link all deps including lightspark into the final binary

i followed https://awsteele.com/blog/2021/10/17/cgo-for-arm64-lambda-functions.html and compiled it works normally without lightspark and works without the above mentioned GLIBC error but when i try to do the same for the function with lightspark lib i get the below error

++ export GOOS=linux
++ GOOS=linux
++ export CGO_ENABLED=1
++ CGO_ENABLED=1
+++ pwd
++ export CC=/home/<redacted>/zcc.sh
++ CC=/home/<redacted>/zcc.sh
+++ pwd
++ export CXX=/home/<redacted>/zxx.sh
++ CXX=/home/<redacted>/zxx.sh
++ GOARCH=arm64
++ ZTARGET=aarch64-linux-musl
++ go build '-ldflags=-linkmode external' -o arm64/bootstrap
# <redacted>
/usr/local/go/pkg/tool/linux_amd64/link: running /home/<redacted>/zcc.sh failed: exit status 1
ld.lld: error: undefined symbol: _Unwind_Resume
>>> referenced by c_str.rs:0 (library/alloc/src/ffi/c_str.rs:0)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(_$LT$$RF$str$u20$as$u20$alloc..ffi..c_str..CString..new..SpecNewImpl$GT$::spec_new_impl::h6aded4389bcc1ae1) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a
>>> referenced by string.rs:650 (library/alloc/src/string.rs:650)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(alloc::string::String::from_utf8_lossy::h1425788ebe20f697) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a
>>> referenced by fmt.rs:612 (library/alloc/src/fmt.rs:612)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(alloc::fmt::format::format_inner::h29b385f4ffd6461e) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a
>>> referenced 63 more times

ld.lld: error: undefined symbol: _Unwind_GetLanguageSpecificData
>>> referenced by gcc.rs:280 (library/std/src/sys/personality/gcc.rs:280)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: _Unwind_GetIPInfo
>>> referenced by gcc.rs:282 (library/std/src/sys/personality/gcc.rs:282)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: _Unwind_GetRegionStart
>>> referenced by gcc.rs:289 (library/std/src/sys/personality/gcc.rs:289)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: _Unwind_SetGR
>>> referenced by gcc.rs:222 (library/std/src/sys/personality/gcc.rs:222)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a
>>> referenced by gcc.rs:227 (library/std/src/sys/personality/gcc.rs:227)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: _Unwind_SetIP
>>> referenced by gcc.rs:228 (library/std/src/sys/personality/gcc.rs:228)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(rust_eh_personality) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: _Unwind_GetDataRelBase
>>> referenced by gcc.rs:291 (library/std/src/sys/personality/gcc.rs:291)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hf88f59bb8cb2649f) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a
>>> referenced by gcc.rs:291 (library/std/src/sys/personality/gcc.rs:291)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::sys::personality::gcc::find_eh_action::_$u7b$$u7b$closure$u7d$$u7d$::h3b7501729ec236b5) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: _Unwind_GetTextRelBase
>>> referenced by gcc.rs:290 (library/std/src/sys/personality/gcc.rs:290)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h7e634549dfa15f32) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a
>>> referenced by gcc.rs:290 (library/std/src/sys/personality/gcc.rs:290)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::sys::personality::gcc::find_eh_action::_$u7b$$u7b$closure$u7d$$u7d$::h4cbd8ab2594c20db) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: open64
>>> referenced by fs.rs:1067 (library/std/src/sys/unix/fs.rs:1067)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::sys::unix::fs::File::open_c::h57abbd8c2f9dc216) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: stat64
>>> referenced by fs.rs:1619 (library/std/src/sys/unix/fs.rs:1619)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::sys::unix::fs::stat::h8af3364f2e11eb20) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a
>>> referenced by fs.rs:1619 (library/std/src/sys/unix/fs.rs:1619)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::sys::common::small_c_string::run_with_cstr_allocating::he80a07c727fadfd5) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: fstat64
>>> referenced by fs.rs:1086 (library/std/src/sys/unix/fs.rs:1086)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::backtrace_rs::symbolize::gimli::libs_dl_iterate_phdr::callback::h27e820df51e6cb77) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a
>>> referenced by fs.rs:1086 (library/std/src/sys/unix/fs.rs:1086)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::backtrace_rs::symbolize::gimli::mmap::h57bdc3d52c1d36ba) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: lseek64
>>> referenced by fs.rs:1220 (library/std/src/sys/unix/fs.rs:1220)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::backtrace_rs::symbolize::gimli::libs_dl_iterate_phdr::callback::h27e820df51e6cb77) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: mmap64
>>> referenced by mmap_unix.rs:19 (library/std/src/../../backtrace/src/symbolize/gimli/mmap_unix.rs:19)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::backtrace_rs::symbolize::gimli::mmap::h57bdc3d52c1d36ba) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: _Unwind_Backtrace
>>> referenced by libunwind.rs:93 (library/std/src/../../backtrace/src/backtrace/libunwind.rs:93)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(_$LT$std..sys_common..backtrace.._print..DisplayBacktrace$u20$as$u20$core..fmt..Display$GT$::fmt::hc38bcf44d9e857e3) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

ld.lld: error: undefined symbol: _Unwind_GetIP
>>> referenced by libunwind.rs:43 (library/std/src/../../backtrace/src/backtrace/libunwind.rs:43)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::sys_common::backtrace::_print_fmt::_$u7b$$u7b$closure$u7d$$u7d$::h0b7fa9d681be3e73) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a
>>> referenced by libunwind.rs:43 (library/std/src/../../backtrace/src/backtrace/libunwind.rs:43)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::sys_common::backtrace::_print_fmt::_$u7b$$u7b$closure$u7d$$u7d$::h0b7fa9d681be3e73) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a
>>> referenced by libunwind.rs:43 (library/std/src/../../backtrace/src/backtrace/libunwind.rs:43)
>>>               lightspark_crypto.lightspark_crypto.f336b45074b1b2ff-cgu.0.rcgu.o:(std::sys_common::backtrace::_print_fmt::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hab2e106e23f0b9b1) in archive /home/n4r35h/go/pkg/mod/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.0.3/libs/linux/arm64/liblightspark_crypto.a

is there a way to statically link these dependencies ?

@balena-zh
Copy link
Contributor

balena-zh commented Mar 21, 2024

@N4r35h it seems per your description you're using musl libc and not GLIBC. The former is usually offered by Alpine Linux, are you able to use another Linux distribution (Amazon Linux, Ubuntu, Debian, etc) that uses GLIBC instead? Even though you end up getting a binary that would depend on system's GLIBC (therefore not statically linked), as per Lambda runtimes description, you'll end up obtaining a compatible binary (except if you compile using a very ancient distribution, with a very old GLIBC).

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

No branches or pull requests

3 participants