This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/wul- on 2025-05-27 15:10:52+00:00.


Build your rust release binaries with glibc. You’ll find the compile times are faster and you won’t need a beefy CI server. In my situation, switching from alpine to debian:slim resulted in a 2x CI speedup.

Figured this out after an OOM debugging session whilst building a tiny crate; apparently, a 24G CI server wasn’t good enough 😅.

This is the binary:

//!cargo //! [dependencies] //! aws-config = { version = “1.1.7”, features = [“behavior-version-latest”] } //! aws-sdk-ec2 = “1.133.0” //! tokio = { version = “1”, features = [“full”] } //! ```

use aws_sdk_ec2 as ec2;

[::tokio::main]

async fn main() -> Result<(), ec2::Error> { let config = aws_config::load_from_env().await; let client = aws_sdk_ec2::Client::new(&config);

let _resp = client
    .associate_address()
    .instance_id(std::env::var("INSTANCE_ID").expect("INSTANCE_ID must be set"))
    .allocation_id(std::env::var("ALLOCATION_ID").expect("ALLOCATION_ID must be set"))
    .send()
    .await?;

Ok(())

}


For our friends (or killer robots 😉) trying to debug in the future, here are the logs:

16 72.41 Compiling aws-sdk-ec2 v1.133.0

16 77.77 Compiling aws-config v1.6.3

16 743.2 rustc-LLVM ERROR: out of memory

16 743.2 Allocation failed#16 775.6 error: could not compile aws-sdk-ec2 (lib)

16 775.6

16 775.6 Caused by:

16 775.6 process didn’t exit successfully: …


If you're dealing with the same thing, you can likely fix the error above in your setup by dynamically linking against Alpine's musl so it uses less RAM when LLVM processes the entire dependency graph. To do this, use `alpine:*` as a base and run `apk add rust cargo` instead of using `rust:*-alpine*` (this will force dynamic linking). I found using `-C target-feature-crt-static` did not work as per <https://www.reddit.com/r/rust/comments/j52wwd/overcoming_linking_hurdles_on_alpine_linux/>. Note: this was using rust 2021 edition.

Hope this made sense and helps someone else in our community <3