Problem
Windows CI builds are failing after upgrading to Rust 1.91.1 with unresolved external symbol errors from libgit2_sys.
Error Details
liblibgit2_sys-bd82eeea6732340b.rlib(f6e81ea219c0b9f3-fs_path.o) : error LNK2019: unresolved external symbol __imp_OpenProcessToken referenced in function current_user_sid
liblibgit2_sys-bd82eeea6732340b.rlib(f6e81ea219c0b9f3-fs_path.o) : error LNK2019: unresolved external symbol __imp_CheckTokenMembership referenced in function git_fs_path_owner_is
liblibgit2_sys-bd82eeea6732340b.rlib(f6e81ea219c0b9f3-rand.o) : error LNK2019: unresolved external symbol __imp_CryptAcquireContextA referenced in function getseed
...
fatal error LNK1120: 15 unresolved externals
All missing symbols are from Windows API:
advapi32.lib: Registry APIs, Token management, SID operations
crypt32.lib: Cryptographic functions
Root Cause
- Dependency Chain:
vergen-git2 → libgit2-sys → libgit2 (C library)
- Build Script Issue: The linking errors occur in the build script compilation phase, not the main binary
- Chicken-and-Egg Problem:
- Build scripts need to link
libgit2_sys to compile
- But linking instructions in
build.rs only affect the main binary, not build scripts
- Cannot add system libraries via
cargo:rustc-link-lib in build.rs because build.rs hasn't compiled yet
Current Workaround
Temporarily disabled Windows CI in cross-platform checks (PR #3899).
Potential Solutions
Option 1: Use Static Linking for libgit2
[dependencies.vergen-git2]
features = ["git", "git2"] # Use bundled git
Option 2: Replace vergen-git2
Alternative crates that don't depend on libgit2:
vergen (older version without git2 dependency)
vergen-lib (lightweight alternative)
- Build version info at release time only
Option 3: Conditional Compilation
#[cfg(not(target_os = "windows"))]
use vergen_git2::{...};
#[cfg(target_os = "windows")]
// Use alternative versioning strategy
Option 4: Use vcpkg for libgit2 on Windows
Set up vcpkg to provide pre-built libgit2 with correct system library dependencies.
Option 5: Fix in vergen-git2/libgit2-sys Upstream
- File issue with
vergen-git2 repo
- Ensure proper Windows system library linkage in build scripts
- May require changes to
libgit2-sys build configuration
Investigation Needed
- Test
vergen-git2 with different feature flags
- Try alternative versioning crates
- Check if newer
libgit2-sys version fixes Windows linking
- Evaluate impact of removing git info from Windows builds
Related
Priority
Medium - Windows CI is blocked but Linux/macOS builds work fine. Windows developers can still build locally using different configurations.
Problem
Windows CI builds are failing after upgrading to Rust 1.91.1 with unresolved external symbol errors from
libgit2_sys.Error Details
All missing symbols are from Windows API:
advapi32.lib: Registry APIs, Token management, SID operationscrypt32.lib: Cryptographic functionsRoot Cause
vergen-git2→libgit2-sys→libgit2(C library)libgit2_systo compilebuild.rsonly affect the main binary, not build scriptscargo:rustc-link-libin build.rs because build.rs hasn't compiled yetCurrent Workaround
Temporarily disabled Windows CI in cross-platform checks (PR #3899).
Potential Solutions
Option 1: Use Static Linking for libgit2
Option 2: Replace vergen-git2
Alternative crates that don't depend on libgit2:
vergen(older version without git2 dependency)vergen-lib(lightweight alternative)Option 3: Conditional Compilation
Option 4: Use vcpkg for libgit2 on Windows
Set up vcpkg to provide pre-built libgit2 with correct system library dependencies.
Option 5: Fix in vergen-git2/libgit2-sys Upstream
vergen-git2repolibgit2-sysbuild configurationInvestigation Needed
vergen-git2with different feature flagslibgit2-sysversion fixes Windows linkingRelated
Priority
Medium - Windows CI is blocked but Linux/macOS builds work fine. Windows developers can still build locally using different configurations.