rust-random / getrandom

A small cross-platform library for retrieving random data from (operating) system source
Apache License 2.0
291 stars 182 forks source link

Add support for targeting the macOS (Darwin/XNU) kernel #500

Closed VisualEhrmanntraut closed 1 month ago

VisualEhrmanntraut commented 1 month ago

Currently if the target OS is macOS, it assumes that you are building an application and not a kernel extension. This causes getrandom to try using libc, which is obviously not available in the kernel.

VisualEhrmanntraut commented 1 month ago
Screenshot 2024-09-23 at 23 40 50

"os": "none" can't be used, because it won't know what OS to put in the Mach-O archives/executable, as seen below.

Screenshot 2024-09-23 at 23 41 07
newpavlov commented 1 month ago

Is writing kernel extensions for macOS officially supported by Rust? I don't think the existing targets are intended for that. If you writing some highly experimental code, then I think your best option probably will be to patch getrandom with a custom version.

VisualEhrmanntraut commented 1 month ago

No it's not an officially supported Rust target; I've created it myself and slowly making bindings. I'll think tomorrow of a different way to do it and let you know.

VisualEhrmanntraut commented 1 month ago

I'll just close it since it's just the other issue you mentioned in the PR