From 1de02f731bdc118e067d3fde7cc2c8aeabfa19c0 Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Thu, 19 Oct 2023 05:19:23 +0000 Subject: [PATCH] Add CARGO_USE_GIT_CLI to the Dockerfile to work around an OOM bug during cross-compiling (#4828) ## Issue Addressed #4827 ## Proposed Changes This PR introduces a new build-arg to the Lighthouse Dockerfile: `CARGO_USE_GIT_CLI`. This arg will be passed into the `CARGO_NET_GIT_FETCH_WITH_CLI` [environment variable](https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli), which instructs `cargo` to use the git CLI during `fetch` operations instead of the git library. Doing so works around [a bug](https://github.com/rust-lang/cargo/issues/10583) with the git library that causes it to go OOM during `fetch` operations on `arm64` platforms. The default value is `false` so this doesn't affect Lighthouse builds or the CI pipeline. Running a build with `--build-arg CARGO_USE_GIT_CLI=true` will activate it, which is necessary to cross-compile the `arm64` binary when not using `cross` (i.e., when building via the Dockerfile instead of natively if you don't have a rust environment ready to go). Special thanks to @michaelsproul for helping me repro the initial problem. Co-authored-by: Michael Sproul --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index bcddef8a6..878a3602b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,10 @@ RUN apt-get update && apt-get -y upgrade && apt-get install -y cmake libclang-de COPY . lighthouse ARG FEATURES ARG PROFILE=release +ARG CARGO_USE_GIT_CLI=true ENV FEATURES $FEATURES ENV PROFILE $PROFILE +ENV CARGO_NET_GIT_FETCH_WITH_CLI=$CARGO_USE_GIT_CLI RUN cd lighthouse && make FROM ubuntu:22.04