From: Ezekiel Newren Date: Fri, 19 Sep 2025 20:25:48 GMT Subject: Re: [PATCH v2 13/18] build-helper: link against libgit.a and any other required C libraries Message-ID: In-Reply-To: On Wed, Sep 17, 2025 at 2:51 AM Eric Sunshine wrote: > > On Tue, Sep 16, 2025 at 9:18 PM Ezekiel Newren via GitGitGadget > wrote: > > build-helper: link against libgit.a and any other required C libraries > > > > Don't link against the C libraries when building with Make or Meson. > > Run cargo tests like this: > > cd rust && cargo clean && USE_LINKING=true cargo test > > > > Signed-off-by: Ezekiel Newren > > --- > > Perhaps it's because I haven't been following the discussion closely > enough, but the above commit message leaves me entirely in the dark. > After reading and rereading it several times, I suppose it is trying > to address some difference between building with `cargo` vs. building > with Make or Meson, but it gives no explanation of what the > differences are or what problem it is trying to solve. So, please > enhance the commit message to begin with the "why" and then proceed to > the "what" or "how". As I partially explained in previous comments about my commits. I was trying to get the Rust compiler to link against libgit.a so that any Rust code that references C code in Git would work in Rust unit tests. The way that Cargo invokes rustc and links to libraries can be controlled through build.rs. To use an example; When build.rs prints the following lines to stdout: cargo:rustc-link-search=native=/path/to/git/build/dir cargo:rustc-link-lib=static=git The first line tells cargo to tell the Rust compiler to look in '/path/to/git/build/dir' for objects. The second line tells Cargo to tell the Rust compiler to link against libgit.a. Telling Rust how to link against libgit.a is only needed for Rust unit tests that reference Git defined C code. I'll drop build-helper for this series, since it only helps with linking against libgit.a for Rust unit tests.