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

Mix for 1.4.1 is not properly compiling C drivers #5748

Closed
ghost opened this issue Feb 8, 2017 · 11 comments
Closed

Mix for 1.4.1 is not properly compiling C drivers #5748

ghost opened this issue Feb 8, 2017 · 11 comments

Comments

@ghost
Copy link

ghost commented Feb 8, 2017

Environment

  • Elixir & Erlang versions (elixir --version): Elixir 1.41
  • Operating system: Fedora 25, Alpine 3.5
  • mix project that uses Feuerlabs/exometer

Current behavior

Compile a Phoenix app that uses exometer-core and exometer (for statsd), and thus Feuerlabs/netlink

Do a mix deps.compile and everything compiles w/out errors, but the netlink C driver is not compiled.

When I run the app via mix phoenix.server, the app will stop with the following info:

=INFO REPORT==== 
    application: logger
    exited: stopped
    type: temporary
** (Mix) Could not start application netlink: :netlink_app.start(:normal, []) returned an error: shutdown: failed to start child: :netlink
    ** (EXIT) an exception was raised:
        ** (ErlangError) erlang error: {:open_error, -10}
            (netlink) /home/vagrant/work/my_app/deps/netlink/src/netlink_drv.erl:97: :netlink_drv.open/1
            (netlink) /home/vagrant/work/my_app/deps/netlink/src/netlink.erl:206: :netlink.init_drv/2
            (stdlib) gen_server.erl:328: :gen_server.init_it/6
            (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

mix.exs

defmodule MyApp.Mixfile do
  use Mix.Project

  def project do
    [app: :my_app,
     version: "0.1.0",
     elixir: "~> 1.4",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps()]
  end

  def application do
    # Specify extra applications you'll use from Erlang/Elixir
    [extra_applications: [:logger, :exometer, :exometer_collectd, :netlink]]
  end

  # Type "mix help deps" for more examples and options
  defp deps do
    [{:lager, "~> 3.2", override: true},
     {:exometer, github: "Feuerlabs/exometer"},
     {:exometer_core, "~> 1.4.0", override: true},
     {:amqp_client, git: "https://github.com/jbrisbin/amqp_client.git", override: true}
    ]
  end
end

Expected behavior

The netlink driver is comiled by mix (and thus via rebar or rebar3), and the app runs w/out any errors.

@ericmj
Copy link
Member

ericmj commented Feb 8, 2017

I can't reproduce on osx and elixir master with the following dependencies:

[{:lager, "~> 3.2", override: true},
 {:exometer, github: "Feuerlabs/exometer"},
 {:exometer_core, "~> 1.4.0", override: true},
 {:amqp_client, github: "jbrisbin/amqp_client", override: true},
 {:rabbit_common, github: "jbrisbin/rabbit_common", override: true}]

Can you show the console output when compiling netlink? I am guessing this is a problem when compiling the C code.

@ghost
Copy link
Author

ghost commented Feb 8, 2017

Unfortunately, there are no errors when compiling netlink:

# <snip>
===> Compiling goldrush
===> Compiling lager
===> Compiling exometer_core
===> Compiling exometer_collectd
===> Compiling netlink
===> Compiling exometer

@ericmj
Copy link
Member

ericmj commented Feb 8, 2017

I don't think this is a mix issue since it seems to work on some machines but not others.

Netlink seems to have issues with Alpine in particular: Feuerlabs/netlink#7.

@ghost
Copy link
Author

ghost commented Feb 8, 2017

Hadn't seen that compile error before about Alpine - I'm ready to abandon exometer altogether now.

Though for this bug, I'm getting the error on a Fedora 25 VM, so it's not necessarily related to the same.

@talentdeficit
Copy link

alpine breaks up otp into packages for each app. rebar3 fails in some cases because required apps are missing. you could try installing the full set of erlang packages and trying again

@ghost
Copy link
Author

ghost commented Feb 8, 2017

If it helps: I'm testing this first on Fedora, not on Alpine.

Moving back to Elixir 1.3.4 (same OS, same OTP, 19.2) and doing a clean build works - mix run completes without errors, and the netlink driver was compiled.

@josevalim
Copy link
Member

Can you please try Elixir v1.4.0 but specify:

{:netlink, github: "Feuerlabs/netlink", override: true, manager: :rebar}

and let us know if it works?

@ghost
Copy link
Author

ghost commented Feb 8, 2017

Unfortunately, I cannot make it that far w/ 1.4.0 - mix deps.compile fails with


** (Mix) Could not compile dependency :afunix, "/home/vagrant/.mix/rebar3 bare compile --paths "/home/vagrant/work/my_app/_build/dev/lib/*/ebin"" command failed
. You can recompile this dependency with "mix deps.compile afunix", update it with "mix deps.update afunix" or clean it with "mix deps.clean afunix"

(which, I believe, is one of the bugs that 1.4.1 fixed)

@josevalim
Copy link
Member

josevalim commented Feb 9, 2017 via email

@ghost
Copy link
Author

ghost commented Feb 9, 2017

1.4.1 with the explilcit manager: rebar worked!

Saw this in the output:

Compiled src/netlink_sup.erl
Compiled src/netlink_stat.erl
Compiled src/netlink_gen.erl
Compiled src/netlink_app.erl
Compiled src/netlink_drv.erl
Compiled src/netlink_codec.erl
Compiled src/netlink.erl
Compiled src/netl_codec.erl
Compiling c_src/netlink_drv.c
...

And got this in the build directory, at last:

ls -laF _build/dev/lib/netlink/priv/
total 40
drwxrwxr-x.  2 vagrant vagrant    46 Feb  9 12:57 ./
drwxrwxr-x. 10 vagrant vagrant   174 Feb  9 12:57 ../
-rw-rw-r--.  1 vagrant vagrant     5 Feb  9 12:54 .gitignore
-rwxrwxr-x.  1 vagrant vagrant 33288 Feb  9 12:57 netlink_drv.so*

mix.run ran w/out errors.

Feel free to close this, unless some other change needs to be made.

@josevalim
Copy link
Member

So it seems the netlink project is not properly compiled under rebar3. There is a pull request for this: Feuerlabs/netlink#6. Hopefully they will merge it soon. Thanks for following up!

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

No branches or pull requests

3 participants