Skip to content
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

NIF compilation error on FreeBSD #4

Open
nicocaille opened this issue Apr 13, 2021 · 2 comments · May be fixed by #5
Open

NIF compilation error on FreeBSD #4

nicocaille opened this issue Apr 13, 2021 · 2 comments · May be fixed by #5

Comments

@nicocaille
Copy link

When trying to compile this package (as a dependency) getting the following error:

==> siphash
could not compile dependency :siphash, "mix compile" failed. You can recompile this dependency with "mix deps.compile siphash", update it with "mix deps.update siphash" or clean it with "mix deps.clean siphash"
** (MatchError) no match of right hand side value: {"make: \"/usr/local/xiloc/analytics/deps/siphash/Makefile\" line 5: Missing dependency operator\nmake: \"/usr/local/xiloc/analytics/deps/siphash/Makefile\" line 11: Need an operator\nmake: Fatal errors encountered -- cannot continue\nmake: stopped in /usr/local/xiloc/analytics/deps/siphash\n", 1}
    /usr/local/xiloc/analytics/deps/siphash/mix.exs:92: Mix.Tasks.Compile.Make.run/1
    (mix 1.11.4) lib/mix/task.ex:394: Mix.Task.run_task/3
    (mix 1.11.4) lib/mix/tasks/compile.all.ex:90: Mix.Tasks.Compile.All.run_compiler/2
    (mix 1.11.4) lib/mix/tasks/compile.all.ex:70: Mix.Tasks.Compile.All.compile/4
    (mix 1.11.4) lib/mix/tasks/compile.all.ex:57: Mix.Tasks.Compile.All.with_logger_app/2
    (mix 1.11.4) lib/mix/tasks/compile.all.ex:35: Mix.Tasks.Compile.All.run/1
    (mix 1.11.4) lib/mix/task.ex:394: Mix.Task.run_task/3
    (mix 1.11.4) lib/mix/tasks/compile.ex:119: Mix.Tasks.Compile.run/1

I managed to get rid of the error by disabling the NIF via putting the following lines in my config.exs:

config :siphash,
  disable_nifs: true

The server is running: FreeBSD 12.2-RELEASE-p6 GENERIC amd64 with the following Elixir/Erlang versions:

elixir          1.11.4-otp-23
erlang          23.3.1

Thanks for your help

@feld
Copy link

feld commented Sep 7, 2021

Correct solution is to modify mix.exs to have it call gmake instead of make:

diff --git a/mix.exs b/mix.exs
index b19cdef..4df56e7 100644
--- a/mix.exs
+++ b/mix.exs
@@ -81,7 +81,7 @@ end

 defmodule Mix.Tasks.Clean.Make do
   def run(_) do
-    { _result, 0 } = System.cmd("make", ["clean"], stderr_to_stdout: true)
+    { _result, 0 } = System.cmd("gmake", ["clean"], stderr_to_stdout: true)^M
     :ok
   end
 end
@@ -89,7 +89,7 @@ end
 defmodule Mix.Tasks.Compile.Make do
   def run(_) do
     if !Application.get_env(:siphash, :disable_nifs)  do
-      { _result, 0 } = System.cmd("make", ["priv/siphash.so"], stderr_to_stdout: true)
+      { _result, 0 } = System.cmd("gmake", ["priv/siphash.so"], stderr_to_stdout: true)^M
       Mix.Project.build_structure()
     end
     :ok
     ```

@feld feld linked a pull request Sep 7, 2021 that will close this issue
@norbu09
Copy link

norbu09 commented Dec 8, 2022

the patch @feld suggests works for me and solves a compile problem i have on FreeBSD. This is used as a dependency in https://github.com/plausible/analytics and stops it from compiling on FreeBSD

/cc @plausible

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

Successfully merging a pull request may close this issue.

3 participants