lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNAT4zKWn6+scn5wbaN2_x4wh4EYSuNxnaoQK1FfJK45MOw@mail.gmail.com>
Date:   Mon, 13 Nov 2023 23:13:18 +0900
From:   Masahiro Yamada <masahiroy@...nel.org>
To:     Martin Rodriguez Reboredo <yakoyoku@...il.com>
Cc:     Miguel Ojeda <ojeda@...nel.org>,
        Alex Gaynor <alex.gaynor@...il.com>,
        Wedson Almeida Filho <wedsonaf@...il.com>,
        Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
        Björn Roy Baron <bjorn3_gh@...tonmail.com>,
        Benno Lossin <benno.lossin@...ton.me>,
        Andreas Hindborg <a.hindborg@...sung.com>,
        Alice Ryhl <aliceryhl@...gle.com>,
        linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
        rust-for-linux@...r.kernel.org
Subject: Re: [RFC PATCH v3 0/2] rust: crates in other kernel directories

On Sun, Nov 5, 2023 at 6:12 AM Martin Rodriguez Reboredo
<yakoyoku@...il.com> wrote:
>
> This RFC provides makes possible to have bindings for kernel subsystems
> that are compiled as modules.
>
> Previously, if you wanted to have Rust bindings for a subsystem, like
> AMBA for example, you had to put it under `rust/kernel/` so it came
> part of the `kernel` crate, but this came with many downsides. Namely
> if you compiled said subsystem as a module you've a dependency on it
> from `kernel`, which is linked directly on `vmlinux`.
>
> So instead of overpopulating `kernel` with a gazillion modules that
> throws you into dire straits you should rather have the bindings in the
> same directory as the subsystem you want to bind with and link it to
> it.
>
> With this patch Rust sources can be compiled into libraries for them to
> be consumed. These libraries are ar archives that follow the `.rlib`
> structure, namely a libfoo.rlib thin archive with a foo.foo.o object
> and a libfoo.rmeta rustc metadata as members. Such Rust crates get
> their symbols exposed and the `bindings` crate is made available for
> them.
>
> Also included there's a sample usage of this in another patch, but it
> is not meant to be merged as it remains as an example.
>
> If you want to use a crate with your Rust module just add a `rust-libs`
> variable in your Makefile with a value of the relative directory of
> said crate plus its name, e.g.
>
>     # Link with the foo crate
>     rust-libs += ../path/to/foo




I will not provide a line-by-line review.


Just one thing I'd like to point out.

You assume the library (drivers/usb/core/*)
is built before its consumers (samples/rust/*).

If Kbuild ends up with building lib consumers first,
it will be a build error.



Kbuild descends into multiple directories in parallel building.

You cannot predict which directory is built first.








> Martin Rodriguez Reboredo (2):
>   kbuild: Build Rust crates as libraries
>   samples: rust: Add USB sample bindings
>
>  .gitignore                      |  2 ++
>  Makefile                        |  4 ++--
>  drivers/usb/core/Kconfig        |  7 ++++++
>  drivers/usb/core/Makefile       |  3 +++
>  drivers/usb/core/usb.rs         | 13 ++++++++++
>  rust/bindings/bindings_helper.h |  1 +
>  samples/rust/Kconfig            | 10 ++++++++
>  samples/rust/Makefile           |  3 +++
>  samples/rust/rust_usb_simple.rs | 22 +++++++++++++++++
>  scripts/Makefile.build          | 42 ++++++++++++++++++++++++++++++---
>  scripts/Makefile.lib            | 20 ++++++++++++----
>  scripts/Makefile.modfinal       |  9 +++++--
>  12 files changed, 125 insertions(+), 11 deletions(-)
>  create mode 100644 drivers/usb/core/usb.rs
>  create mode 100644 samples/rust/rust_usb_simple.rs
>
> --
> 2.42.1
>


-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ