Description
🐛 Bug description
When running npx Serverless deploy, or cargo build --release --target x86_64-unknown-linux-musl, I receive this error.
error: linking with `x86_64-linux-musl-gcc` failed: exit code: 1
|
= note: "x86_64-linux-musl-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-nostartfiles"
error: aborting due to previous error; 1 warning emitted
I've cut most of the error because it would make this unreadable.
I have walked through most of the steps that you will find online for MacOS such as :
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
serverless.yml
service: hi
provider:
name: aws
runtime: rust
package:
individually: true
plugins:
- serverless-rust
custom:
rust:
dockerless: true
functions:
hello:
handler: hello
events:
- http:
path: "/"
method: POST
cors: true
main.rs // the crate completely compiles if I comment out the pool and create_user fn which runs a diesel function.
use chrono::prelude::Utc;
use hello::db::establish_connection;
use hello::models::users::model::*;
use lambda_http::{handler, lambda, Body, Context, IntoResponse, Request};
use serde_json::json;
type Error = Box<dyn std::error::Error + Sync + Send + 'static>;
#[tokio::main]
async fn main() -> Result<(), Error> {
lambda::run(handler(hello)).await?;
Ok(())
}
async fn hello(req: Request, _: Context) -> Result<impl IntoResponse, Error> {
let body = match req.body() {
Body::Text(data) => data,
_ => panic!("request not satisfied"),
};
let body: Result<NewUser, _> =
serde_json::from_str(body).map_err(|err| println!("Error - {}", err.to_string()));
let conn = establish_connection();
if let Ok(body) = body {
let user = NewUser {
//fields
};
let user = User::create(user);
let user = User::create_user(&conn, user).await?;
let user = serde_json::to_string(&user)?;
Ok(json!(user))
} else {
Ok(json!({}))
}
}
This issue looks similar to the one listed for open-ssl, but this is an issue for diesel as well.
🤔 Expected Behavior
This should compile as normal.
If I run cargo build, it'll compile perfectly fine, but running cargo build --release --target x86_64-unknown-linux-musl,
not so much
👟 Steps to reproduce
make sure to use any diesel functionality, in main.rs, then attempt to compile with cargo build --release --target x86_64-unknown-linux-musl or npx Serverless deploy
🌍 Your environment
MacOS big sure 11.1
rustc 1.49.0 (e1884a8e3 2020-12-29)
cargo 1.49.0 (d00d64df9 2020-12-05)
serverless version:
"serverless": "^1.83.2",
rust-plugin version:
"serverless-rust": "^0.3.8"