Skip to content

Commit ce29824

Browse files
committed
cargo: enable vendored-libgit2, document how to properly dynamically link libgit2
This changes less than it seems. Our CI builds already mostly linked a vendored copy of libgit2. This is because before this commit, it turns out that `git2` could link `libgit2` *either* statically or dynamically based on whether it could find a version of libgit2 it liked to link dynamically. Our CI builds usually did not provide such a version AFAIK. This made the kind of binary `cargo install` would produce unpredictable and may have contributed to #2896. I was once very surprised when I did `brew upgrade libgit2` and then `cargo build --release` suddenly switched from building dynamically linked `jj` to the vendored version. Instead, if a packager wants to link `libgit2` dynamically, they should set an environment variable, as described inside the diff of this commit. I also think we should recommend static linking as `git2` is quite picky about the versions of `libgit2` it supports. See also rust-lang/git2-rs#1073 This might be related to #4115.
1 parent 304f6df commit ce29824

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
### Note to packagers
12+
13+
* `jj` now links `libgit2` statically by default. To use dynamic linking, you
14+
need to set the environment variable `LIBGIT2_NO_VENDOR=1` while compiling.
15+
([#4163](https://github.com/martinvonz/jj/pull/4163))
16+
1117
### Breaking changes
1218

1319
* `jj rebase --skip-empty` has been renamed to `jj rebase --skip-emptied`

Cargo.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,16 @@ dunce = "1.0.4"
4848
either = "1.13.0"
4949
esl01-renderdag = "0.3.0"
5050
futures = "0.3.30"
51-
git2 = "0.18.3"
51+
git2 = { version = "0.18.3", features = [
52+
# Do *not* disable this feature even if you'd like dynamic linking. Instead,
53+
# set the environment variable `LIBGIT2_NO_VENDOR=1` if dynamic linking must
54+
# be used (this will override the Cargo feature), and allow static linking
55+
# in other cases. Rationale: If neither the feature nor the environment
56+
# variable are set, `git2` may still decide to vendor `libgit2` if it
57+
# doesn't find a version of `libgit2` to link to dynamically. See also
58+
# https://github.com/rust-lang/git2-rs/commit/3cef4119f
59+
"vendored-libgit2"
60+
] }
5261
gix = { version = "0.63.0", default-features = false, features = [
5362
"index",
5463
"max-performance-safe",

0 commit comments

Comments
 (0)