From 1b7cab076681d151735529711eb333c710b98631 Mon Sep 17 00:00:00 2001 From: z Date: Tue, 3 Mar 2026 06:30:59 -0800 Subject: [PATCH 1/3] fix: use lld linker on Linux to prevent arm64 OOM during linking --- .cargo/config.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 94dd605be..f0e43da95 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,3 +3,13 @@ incremental = true [target.x86_64-pc-windows-msvc] rustflags = ["-Ctarget-feature=+crt-static"] + +# Use lld linker on Linux — significantly less memory than default ld, +# critical for arm64 builds on 16GB Graviton runners. +[target.x86_64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-Clink-arg=-fuse-ld=lld"] + +[target.aarch64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-Clink-arg=-fuse-ld=lld"] From 1cab690b4e7c576a57d6e82299ded487b83681e5 Mon Sep 17 00:00:00 2001 From: z Date: Tue, 3 Mar 2026 06:33:06 -0800 Subject: [PATCH 2/3] fix: add CARGO_BUILD_JOBS=4 and clang for lld linker in Docker build --- docker/Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index bdd18f849..73b9e7bb5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -25,6 +25,7 @@ ARG VCS_REF # Install build dependencies RUN apt-get update && apt-get install -y \ + clang \ libclang-dev \ cmake \ libssl-dev \ @@ -43,6 +44,10 @@ COPY . . # Add rustfmt for build RUN rustup component add rustfmt +# Limit parallel codegen/linker jobs to prevent OOM on arm64 (16GB Graviton). +# lld is configured as the linker via .cargo/config.toml (uses ~3x less RAM than ld). +ENV CARGO_BUILD_JOBS=4 + # Build the project # Build the entire workspace to properly resolve all dependencies # Then extract just the hanzo_node binary we need From 077015a4d21d6eee8716be01a1c650d316d77263 Mon Sep 17 00:00:00 2001 From: z Date: Tue, 3 Mar 2026 06:34:01 -0800 Subject: [PATCH 3/3] fix: add clang + CARGO_BUILD_JOBS=4 to CI Dockerfile for arm64 OOM prevention --- .github/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/Dockerfile b/.github/Dockerfile index 0fb558e4d..b7d5afe49 100644 --- a/.github/Dockerfile +++ b/.github/Dockerfile @@ -1,7 +1,7 @@ # Use a Rust base image FROM rust:bookworm AS builder ARG BUILD_TYPE -RUN apt-get update && apt-get install -y libclang-dev cmake libssl-dev libc++-dev libc++abi-dev lld +RUN apt-get update && apt-get install -y clang libclang-dev cmake libssl-dev libc++-dev libc++abi-dev lld # Install nvm, npm and node RUN rm /bin/sh && ln -s /bin/bash /bin/sh @@ -36,6 +36,10 @@ COPY . . RUN rustup default 1.88 RUN rustup component add rustfmt +# Limit parallel jobs to prevent OOM on arm64 (16GB Graviton). +# lld linker configured in .cargo/config.toml (uses ~3x less RAM than ld). +ENV CARGO_BUILD_JOBS=4 + # Build main code, pre-compile tests, and cleanup in SINGLE layer # This is critical - separate RUN commands create Docker layers that preserve old data # Even if we delete files in a later layer, the image size includes all layers