mjaric / tds-encoding

String encoding/decoding NIF using rust encoding crate
MIT License
2 stars 3 forks source link

Update rustler to v0.22.0-rc.1 #1

Closed deepankar-j closed 2 years ago

deepankar-j commented 3 years ago

This change updates rustler to v0.22.0-rc.1, which enables OTP 24 support. Without this change, :tds_encoding cannot compile on OTP 24.

deepankar-j commented 3 years ago

@mjaric: I don't know whether referencing an rc version of Rustler is acceptable. However, this was the only way to pickup this Rustler fix.

https://github.com/rusterlium/rustler/issues/359

If this PR is acceptable, could you please create a new Hex release of :tds_encoding?

deepankar-j commented 3 years ago

I should mention that after this upgrade, compiling :tds_encoding as a dependency, on OTP 24 + Elixir v1.12, results in the following warnings.

mix deps.compile tds_encoding                                                                                                  

The `:rustler` compiler has been deprecated since v0.22.0 and will be
removed in v1.0.

To remove this warning, please consult the CHANGELOG for v0.22.0.

==> tds_encoding
Compiling 1 file (.ex)
Compiling crate tds_encoding in release mode (native/tds_encoding)
   Compiling encoding_index_tests v0.1.4
   Compiling proc-macro2 v1.0.27
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.72
   Compiling rustler_sys v2.1.1
   Compiling void v1.0.2
   Compiling unicode-segmentation v1.7.1
   Compiling rustler v0.22.0-rc.1
   Compiling lazy_static v1.4.0
   Compiling encoding-index-tradchinese v1.20141219.5
   Compiling encoding-index-korean v1.20141219.5
   Compiling encoding-index-singlebyte v1.20141219.5
   Compiling encoding-index-japanese v1.20141219.5
   Compiling encoding-index-simpchinese v1.20141219.5
   Compiling unreachable v1.0.0
   Compiling heck v0.3.2
   Compiling encoding v0.2.33
   Compiling quote v1.0.9
Compiling lib/tds_encoding.ex (it's taking more than 10s)
   Compiling rustler_codegen v0.22.0-rc.1
   Compiling tds_encoding v0.1.0 (/Users/dj.jain/git/hapi/deps/tds_encoding/native/tds_encoding)
warning: use of deprecated macro `rustler_atoms`: Please use `atoms!` instead.
  --> src/lib.rs:21:5
   |
21 |     rustler_atoms! {
   |     ^^^^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default

warning: use of deprecated macro `::rustler::rustler_atoms`: Please use `atoms!` instead.
  --> src/lib.rs:21:5
   |
21 | /     rustler_atoms! {
22 | |         atom ok;
23 | |         atom error;
24 | |         atom unknown_encoding;
25 | |         //atom __true__ = "true";
26 | |         //atom __false__ = "false";
27 | |     }
   | |_____^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated macro `::rustler::rustler_atoms`: Please use `atoms!` instead.
  --> src/lib.rs:21:5
   |
21 | /     rustler_atoms! {
22 | |         atom ok;
23 | |         atom error;
24 | |         atom unknown_encoding;
25 | |         //atom __true__ = "true";
26 | |         //atom __false__ = "false";
27 | |     }
   | |_____^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated macro `::rustler::rustler_atoms`: Please use `atoms!` instead.
  --> src/lib.rs:21:5
   |
21 | /     rustler_atoms! {
22 | |         atom ok;
23 | |         atom error;
24 | |         atom unknown_encoding;
25 | |         //atom __true__ = "true";
26 | |         //atom __false__ = "false";
27 | |     }
   | |_____^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated macro `::rustler::rustler_atoms`: Please use `atoms!` instead.
  --> src/lib.rs:21:5
   |
21 | /     rustler_atoms! {
22 | |         atom ok;
23 | |         atom error;
24 | |         atom unknown_encoding;
25 | |         //atom __true__ = "true";
26 | |         //atom __false__ = "false";
27 | |     }
   | |_____^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated macro `rustler_export_nifs`: Please use `rustler::init!` instead.
  --> src/lib.rs:30:1
   |
30 | rustler_export_nifs! {
   | ^^^^^^^^^^^^^^^^^^^

warning: use of deprecated macro `::rustler::rustler_export_nifs`: Please use `rustler::init!` instead.
  --> src/lib.rs:30:1
   |
30 | / rustler_export_nifs! {
31 | |     "Elixir.Tds.Encoding",
32 | |     [
33 | |         ("encode", 2, encode),
...  |
36 | |     None
37 | | }
   | |_^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated macro `::rustler::rustler_export_nifs`: Please use `rustler::init!` instead.
  --> src/lib.rs:30:1
   |
30 | / rustler_export_nifs! {
31 | |     "Elixir.Tds.Encoding",
32 | |     [
33 | |         ("encode", 2, encode),
...  |
36 | |     None
37 | | }
   | |_^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated macro `::rustler::rustler_export_nifs`: Please use `rustler::init!` instead.
  --> src/lib.rs:30:1
   |
30 | / rustler_export_nifs! {
31 | |     "Elixir.Tds.Encoding",
32 | |     [
33 | |         ("encode", 2, encode),
...  |
36 | |     None
37 | | }
   | |_^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated macro `::rustler::rustler_export_nifs`: Please use `rustler::init!` instead.
  --> src/lib.rs:30:1
   |
30 | / rustler_export_nifs! {
31 | |     "Elixir.Tds.Encoding",
32 | |     [
33 | |         ("encode", 2, encode),
...  |
36 | |     None
37 | | }
   | |_^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated macro `::rustler::rustler_export_nifs`: Please use `rustler::init!` instead.
  --> src/lib.rs:30:1
   |
30 | / rustler_export_nifs! {
31 | |     "Elixir.Tds.Encoding",
32 | |     [
33 | |         ("encode", 2, encode),
...  |
36 | |     None
37 | | }
   | |_^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: use of deprecated macro `::rustler::rustler_export_nifs`: Please use `rustler::init!` instead.
  --> src/lib.rs:30:1
   |
30 | / rustler_export_nifs! {
31 | |     "Elixir.Tds.Encoding",
32 | |     [
33 | |         ("encode", 2, encode),
...  |
36 | |     None
37 | | }
   | |_^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: 12 warnings emitted

    Finished release [optimized] target(s) in 18.03s
Generated tds_encoding app

16:29:53.843 [warn]  The on_load function for module Elixir.Tds.Encoding returned:
{:error,
 {:load_failed,
  'Failed to load NIF library: \'dlopen(/Users/dj.jain/git/hapi/_build/dev/lib/tds_encoding/priv/native/libtds_encoding.so, 2): image not found\''}}
deepankar-j commented 3 years ago

The warning, which really should be an error results in :tds_encoding not working at runtime. Re-running mix deps.compile tds_encoding results in a functional system.

The problem is that on the first compile, the _build/dev/lib/tds_encoding/priv symbolic link to deps/tds_encoding/priv, isn't created.

It seems like an event sequence problem. I'm not really sure what the appropriate fix is. However, at least the workaround of double compiling addresses the problem for now.

16:29:53.843 [warn]  The on_load function for module Elixir.Tds.Encoding returned:
{:error,
 {:load_failed,
  'Failed to load NIF library: \'dlopen(/Users/dj.jain/git/hapi/_build/dev/lib/tds_encoding/priv/native/libtds_encoding.so, 2): image not found\''}}
jeroenvisser101 commented 3 years ago

@deepankar-j not sure if it's the same issue, but I had something similar when doing the upgrade for meeseeks_html5ever, which might be related to https://github.com/rusterlium/rustler/issues/326. You can see what I did in this PR: https://github.com/mischov/meeseeks_html5ever/pull/37.

Hope it helps!

ericlathrop commented 3 years ago

Rustler 0.22.0 is out now.

moogle19 commented 2 years ago

@deepankar-j I updated tds_encoding to use rustler 0.22. As soon as I get access to hex.pm from @mjaric I will release a new version!