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.