Skip to content

Cannot compile exla on Mac #1599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nallwhy opened this issue Apr 10, 2025 · 7 comments
Open

Cannot compile exla on Mac #1599

nallwhy opened this issue Apr 10, 2025 · 7 comments

Comments

@nallwhy
Copy link
Contributor

nallwhy commented Apr 10, 2025

Mix.install([
  {:exla, "~> 0.9.0"}
])
==> exla
Unpacking /Users/json/Library/Caches/xla/0.8.0/download/xla_extension-0.8.0-aarch64-darwin-cpu.tar.gz into /Users/json/Library/Caches/mix/installs/elixir-1.18.1-erts-15.2/3e10f8b466ca6981e94700127c3c9d09/deps/exla/cache
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/exla.cc -o cache/0.9.2/objs/exla.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/exla_mlir.cc -o cache/0.9.2/objs/exla_mlir.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/exla_client.cc -o cache/0.9.2/objs/exla_client.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls.cc -o cache/0.9.2/objs/custom_calls.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/exla_nif_util.cc -o cache/0.9.2/objs/exla_nif_util.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/ipc.cc -o cache/0.9.2/objs/ipc.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls/eigh_f32.cc -o cache/0.9.2/objs/custom_calls/eigh_f32.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls/eigh_f64.cc -o cache/0.9.2/objs/custom_calls/eigh_f64.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls/lu_bf16.cc -o cache/0.9.2/objs/custom_calls/lu_bf16.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls/lu_f16.cc -o cache/0.9.2/objs/custom_calls/lu_f16.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls/lu_f32.cc -o cache/0.9.2/objs/custom_calls/lu_f32.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls/lu_f64.cc -o cache/0.9.2/objs/custom_calls/lu_f64.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls/qr_bf16.cc -o cache/0.9.2/objs/custom_calls/qr_bf16.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls/qr_f16.cc -o cache/0.9.2/objs/custom_calls/qr_f16.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls/qr_f32.cc -o cache/0.9.2/objs/custom_calls/qr_f32.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/custom_calls/qr_f64.cc -o cache/0.9.2/objs/custom_calls/qr_f64.o
c++ -fPIC -I/Users/json/.local/share/mise/installs/erlang/27.2/erts-15.2/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -std=c++17 -w -DLLVM_VERSION_STRING= -O3 -c c_src/exla/exla_cuda.cc -o cache/0.9.2/objs/exla_cuda.o
In file included from c_src/exla/exla_client.cc:1:
In file included from c_src/exla/exla_client.h:13:
In file included from cache/xla_extension/include/xla/pjrt/pjrt_client.h:47:
In file included from cache/xla_extension/include/xla/pjrt/pjrt_future.h:30:
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:177:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  177 |     return AsPtr().template Map(std::forward<F>(f));
      |                             ^
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:182:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  182 |     return AsPtr().template Map(executor, std::forward<F>(f));
      |                             ^
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:197:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  197 |     return AsPtr().template TryMap(std::forward<F>(f));
      |                             ^
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:202:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  202 |     return AsPtr().template TryMap(executor, std::forward<F>(f));
      |                             ^
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:207:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  207 |     return AsPtr().template FlatMap(std::forward<F>(f));
      |                             ^
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:212:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  212 |     return AsPtr().template FlatMap(executor, std::forward<F>(f));
      |                             ^
In file included from c_src/exla/exla.cc:4:
In file included from c_src/exla/exla_client.h:13:
In file included from cache/xla_extension/include/xla/pjrt/pjrt_client.h:47:
In file included from cache/xla_extension/include/xla/pjrt/pjrt_future.h:30:
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:177:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  177 |     return AsPtr().template Map(std::forward<F>(f));
      |                             ^
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:182:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  182 |     return AsPtr().template Map(executor, std::forward<F>(f));
      |                             ^
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:197:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  197 |     return AsPtr().template TryMap(std::forward<F>(f));
      |                             ^
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:202:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  202 |     return AsPtr().template TryMap(executor, std::forward<F>(f));
      |                             ^
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:207:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  207 |     return AsPtr().template FlatMap(std::forward<F>(f));
      |                             ^
cache/xla_extension/include/xla/tsl/concurrency/async_value_ref.h:212:29: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
  212 |     return AsPtr().template FlatMap(executor, std::forward<F>(f));
      |                             ^
6 errors generated.
6 errors generated.
make: *** [cache/0.9.2/objs/exla_client.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [cache/0.9.2/objs/exla.o] Error 1
could not compile dependency :exla, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile exla --force", update it with "mix deps.update exla" or clean it with "mix deps.clean exla"
** (Mix.Error) Could not compile with "make" (exit status: 2).
You need to have gcc and make installed. Try running the
commands "gcc --version" and / or "make --version". If these programs
are not installed, you will be prompted to install them.

    (mix 1.18.1) lib/mix.ex:613: Mix.raise/2
    (elixir_make 0.9.0) lib/elixir_make/compiler.ex:53: ElixirMake.Compiler.compile/1
    /Users/json/Library/Caches/mix/installs/elixir-1.18.1-erts-15.2/3e10f8b466ca6981e94700127c3c9d09/deps/exla/mix.exs:194: EXLA.MixProject.cached_make/1
    (mix 1.18.1) lib/mix/task.ex:574: Mix.Task.run_alias/6
    (mix 1.18.1) lib/mix/tasks/compile.all.ex:117: Mix.Tasks.Compile.All.run_compiler/2
    (mix 1.18.1) lib/mix/tasks/compile.all.ex:97: Mix.Tasks.Compile.All.compile/4
    (mix 1.18.1) lib/mix/tasks/compile.all.ex:71: Mix.Tasks.Compile.All.do_run/2
    (mix 1.18.1) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
$ gcc --version
Apple clang version 17.0.0 (clang-1700.0.13.3)
Target: arm64-apple-darwin24.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
@nallwhy
Copy link
Contributor Author

nallwhy commented Apr 10, 2025

Possibly related:

llvm/llvm-project#80801

@Joss-Steward
Copy link

I just ran into this on my own, it seemed related to this clang issue: llvm/llvm-project#94194 and I was able to resolve it by cloning the exla repo and adding -Wno-missing-template-arg-list-after-template-kw to the CFLAGS in the exla Makefile.

Specifically I saw this with Apple Clang 17.0.0 on my laptop, while it worked fine with clang 16.0.0

@nallwhy
Copy link
Contributor Author

nallwhy commented Apr 10, 2025

It looks like this issue has been fixed in the latest version of the file.
https://github.com/openxla/xla/blob/cf7150f5755f7c5d985038410bd5c62c5a0debc2/xla/tsl/concurrency/async_value_ref.h

Would updating the xla version used in elixir-nx/xla resolve this?

@Joss-Steward
Copy link

@nallwhy I believe it would but I'm not very familiar with the XLA project and although I took a look I couldn't figure out how to do so quickly. As far as I can tell this is a new type of warning which was added to Clang, and is now warning about existing issues in the XLA code.

Updating the version of XLA in the XLA project is probably the right thing to do but for me just modifying it to ignore the warning let me continue the project I was working on. I could probably install Clang 16 on my laptop instead but that seemed tricky.

@jyc
Copy link

jyc commented Apr 25, 2025

I ran into this as well after upgrading macOS. @Joss-Steward's idea of vendoring to disable the warning makes sense. In case it helps others: in my case my mix.exs already pointed to Nx on Git. So I just made a (temporary) fork on GitHub and changed the repository from elixir-nx/nx:

defp deps do
  [
    # ...
    {:exla, github: "your-username-here/nx", sparse: "exla", ref: "commit-with-patch-here"},
    {:nx, github: "your-username-here/nx", sparse: "nx", ref: "fcommit-with-patch-here", override: true},
    # ...
  ]
end

Vendoring is a good solution too but I didn't want to deal with Git submodules :) and only changing mix.exs should be very easy to revert.

@kpy3
Copy link

kpy3 commented Apr 26, 2025

Another quick solution until fix committed is to define environment variable CXX with llvm 16, as mentioned earlier. For brew'ed llvm define CXX to /opt/homebrew/opt/llvm@16/bin/clang++

@polvalente
Copy link
Contributor

polvalente commented Apr 26, 2025

With #1603 you'll be able to add the custom no-warn flag. This is not necessarily a fix for the underlying issue (I'll see about updating XLA), but it will unblock everyone and serve as a temporary solution for future similar problems.

Example:

$ CFLAGS=-Wnomissing-template-arg-list-after-template-kw mix compile
...
c++ -Wnomissing-template-arg-list-after-template-kw -fPIC ... -c c_src/exla/custom_calls/qr_f64.cc -o cache/0.9.1/objs/custom_calls/qr_f64.o
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants