Thread (138 messages) 138 messages, 11 authors, 2025-01-30

RE: [RFC PATCH 3/6] contrib/cgit-rs: introduce Rust wrapper for libgit.a

From: <hidden>
Date: 2024-08-12 02:00:23

On Wednesday, August 7, 2024 7:08 PM, Josh Steadmon wrote:
On 2024.08.07 17:40, rsbecker@nexbridge.com wrote:
quoted
On Wednesday, August 7, 2024 5:21 PM, brian m. carlson wrote:
quoted
On 2024-08-07 at 18:21:28, Josh Steadmon wrote:
quoted
Introduce cgit-rs, a Rust wrapper crate that allows Rust code to
call functions in libgit.a. This initial patch defines build rules
and an interface that exposes user agent string getter functions as
a proof of concept. A proof-of-concept library consumer is provided
in contrib/cgit-rs/src/main.rs. This executable can be run with
`cargo run`

Symbols in cgit can collide with symbols from other libraries such
as libgit2. We avoid this by first exposing library symbols in
public_symbol_export.[ch]. These symbols are prepended with "libgit_"
to avoid collisions and set to visible using a visibility pragma.
In build.rs, Rust builds contrib/cgit-rs/libcgit.a, which also
contains libgit.a and other dependent libraries, with
-fvisibility=hidden to hide all symbols within those libraries that
haven't been exposed with a visibility pragma.
I think this is a good idea.  It's optional and it allows us to add
functionality as we go along.  Platforms that don't have Rust can just
omit
building it.
quoted
quoted
quoted
+[dependencies]
+libc = "0.2.155"
I don't love that we're using libc here.  It would be better to use
rustix because that provides safe APIs that are compatible with
POSIX, but I think for now we need this because rustix doesn't offer
memory management like free(3).  I'd really prefer that we didn't
have to do memory management in Rust, but maybe that can come in with a
future series.
quoted
This is a good point. Libc is not portable, but because I can't build
with RUST anyway, I hope that libc is restricted to this facility if
used. It should not be included in the git C build. It is probably
moot for me anyway for this series, but I have to mention it in case
anyone else
gets the idea to include it as a dependency for git C.

I know you don't have access to Rust, but would you be able to test the
symbol
visibility steps with `make contrib/cgit-rs/libcgit.a`?
This target is no longer valid. Is there another target I can try?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help