rust-lang / rust-lang/git2-rs

Build problems with installed libgit2 1.8.0

Open
#1,041 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.1k
Forks
450
Avg merge
11m
Merged PRs (30d)
1

Description

This is not the first time similar problems are happening, but this time I'd like to track it down.
The current problem is that cargo-c 0.9.31, when built from pkgsrc, doesn't build after the pkgsc libgit2 package is upgraded from 1.7.2 to 1.8.0.

In pkgsrc (and probably most other packaging systems), we'd like to install only one copy of a library so that e.g. fixing security problems is easy - fix the library, rebuild all users, done. When using bundled libgit2, we need to find and fix the problem in all bundled copies of libgit2, which is much more work.

cargo-c 0.9.31 uses libgit2-sys-0.16.2+1.7.2.crate. The build fails with:

...
warning: libgit2-sys@0.16.2+1.7.2: libgit2/src/libgit2/commit.c:300:5: error: conflicting types for 'git_commit_create'
...
warning: libgit2-sys@0.16.2+1.7.2: libgit2/src/libgit2/commit.c:939:5: error: conflicting types for 'git_commit_create_buffer'
...
warning: libgit2-sys@0.16.2+1.7.2: libgit2/src/libgit2/config_backend.h:47:12: error: conflicting types for 'git_config_backend_from_string'
...

(and many more). I suspect that this happens because git2-rs tries to build the bundled libgit2 1.7.2 against the system's 1.8.0 headers.

I see that the documentation says that only newer patch releases of 1.7.2 are supported, so you're already documenting that it won't work. The failure mode when 1.8.0 is installed is hard to diagnose (if you're only interested in cargo-c and just see the build fail).

I have two ideas for this:

  • allow newer major versions. Of course you can't predict the future and this might break, but building the included old version against newer headers has already broken a couple of times.
  • when building the bundled libgit2 code, make sure to avoid using system-provided headers. (If this is a problem in pkgsrc only, let me know - but it looks like pkgsrc only sets a rust link-arg to fix the rpath.)

Let me know if I got something wrong, or if you have other ideas how to improve the situation. Thank you!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the pkgsrc build of cargo-c 0.9.31 with libgit2 1.8.0 and inspect the libgit2-sys 0.16.2+1.7.2 build. Review the reported conflicts in libgit2/src/libgit2/commit.c and libgit2/src/libgit2/config_backend.h. Done requires an agreed approach—supporting newer versions or isolating bundled headers—and a build that no longer produces the conflicting declarations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.