Skip to content

Commit f1cf460

Browse files
dschogitster
authored andcommitted
win+Meson: do allow linking with the Rust-built xdiff
When linking against the Rust-built `xdiff`, there is now a new required dependency: Without _also_ linking to the system library `userenv`, the compile would fail with this error message: xdiff.lib(std-c85e9beb7923f636.std.df32d1bc89881d89-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol __imp_GetUserProfileDirectoryW referenced in function _ZN3std3env8home_dir17hfd1c3b6676cd78f6E Therefore, just like we do in case of Makefile-based builds on Windows, we now also link to that library when building with Meson. Note that if we only have Rust depend upon libuserenv then at link time GCC would complain about: undefined reference to `GetUserProfileDirectoryW' Apparently there is _some_ closure that gets compiled in that requires this function, and that in turn forces Git to link to libuserenv. This is a new requirement, and therefore has not been made part of the "minimal Git for Windows SDK". In the near future, I intend to include it, but for now let's just ensure that the file is added manually if it is missing. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> [en: Squashed a few of Johannes's patches, and moved lib userenv handling from an earlier patch] Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 75e6360 commit f1cf460

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ jobs:
115115
steps:
116116
- uses: actions/checkout@v4
117117
- uses: git-for-windows/setup-git-for-windows-sdk@v1
118+
- name: ensure that libuserenv.a is present
119+
shell: bash
120+
run: |
121+
cd /mingw64/lib && {
122+
test -f libuserenv.a ||
123+
/c/Program\ Files/Git/mingw64/bin/curl -Lo libuserenv.a \
124+
https://github.com/git-for-windows/git-sdk-64/raw/HEAD/mingw64/lib/libuserenv.a
125+
}
118126
- name: build
119127
shell: bash
120128
env:

config.mak.uname

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,8 @@ ifeq ($(uname_S),MINGW)
765765

766766
export CARGO_BUILD_TARGET
767767
RUST_TARGET_DIR = rust/target/$(CARGO_BUILD_TARGET)/$(RUST_BUILD_MODE)
768+
# Unfortunately now needed because of Rust
769+
EXTLIBS += -luserenv
768770

769771
CC = gcc
770772
COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,7 @@ elif host_machine.system() == 'windows'
12931293
]
12941294

12951295
libgit_dependencies += compiler.find_library('ntdll')
1296+
libgit_dependencies += compiler.find_library('userenv')
12961297
libgit_include_directories += 'compat/win32'
12971298
if compiler.get_id() == 'msvc'
12981299
libgit_include_directories += 'compat/vcbuild/include'

0 commit comments

Comments
 (0)