From 07dbcbc4286dc5da39d9bdcce1286919ca6ddfe3 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 5 Aug 2026 13:11:05 -0500 Subject: [PATCH] fix: patch EXLA Makefile directly for -O0 and -j1 in CI image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit elixir_make builds a sanitized env map for make — MAKEFLAGS and DEBUG never reach make. EXLA also sets make_args to nproc-2 parallel jobs. We must patch the Makefile (-O3→-O0) and override make_args via Application.put_env to actually control compilation behavior. --- Dockerfile.ci | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Dockerfile.ci b/Dockerfile.ci index 1cb36852..785cfd81 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -34,11 +34,14 @@ COPY vendor /tmp/exla_warm/vendor RUN mkdir -p /tmp/exla_warm/config && \ printf 'import Config\nconfig :nx, :default_backend, EXLA.Backend\n' > /tmp/exla_warm/config/config.exs -# Compile all deps. DEBUG=1 tells the EXLA Makefile to use -g instead -# of -O3 — this avoids the heavy optimization passes that OOM-kill g++ -# on low-memory CI runners. MAKEFLAGS=-j1 serializes make jobs. The -# resulting unoptimized NIF is fine for tests. -RUN MAKEFLAGS="-j1" DEBUG=1 mix deps.get && MAKEFLAGS="-j1" DEBUG=1 mix deps.compile +# Compile all deps. EXLA's Makefile defaults to -O3 which OOM-kills g++ +# on low-memory CI runners. Patch it to -O0 before compilation. +# Also override make_args to -j1 (EXLA defaults to nproc-2 parallel jobs) +# since elixir_make's sanitized env blocks MAKEFLAGS/DEBUG from reaching make. +RUN mix deps.get && \ + sed -i 's/-O3/-O0/g' deps/exla/Makefile && \ + mix run -e 'Application.put_env(:exla, :make_args, ["-j1"])' && \ + mix deps.compile # Save the full build cache (libexla.so + .o files + xla_extension lib) # so Make finds all targets already built when restored in the test step.