adoptoposs / mjml_nif

Elixir NIF bindings for the MJML Rust implementation (mrml)
https://hexdocs.pm/mjml
MIT License
122 stars 17 forks source link

unable to compile on non-m1 macbook pro #6

Closed jonathanstiansen closed 3 years ago

jonathanstiansen commented 3 years ago

When attempting to compile MJML, it would not finish.

⋊> ~on main ⨯ mix deps.compile mjml                                                                                                                                                                                   
==> mjml
Compiling NIF crate :mjml_nif (native/mjml_nif)...

Compiling on macOS requires special link args in order to compile
correctly.

Rustler is currently working around this issue in the compiler task.
This will be removed in v1.0.0 in favor of a user supplied .cargo/config
file.

To remove this warning, please create /Users/JRock/projects/blackbelt/deps/mjml/native/mjml_nif/.cargo/config
with the following content:

      [target.x86_64-apple-darwin]
      rustflags = [
          "-C", "link-arg=-undefined",
          "-C", "link-arg=dynamic_lookup",
      ]

See https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/executing_files.html
for more details.

could not compile dependency :mjml, "mix compile" failed. You can recompile this dependency with "mix deps.compile mjml", update it with "mix deps.update mjml" or clean it with "mix deps.clean mjml"
** (ErlangError) Erlang error: :enoent
    (elixir 1.11.2) lib/system.ex:815: System.cmd("cargo", ["rustc", "--release", "--", "-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"], [cd: "/Users/JRock/projects/blackbelt/deps/mjml/native/mjml_nif", stderr_to_stdout: true, env: [{"CARGO_TARGET_DIR", "/Users/JRock/projects/blackbelt/_build/dev/rustler_crates/mjml_nif"}], into: %IO.Stream{device: :standard_io, line_or_bytes: :line, raw: false}])
    (rustler 0.21.1) lib/mix/tasks/compile.rustler.ex:59: Mix.Tasks.Compile.Rustler.compile_crate/1
    (elixir 1.11.2) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
    (rustler 0.21.1) lib/mix/tasks/compile.rustler.ex:15: Mix.Tasks.Compile.Rustler.run/1
    (mix 1.11.2) lib/mix/task.ex:394: Mix.Task.run_task/3
    (mix 1.11.2) lib/mix/tasks/compile.all.ex:90: Mix.Tasks.Compile.All.run_compiler/2
    (mix 1.11.2) lib/mix/tasks/compile.all.ex:70: Mix.Tasks.Compile.All.compile/4
    (mix 1.11.2) lib/mix/tasks/compile.all.ex:57: Mix.Tasks.Compile.All.with_logger_app/2

I attempted to follow those instructions, but you'll see in the cargo compilation line that those two args things are listed. So I believe I've done what was asked from that warning.

Here's my system info:

⋊> ~on main ⨯ system_profiler SPSoftwareDataType                                                                                                                                                                      

Software:

    System Software Overview:

      System Version: macOS 11.1 (20C69)
      Kernel Version: Darwin 20.2.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: Jonathan’s MacBook Pro
      User Name: Jono
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 1 day 2:52
paulgoetze commented 3 years ago

Hey @jonathanstiansen, thanks for reporting.

I think the additional rustflags are a warning, so I figure compiling should not fail because of them?

Nevertheless, could you please check if the changes made in #7 (branch: fix/link-args-on-macos) fix compiling the package for you?

I tried on a machine with the same system setup as yours (macOS 11.1 (20C69), Darwin 20.2.0) with Rust 1.49.0 (e1884a8e3 2020-12-29) and compiling worked for me.

What is your Rust version (rustc --version)?

jonathanstiansen commented 3 years ago

Hehehe this may be the problem, I didn't think about installing rust

jonathanstiansen commented 3 years ago

What version should I install?

paulgoetze commented 3 years ago

What version should I install?

You can't do anything wrong with the latest stable (1.49.0 currently), but earlier versions should also work, I tested yesterday with 1.45.2.

But that's a good point, I'll add installing Rust as a requirement to the Readme.

paulgoetze commented 3 years ago

@jonathanstiansen I added a hint that Rust is required to use the package & released a new version 0.3.0 that fixes the warning. Were you able to install/compile the package? Then I'd close this issue.

jonathanstiansen commented 3 years ago

Totally! Thank you so much!