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

Bump Rustler to 0.34.0 in Cargo.toml (not 0.35.0), IOW, downgrade in mix.exs #69

Merged
merged 9 commits into from
Nov 5, 2024

Conversation

takasehideki
Copy link
Contributor

@takasehideki takasehideki commented Nov 2, 2024

This PR is trying to bump Rustler in Cargo.toml to 0.35.0. Also see #68
Note that this is now working in progress, since we are trying to bump it step by step by referring upgrade guide of Rustler.


As a result, we decided to bump Rustler in Cargo.toml to 0.34.0, not 0.35.0, in this PR.
The bump to 0.35.0, the current latest version, will be made after Zenoh's update to v1.0.0 first (#59), and then continued in #68.

Since we use NIF version to 2.15 (default of Rustler) and does not use `enif_get_type`, the option `default-features = false` is not needed.

See: https://hexdocs.pm/rustler/upgrade.html#0-29-0-30
```
4. The default NIF version is raised to 2.15 to make use of enif_get_type. To use a compiled NIF with an older version than OTP22, disable the default features and expliictly use the nif_version_2_14 feature in the library's Cargo.toml:
```
…ler 0.34.0

See:
https://hexdocs.pm/rustler/upgrade.html#0-33-0-34

```
2. The functionality related to the derive feature is now unconditionally active. The feature flag is kept for compatibility for now but will be removed in the future.
```
@takasehideki takasehideki marked this pull request as draft November 2, 2024 11:14
@takasehideki
Copy link
Contributor Author

I have confirmed that bump to 0.34.0 works fine. However, some warnings have occurred.
I think these should be eliminated.

   Compiling zenohex_nif v0.3.0 (/home/takase/zenoh/zenohex/native/zenohex_nif)
warning: use of deprecated constant `rustler_init::explicit_nif_functions`: Passing NIF functions explicitly is deprecated and this argument is ignored, please remove it
  --> src/lib.rs:59:5
   |
59 | /     [
60 | |         zenoh_open,
61 | |         session::declare_publisher,
62 | |         session::declare_subscriber,
...  |
83 | |         keyexpr::key_expr_intersects,
84 | |     ],
   | |_____^
   |
   = note: `#[warn(deprecated)]` on by default

warning: unused return value of `Result::<T, E>::is_ok` that must be used
  --> src/lib.rs:46:5
   |
46 |     rustler::resource!(SessionRef, env);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: if you intended to assert that this is ok, consider `.unwrap()` instead
   = note: `#[warn(unused_must_use)]` on by default
   = note: this warning originates in the macro `rustler::resource` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused return value of `Result::<T, E>::is_ok` that must be used
  --> src/lib.rs:47:5
   |
47 |     rustler::resource!(PublisherRef, env);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: if you intended to assert that this is ok, consider `.unwrap()` instead
   = note: this warning originates in the macro `rustler::resource` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused return value of `Result::<T, E>::is_ok` that must be used
  --> src/lib.rs:48:5
   |
48 |     rustler::resource!(SubscriberRef, env);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: if you intended to assert that this is ok, consider `.unwrap()` instead
   = note: this warning originates in the macro `rustler::resource` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused return value of `Result::<T, E>::is_ok` that must be used
  --> src/lib.rs:49:5
   |
49 |     rustler::resource!(PullSubscriberRef, env);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: if you intended to assert that this is ok, consider `.unwrap()` instead
   = note: this warning originates in the macro `rustler::resource` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused return value of `Result::<T, E>::is_ok` that must be used
  --> src/lib.rs:50:5
   |
50 |     rustler::resource!(QueryableRef, env);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: if you intended to assert that this is ok, consider `.unwrap()` instead
   = note: this warning originates in the macro `rustler::resource` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused return value of `Result::<T, E>::is_ok` that must be used
  --> src/lib.rs:51:5
   |
51 |     rustler::resource!(ReplyReceiverRef, env);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: if you intended to assert that this is ok, consider `.unwrap()` instead
   = note: this warning originates in the macro `rustler::resource` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused return value of `Result::<T, E>::is_ok` that must be used
  --> src/lib.rs:52:5
   |
52 |     rustler::resource!(QueryRef, env);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: if you intended to assert that this is ok, consider `.unwrap()` instead
   = note: this warning originates in the macro `rustler::resource` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused return value of `Result::<T, E>::is_ok` that must be used
  --> src/lib.rs:53:5
   |
53 |     rustler::resource!(SampleRef, env);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: if you intended to assert that this is ok, consider `.unwrap()` instead
   = note: this warning originates in the macro `rustler::resource` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `zenohex_nif` (lib) generated 9 warnings
    Finished `release` profile [optimized] target(s) in 3m 37s
Generated zenohex app

@takasehideki
Copy link
Contributor Author

I guess the resource registration method may be changed, but cannot find how to upgrade,,,
https://docs.rs/rustler/0.34.0/rustler/macro.resource.html

See: https://hexdocs.pm/rustler/upgrade.html#0-33-0-34

```
1. NIF implementations are now discovered automatically, the respective argument in the rustler::init! macro should be removed. If a NIF implementation should not be exported, it must be disabled with a #[cfg] marker.
```

Compilation log to be removed:

```
warning: use of deprecated constant `rustler_init::explicit_nif_functions`: Passing NIF functions explicitly is deprecated and this argument is ignored, please remove it
  --> src/lib.rs:59:5
   |
59 | /     [
60 | |         zenoh_open,
61 | |         session::declare_publisher,
62 | |         session::declare_subscriber,
...  |
83 | |         keyexpr::key_expr_intersects,
84 | |     ],
   | |_____^
   |
   = note: `#[warn(deprecated)]` on by default
```
@takasehideki
Copy link
Contributor Author

takasehideki commented Nov 4, 2024

With the help of the following various information, I have made modifications to 1b87285.
https://docs.rs/rustler/0.34.0/rustler/macro.resource.html
rusterlium/rustler@rustler-0.33.0...rustler-0.34.0#diff-77f824b36e0d96ba4f3fee0e86ff2edf9981f4c7df85c91ca8565683e2b2ba40
https://github.com/rusterlium/rustler/blob/master/rustler_tests/native/rustler_test/src/test_resource.rs

As a result, I succeeded in removing the compile-time warning message in Rustler 0.34.0.
However, I'm not at all confident that this modification is correct. Also, there exist the following discussion points:


I initially thought L55 in lib.rs should be written as follows.

    env.register::<SessionRef>().is_ok();

However, another warning message appeared.

warning: unused return value of `Result::<T, E>::is_ok` that must be used
  --> src/lib.rs:55:5
   |
55 |     env.register::<SessionRef>().is_ok();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: if you intended to assert that this is ok, consider `.unwrap()` instead
   = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
   |
55 |     let _ = env.register::<SessionRef>().is_ok();
   |     +++++++

By following this, I decided to write using unwrap(). Is it correct??


For now, we use nif_version_2_15.
https://github.com/biyooon-ex/zenohex/pull/69/files#diff-c00d7d7d793ec0cad40fc4996fdfcd165480b7caeb51839bf526104e5ff6e746R15

However, we have already used OTP 26, so I think it is better to use nif_version_2_16 or nif_version_2_17.
https://github.com/rusterlium/rustler?tab=readme-ov-file#supported-nif-version

@takasehideki
Copy link
Contributor Author

takasehideki commented Nov 4, 2024

@s-hosoai @pojiro If you have time, could you give me advice and/or your knowledge??

FYI, I have still encountered another issues compiling with Rustler 0.35.0,,,

@pojiro
Copy link
Contributor

pojiro commented Nov 4, 2024

@takasehideki

I initially thought L55 in lib.rs should be written as follows.

You are right. You need to use them like followings,

fn load(env: Env, _term: Term) -> bool {
    env.register::<SessionRef>().is_ok()
        && env.register::<PublisherRef>().is_ok()
        && env.register::<SubscriberRef>().is_ok()
        && env.register::<PullSubscriberRef>().is_ok()
        && env.register::<QueryableRef>().is_ok()
        && env.register::<ReplyReceiverRef>().is_ok()
        && env.register::<QueryRef>().is_ok()
        && env.register::<SampleRef>().is_ok()
}

is_ok() returns boolean, it means register works fine.

ref. https://github.com/rusterlium/rustler/blob/rustler-0.35.0/rustler/src/resource/registration.rs#L129-L155

@takasehideki
Copy link
Contributor Author

About NIF version, we concluded that using 2.15 is reasonable because this is the default version for Rustler we don't have aggressive reasons to use newer features of NIF and OTP.
To make a note about this, I added 5c0e197 and made #71.

@takasehideki
Copy link
Contributor Author

@pojiro Thank you so much for your awesome comment!!
I modified code according to your suggestion.
23eb6aa

@takasehideki takasehideki changed the title [WIP] Bump Rustler to 0.35.0 while resolving issues Bump Rustler to 0.34.0 (not 0.35.0) Nov 4, 2024
@takasehideki takasehideki marked this pull request as ready for review November 4, 2024 13:31
@takasehideki takasehideki requested a review from s-hosoai November 4, 2024 13:31
@takasehideki
Copy link
Contributor Author

I'd like to conclude that bumping Rustler to 0.35.0 is not cost-effective and difficult at this time, and that a response to 0.34.0 is sufficient for this PR (now).

Bumping Rustler to 0.35.0 caused many inexplicable compile errors. I guess that these are probably due to that the transition from async-std to Tokio was not yet complete in Zenoh 0.11.0. I have experimentally tried Zenoh 1.0.0 along with Rustler 0.35.0; most of the errors seemed not appear at that time (although many other compile errors happened, so we will have to work on resolving them).

IOW, please review @s-hosoai if this PR is acceptable or not 🙏
If you agree on this, I will merge it and release Zenohex 0.3.1.

Copy link
Collaborator

@s-hosoai s-hosoai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@takasehideki Thank you for the PR. The modifications you made are fine.
Additionally, please update the Rustler version in mix.exs. If this PR is upgrading to v0.3.1, please adjust the version accordingly.

@takasehideki
Copy link
Contributor Author

takasehideki commented Nov 4, 2024

@s-hosoai sorry I can’t catch up what you want me to do,,,

Rustler in mix.lock has already bumped to 0.3.5 by dependabot. You mean this should adjust to 0.3.4? I agree with your this suggestion and will treat it.

"rustler": {:hex, :rustler, "0.35.0", "1e2e379e1150fab9982454973c74ac9899bd0377b3882166ee04127ea613b2d9", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "a176bea1bb6711474f9dfad282066f2b7392e246459bf4e29dfff6d828779fdf"},

#61

Or you mean Zenohex should bump to 0.3.1 in this PR too? I don’t think so, The bump to this library itself should be treated in the separate PR like the below.
#52

@takasehideki
Copy link
Contributor Author

takasehideki commented Nov 5, 2024

Rustler in mix.lock has already bumped to 0.3.5 by dependabot. You mean this should adjust to 0.3.4? I agree with your this suggestion and will treat it.

I got it in e288e6c d64faa0 (force-pushed because I forgot to specify to rustler in Cargo.toml).

@s-hosoai could you review again??

@takasehideki takasehideki changed the title Bump Rustler to 0.34.0 (not 0.35.0) Bump Rustler to 0.34.0 in Cargo.toml (not 0.35.0), IOW, downgrade in mix.exs Nov 5, 2024
@s-hosoai s-hosoai self-requested a review November 5, 2024 01:59
Copy link
Collaborator

@s-hosoai s-hosoai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention was to lock the version to 0.34. Your fix is perfect!
I also agree with handling the Zenohex version upgrade in a separate PR.

@takasehideki
Copy link
Contributor Author

go merging! I will create another PR to release Zenohex 0.3.1.

@takasehideki takasehideki merged commit 66d8856 into main Nov 5, 2024
4 checks passed
@takasehideki takasehideki deleted the cargo_rustler_bump branch November 5, 2024 03:04
takasehideki added a commit that referenced this pull request Nov 5, 2024
This version is compatible [with Zenoh 0.11.0](https://github.com/eclipse-zenoh/zenoh/releases/tag/0.11.0)

* Add cargo of NIF module to dependabot target by @takasehideki in #62
* Bump Rustler to 0.34.0 in Cargo.toml (not 0.35.0), IOW, downgrade in mix.exs by @takasehideki in #69

* Bump credo from 1.7.7 to 1.7.8 by @dependabot in #63
* Bump dialyxir from 1.4.3 to 1.4.4 by @dependabot in #65
* Bump futures from 0.3.30 to 0.3.31 in /native/zenohex_nif by @dependabot in #64
* Bump rustler_precompiled from 0.7.1 to 0.8.2 by @dependabot in #60
* Bump ex_doc from 0.34.1 to 0.34.2 by @dependabot in #55
* Bump flume from 0.11.0 to 0.11.1 in /native/zenohex_nif by @dependabot in #66
* Bump credo from 1.7.8 to 1.7.10 by @dependabot in #72

**Full Changelog**: v0.3.0...v0.3.1
@takasehideki takasehideki mentioned this pull request Nov 5, 2024
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 this pull request may close these issues.

3 participants