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

Rust bindings fail to build with stable (rustc 1.71.0) #4984

Closed
skull-squadron opened this issue Aug 2, 2023 · 6 comments
Closed

Rust bindings fail to build with stable (rustc 1.71.0) #4984

skull-squadron opened this issue Aug 2, 2023 · 6 comments
Labels

Comments

@skull-squadron
Copy link

Output
error[E0425]: cannot find value `KEY_CP_NAME` in crate `elektra_sys`
  --> elektra/src/key.rs:58:42
   |
58 |         const KEY_CP_NAME = elektra_sys::KEY_CP_NAME as elektra_sys::elektraCopyFlags;
   |                                          ^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_CP_STRING` in crate `elektra_sys`
  --> elektra/src/key.rs:60:44
   |
60 |         const KEY_CP_STRING = elektra_sys::KEY_CP_STRING as elektra_sys::elektraCopyFlags;
   |                                            ^^^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_CP_VALUE` in crate `elektra_sys`
  --> elektra/src/key.rs:62:43
   |
62 |         const KEY_CP_VALUE = elektra_sys::KEY_CP_VALUE as elektra_sys::elektraCopyFlags;
   |                                           ^^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_CP_META` in crate `elektra_sys`
  --> elektra/src/key.rs:64:42
   |
64 |         const KEY_CP_META = elektra_sys::KEY_CP_META as elektra_sys::elektraCopyFlags;
   |                                          ^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_NS_SPEC` in crate `elektra_sys`
  --> elektra/src/readable.rs:72:42
   |
72 |         self.namespace() == elektra_sys::KEY_NS_SPEC
   |                                          ^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_NS_DIR` in crate `elektra_sys`
  --> elektra/src/readable.rs:77:42
   |
77 |         self.namespace() == elektra_sys::KEY_NS_DIR
   |                                          ^^^^^^^^^^ help: a constant with a similar name exists: `KEY_NS_FIRST`
   |
  ::: /tmp/libelektra/build/src/bindings/rust/target/release/build/elektra-sys-b82dff8e72fe2f0c/out/bindings.rs:21:1
   |
21 | pub const KEY_NS_FIRST: elektraNamespace = 2;
   | ---------------------------------------- similarly named constant `KEY_NS_FIRST` defined here

error[E0425]: cannot find value `KEY_NS_PROC` in crate `elektra_sys`
  --> elektra/src/readable.rs:82:42
   |
82 |         self.namespace() == elektra_sys::KEY_NS_PROC
   |                                          ^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_NS_USER` in crate `elektra_sys`
  --> elektra/src/readable.rs:87:42
   |
87 |         self.namespace() == elektra_sys::KEY_NS_USER
   |                                          ^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_NS_SYSTEM` in crate `elektra_sys`
  --> elektra/src/readable.rs:92:42
   |
92 |         self.namespace() == elektra_sys::KEY_NS_SYSTEM
   |                                          ^^^^^^^^^^^^^ help: a constant with a similar name exists: `KEY_NS_LAST`
   |
  ::: /tmp/libelektra/build/src/bindings/rust/target/release/build/elektra-sys-b82dff8e72fe2f0c/out/bindings.rs:22:1
   |
22 | pub const KEY_NS_LAST: elektraNamespace = 8;
   | --------------------------------------- similarly named constant `KEY_NS_LAST` defined here

error[E0425]: cannot find value `KEY_NS_CASCADING` in crate `elektra_sys`
  --> elektra/src/readable.rs:97:42
   |
97 |         self.namespace() == elektra_sys::KEY_NS_CASCADING
   |                                          ^^^^^^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KDB_O_NONE` in crate `elektra_sys`
  --> elektra/src/keyset.rs:74:41
   |
74 |         const KDB_O_NONE = elektra_sys::KDB_O_NONE as elektra_sys::elektraLookupFlags;
   |                                         ^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KDB_O_POP` in crate `elektra_sys`
  --> elektra/src/keyset.rs:76:40
   |
76 |         const KDB_O_POP = elektra_sys::KDB_O_POP as elektra_sys::elektraLookupFlags;
   |                                        ^^^^^^^^^ not found in `elektra_sys`

error[E0308]: mismatched types
   --> elektra/src/key.rs:221:21
    |
218 |                 elektra_sys::keySetBinary(
    |                 ------------------------- arguments to this function are incorrect
...
221 |                     data.len(),
    |                     ^^^^^^^^^^ expected `u64`, found `usize`
    |
note: function defined here
   --> /tmp/libelektra/build/src/bindings/rust/target/release/build/elektra-sys-b82dff8e72fe2f0c/out/bindings.rs:211:12
    |
211 |     pub fn keySetBinary(
    |            ^^^^^^^^^^^^
help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit
    |
221 |                     data.len().try_into().unwrap(),
    |                               ++++++++++++++++++++

error[E0308]: mismatched types
   --> elektra/src/key.rs:235:17
    |
232 |             elektra_sys::keyGetBinary(
    |             ------------------------- arguments to this function are incorrect
...
235 |                 vec.capacity(),
    |                 ^^^^^^^^^^^^^^ expected `u64`, found `usize`
    |
note: function defined here
   --> /tmp/libelektra/build/src/bindings/rust/target/release/build/elektra-sys-b82dff8e72fe2f0c/out/bindings.rs:204:12
    |
204 |     pub fn keyGetBinary(
    |            ^^^^^^^^^^^^
help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit
    |
235 |                 vec.capacity().try_into().unwrap(),
    |                               ++++++++++++++++++++

error[E0308]: mismatched types
  --> elektra/src/readable.rs:43:18
   |
42 |     fn basename_size(&self) -> isize {
   |                                ----- expected `isize` because of return type
43 |         unsafe { elektra_sys::keyGetBaseNameSize(self.as_ref()) }
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `i64`
   |
help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit
   |
43 |         unsafe { elektra_sys::keyGetBaseNameSize(self.as_ref()).try_into().unwrap() }
   |                                                                ++++++++++++++++++++

error[E0308]: mismatched types
   --> elektra/src/keyset.rs:177:50
    |
177 |         let ks_ptr = unsafe { elektra_sys::ksNew(capacity, elektra_sys::KS_END) };
    |                               ------------------ ^^^^^^^^ expected `u64`, found `usize`
    |                               |
    |                               arguments to this function are incorrect
    |
note: function defined here
   --> /tmp/libelektra/build/src/bindings/rust/target/release/build/elektra-sys-b82dff8e72fe2f0c/out/bindings.rs:226:12
    |
226 |     pub fn ksNew(alloc: size_t, ...) -> *mut KeySet;
    |            ^^^^^
help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit
    |
177 |         let ks_ptr = unsafe { elektra_sys::ksNew(capacity.try_into().unwrap(), elektra_sys::KS_END) };
    |                                                          ++++++++++++++++++++

error[E0308]: mismatched types
   --> elektra/src/keyset.rs:194:18
    |
193 |     pub fn append(&mut self, to_append: &KeySet) -> isize {
    |                                                     ----- expected `isize` because of return type
194 |         unsafe { elektra_sys::ksAppend(self.as_ptr(), to_append.as_ref()) }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `i64`
    |
help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit
    |
194 |         unsafe { elektra_sys::ksAppend(self.as_ptr(), to_append.as_ref()).try_into().unwrap() }
    |                                                                          ++++++++++++++++++++

Some errors have detailed explanations: E0308, E0425.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `elektra` (lib) due to 17 previous errors
Note: /tmp/libelektra/build/src/bindings/jna/process/src/main/java/org/libelektra/process/PluginProcess.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
  1. The bindgen-generated bindings.rs in the electra-sys crate is indeed missing these symbols, and so the electra crate fails to build.
  2. Integer types need to be updated to use ssize_t/size_t defined by bindgen rather than rust types isize/usize, or it's always going to be fragile.
@markus2330
Copy link
Contributor

markus2330 commented Aug 3, 2023

@steakknife thx for reporting this problem!

Which bindgen version did you use? We recently upgraded in #4983.

We also published a very recent version (which is more or less identical to 0.11.0) but we called it "version 0.10.0". Is this the version you used?

@markus2330
Copy link
Contributor

Will be hopefully fixed after the release.

@atmaxinger did you try with rustc 1.71.0?

@atmaxinger
Copy link
Contributor

No, I really don't have any expertise with rust.

@skull-squadron
Copy link
Author

skull-squadron commented Aug 4, 2023 via email

Copy link

github-actions bot commented Aug 4, 2024

I mark this stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping by writing a message here or create a new issue with the remainder of this issue.
Thank you for your contributions 💖

@github-actions github-actions bot added the stale label Aug 4, 2024
Copy link

I closed this now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue.
Thank you for your contributions 💖

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants