fix: patch EXLA Makefile directly for -O0 and -j1 in CI image
Some checks failed
Build base image / Build and push base image (push) Successful in 1m58s
Build and Push / Build CI test image (push) Failing after 5m58s
Build and Push / Build and Push Docker Image (push) Has been skipped

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.
This commit is contained in:
Graham McIntire 2026-08-05 13:11:05 -05:00
parent 484c59f217
commit 07dbcbc428

View file

@ -34,11 +34,14 @@ COPY vendor /tmp/exla_warm/vendor
RUN mkdir -p /tmp/exla_warm/config && \ RUN mkdir -p /tmp/exla_warm/config && \
printf 'import Config\nconfig :nx, :default_backend, EXLA.Backend\n' > /tmp/exla_warm/config/config.exs 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 # Compile all deps. EXLA's Makefile defaults to -O3 which OOM-kills g++
# of -O3 — this avoids the heavy optimization passes that OOM-kill g++ # on low-memory CI runners. Patch it to -O0 before compilation.
# on low-memory CI runners. MAKEFLAGS=-j1 serializes make jobs. The # Also override make_args to -j1 (EXLA defaults to nproc-2 parallel jobs)
# resulting unoptimized NIF is fine for tests. # since elixir_make's sanitized env blocks MAKEFLAGS/DEBUG from reaching make.
RUN MAKEFLAGS="-j1" DEBUG=1 mix deps.get && MAKEFLAGS="-j1" DEBUG=1 mix deps.compile 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) # 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. # so Make finds all targets already built when restored in the test step.