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

feat: add bindings for riscv64gc-unknown-linux-gnu target #212

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NeilHanlon
Copy link

This change adds riscv64gc-unknown-linux-gnu bindings for cryptoki-sys
crate and adds the target to ci.sh and regenerate_bindings.sh for future
updates. This change will enable building the package for risvc in
Fedora.

n.b., in order to build locally I disabled the unused_qualifications lint due to the following:

error: unnecessary qualification
   --> cryptoki/src/mechanism/mod.rs:979:33
    |
979 |                 ulParameterLen: std::mem::size_of::<CK_GCM_PARAMS>()
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: the lint level is defined here
   --> cryptoki/src/lib.rs:51:8
    |
51  |        unused_qualifications,
    |        ^^^^^^^^^^^^^^^^^^^^^
help: remove the unnecessary path segments
    |
979 -                 ulParameterLen: std::mem::size_of::<CK_GCM_PARAMS>()
979 +                 ulParameterLen: size_of::<CK_GCM_PARAMS>()
    |

error: unnecessary qualification
    --> cryptoki/src/mechanism/mod.rs:1042:25
     |
1042 |         ulParameterLen: std::mem::size_of::<T>()
     |                         ^^^^^^^^^^^^^^^^^^^^^^
     |
help: remove the unnecessary path segments
     |
1042 -         ulParameterLen: std::mem::size_of::<T>()
1042 +         ulParameterLen: size_of::<T>()
     |

error: unnecessary qualification
   --> cryptoki/src/object.rs:620:48
    |
620 |             | Attribute::WrapWithTrusted(_) => std::mem::size_of::<bool>(),
    |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
620 -             | Attribute::WrapWithTrusted(_) => std::mem::size_of::<bool>(),
620 +             | Attribute::WrapWithTrusted(_) => size_of::<bool>(),
    |

error: unnecessary qualification
   --> cryptoki/src/object.rs:623:17
    |
623 |                 std::mem::size_of::<CK_UTF8CHAR>() * bytes.len()
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
623 -                 std::mem::size_of::<CK_UTF8CHAR>() * bytes.len()
623 +                 size_of::<CK_UTF8CHAR>() * bytes.len()
    |

error: unnecessary qualification
   --> cryptoki/src/object.rs:627:46
    |
627 |             Attribute::CertificateType(_) => std::mem::size_of::<CK_CERTIFICATE_TYPE>(),
    |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
627 -             Attribute::CertificateType(_) => std::mem::size_of::<CK_CERTIFICATE_TYPE>(),
627 +             Attribute::CertificateType(_) => size_of::<CK_CERTIFICATE_TYPE>(),
    |

error: unnecessary qualification
   --> cryptoki/src/object.rs:629:36
    |
629 |             Attribute::Class(_) => std::mem::size_of::<CK_OBJECT_CLASS>(),
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
629 -             Attribute::Class(_) => std::mem::size_of::<CK_OBJECT_CLASS>(),
629 +             Attribute::Class(_) => size_of::<CK_OBJECT_CLASS>(),
    |

error: unnecessary qualification
   --> cryptoki/src/object.rs:639:46
    |
639 |             Attribute::KeyGenMechanism(_) => std::mem::size_of::<CK_MECHANISM_TYPE>(),
    |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
639 -             Attribute::KeyGenMechanism(_) => std::mem::size_of::<CK_MECHANISM_TYPE>(),
639 +             Attribute::KeyGenMechanism(_) => size_of::<CK_MECHANISM_TYPE>(),
    |

error: unnecessary qualification
   --> cryptoki/src/object.rs:640:38
    |
640 |             Attribute::KeyType(_) => std::mem::size_of::<CK_KEY_TYPE>(),
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
640 -             Attribute::KeyType(_) => std::mem::size_of::<CK_KEY_TYPE>(),
640 +             Attribute::KeyType(_) => size_of::<CK_KEY_TYPE>(),
    |

error: unnecessary qualification
   --> cryptoki/src/object.rs:642:42
    |
642 |             Attribute::ModulusBits(_) => std::mem::size_of::<CK_ULONG>(),
    |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
642 -             Attribute::ModulusBits(_) => std::mem::size_of::<CK_ULONG>(),
642 +             Attribute::ModulusBits(_) => size_of::<CK_ULONG>(),
    |

error: unnecessary qualification
   --> cryptoki/src/object.rs:654:39
    |
654 |             Attribute::ValueLen(_) => std::mem::size_of::<CK_ULONG>(),
    |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
654 -             Attribute::ValueLen(_) => std::mem::size_of::<CK_ULONG>(),
654 +             Attribute::ValueLen(_) => size_of::<CK_ULONG>(),
    |

error: unnecessary qualification
   --> cryptoki/src/object.rs:655:64
    |
655 |             Attribute::EndDate(_) | Attribute::StartDate(_) => std::mem::size_of::<CK_DATE>(),
    |                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
655 -             Attribute::EndDate(_) | Attribute::StartDate(_) => std::mem::size_of::<CK_DATE>(),
655 +             Attribute::EndDate(_) | Attribute::StartDate(_) => size_of::<CK_DATE>(),
    |

error: unnecessary qualification
   --> cryptoki/src/object.rs:658:17
    |
658 |                 std::mem::size_of::<CK_MECHANISM_TYPE>() * mechanisms.len()
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
658 -                 std::mem::size_of::<CK_MECHANISM_TYPE>() * mechanisms.len()
658 +                 size_of::<CK_MECHANISM_TYPE>() * mechanisms.len()
    |

error: unnecessary qualification
   --> cryptoki/src/object.rs:770:24
    |
770 |     let as_array: [u8; std::mem::size_of::<CK_BBOOL>()] = slice.try_into()?;
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: remove the unnecessary path segments
    |
770 -     let as_array: [u8; std::mem::size_of::<CK_BBOOL>()] = slice.try_into()?;
770 +     let as_array: [u8; size_of::<CK_BBOOL>()] = slice.try_into()?;
    |

error: could not compile `cryptoki` (lib) due to 13 previous errors

If this change is not preferred or required, I can drop the hunk from the PR.

@wiktor-k
Copy link
Collaborator

I think this looks good. The lint you had to disabled should be accounted for in main so if you could rebase we'd proceed with this one.

Sorry for the delay - I guess it's holiday season 😅

@ionut-arm
Copy link
Member

I'm happy with the patch, but as @wiktor-k says, would be good to rebase and re-enable the lint. Apologies for the long delay 🥲

This change adds riscv64gc-unknown-linux-gnu bindings for cryptoki-sys
crate and adds the target to ci.sh and regenerate_bindings.sh for future
updates. This change will enable building the package for risvc in
Fedora.

Signed-off-by: Neil Hanlon <[email protected]>
@NeilHanlon
Copy link
Author

All set. Sorry for the delay, and thank you!

@hug-dev
Copy link
Member

hug-dev commented Sep 13, 2024

I am wondering if you are missing adding the target in the GitHub workflow files (in .github). Compare with PRs doing similar changes for example #166 and #190. The CI might pass after that?

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.

4 participants