无法使用rusoto编译Rust AWS Lambda

14ifxucb  于 2022-12-19  发布在  其他
关注(0)|答案(1)|浏览(106)

我在编译Rust lambda时遇到了一些问题。这些问题是在我包含rusoto包之后开始的,它正在抱怨链接器问题(选项和库)。
我在跑步:

cargo lambda build

获取:

= note: warning: unsupported linker arg: -znoexecstack
          warning: unsupported linker arg: -zrelro
          warning: unsupported linker arg: -znow
          ld.lld: error: unable to find library -lssl
          ld.lld: error: unable to find library -lcrypto

我的货物。

[package]
name = "super-lambda"
version = "0.1.0"
edition = "2021"

# Starting in Rust 1.62 you can use `cargo add` to add dependencies 
# to your project.
#
# If you're using an older Rust version,
# download cargo-edit(https://github.com/killercup/cargo-edit#installation) 
# to install the `add` subcommand.
#
# Running `cargo add DEPENDENCY_NAME` will
# add the latest version of a dependency to the list,
# and it will keep the alphabetic ordering for you.

[dependencies]
lambda_http = "0.7"
lambda_runtime = "0.7"
lazy_static = "1.4.0"
rusoto_core = "0.48.0"
rusoto_dynamodb = "0.48.0"
serde = "1.0.149"
tokio = { version = "1", features = ["macros"] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] }

我确实试过禁用zig-linker:

cargo lambda build --disable-zig-linker

然后它编译,但AWS会抱怨:

/var/task/bootstrap: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory

我能做些什么来解决这个问题?

ie3xauqp

ie3xauqp1#

Cargo-lambda将针对x86_64-unknown-linux-gnu进行交叉编译。为了避免依赖libssl依赖项,您可以尝试使用rustls为x1m2 n1 a构建项目。您应该能够为rusoto启用rustls功能,如下所示:

rusoto_core = {version = "0.48.0", features = ["rustls"], default-features = false}
rusoto_dynamodb = {version = "0.48.0", features = ["rustls"], default-features = false}

您还可以看到与此主题相关的GitHub issue
如果您使用的是Linux,您可能会尝试安装libssl-dev并再次构建它。但是,根据我的经验,zigbuildcargo-lambda用于交叉编译)可能很难找到这种依赖关系。

相关问题