Skip to content

clangarm64: let the tests pass! #5586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3613,6 +3613,10 @@ static size_t append_system_bin_dirs(char *path, size_t size)
strip_suffix_mem(prefix, &len, "\\mingw64\\bin"))
off += xsnprintf(path + off, size - off,
"%.*s\\mingw64\\bin;", (int)len, prefix);
else if (strip_suffix_mem(prefix, &len, "\\clangarm64\\libexec\\git-core") ||
strip_suffix_mem(prefix, &len, "\\clangarm64\\bin"))
off += xsnprintf(path + off, size - off,
"%.*s\\clangarm64\\bin;", (int)len, prefix);
else if (strip_suffix_mem(prefix, &len, "\\mingw32\\libexec\\git-core") ||
strip_suffix_mem(prefix, &len, "\\mingw32\\bin"))
off += xsnprintf(path + off, size - off,
Expand Down Expand Up @@ -3718,9 +3722,13 @@ static void setup_windows_environment(void)
char buf[32768];
size_t off = 0;

xsnprintf(buf, sizeof(buf),
"MINGW%d", (int)(sizeof(void *) * 8));
setenv("MSYSTEM", buf, 1);
#if defined(__MINGW64__) || defined(_M_AMD64)
setenv("MSYSTEM", "MINGW64", 1);
#elif defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
setenv("MSYSTEM", "CLANGARM64", 1);
#else
setenv("MSYSTEM", "MINGW32", 1);
#endif

if (home)
off += xsnprintf(buf + off, sizeof(buf) - off,
Expand Down
12 changes: 12 additions & 0 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,21 @@ int max_allowed_tree_depth =
* the stack overflow can occur.
*/
512;
#else
#if defined(GIT_WINDOWS_NATIVE) && defined(__clang__) && defined(__aarch64__)
/*
* Similar to Visual C, it seems that on Windows/ARM64 the clang-based
* builds have a smaller stack space available. When running out of
* that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the
* Git command was run from an MSYS2 Bash, this unfortunately results
* in an exit code 127. Let's prevent that by lowering the maximal
* tree depth; This value seems to be low enough.
*/
1280;
#else
2048;
#endif
#endif

#ifndef PROTECT_HFS_DEFAULT
#define PROTECT_HFS_DEFAULT 0
Expand Down
34 changes: 18 additions & 16 deletions t/t0060-path-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -621,30 +621,32 @@ test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works'
'

test_expect_success MINGW,RUNTIME_PREFIX 'MSYSTEM/PATH is adjusted if necessary' '
mkdir -p "$HOME"/bin pretend/mingw64/bin \
pretend/mingw64/libexec/git-core pretend/usr/bin &&
cp "$GIT_EXEC_PATH"/git.exe pretend/mingw64/bin/ &&
cp "$GIT_EXEC_PATH"/git.exe pretend/mingw64/libexec/git-core/ &&
if test -z "$MINGW_PREFIX"
then
MINGW_PREFIX="/$(echo "${MSYSTEM:-MINGW64}" | tr A-Z a-z)"
fi &&
mkdir -p "$HOME"/bin pretend"$MINGW_PREFIX"/bin \
pretend"$MINGW_PREFIX"/libexec/git-core pretend/usr/bin &&
cp "$GIT_EXEC_PATH"/git.exe pretend"$MINGW_PREFIX"/bin/ &&
cp "$GIT_EXEC_PATH"/git.exe pretend"$MINGW_PREFIX"/libexec/git-core/ &&
# copy the .dll files, if any (happens when building via CMake)
case "$GIT_EXEC_PATH"/*.dll in
*/"*.dll") ;; # no `.dll` files to be copied
*)
cp "$GIT_EXEC_PATH"/*.dll pretend/mingw64/bin/ &&
cp "$GIT_EXEC_PATH"/*.dll pretend/mingw64/libexec/git-core/
;;
esac &&
if test -n "$(ls "$GIT_EXEC_PATH"/*.dll 2>/dev/null)"
then
cp "$GIT_EXEC_PATH"/*.dll pretend"$MINGW_PREFIX"/bin/ &&
cp "$GIT_EXEC_PATH"/*.dll pretend"$MINGW_PREFIX"/libexec/git-core/
fi &&
echo "env | grep MSYSTEM=" | write_script "$HOME"/bin/git-test-home &&
echo "echo mingw64" | write_script pretend/mingw64/bin/git-test-bin &&
echo "echo ${MINGW_PREFIX#/}" | write_script pretend"$MINGW_PREFIX"/bin/git-test-bin &&
echo "echo usr" | write_script pretend/usr/bin/git-test-bin2 &&

(
MSYSTEM= &&
GIT_EXEC_PATH= &&
pretend/mingw64/libexec/git-core/git.exe test-home >actual &&
pretend/mingw64/libexec/git-core/git.exe test-bin >>actual &&
pretend/mingw64/bin/git.exe test-bin2 >>actual
pretend"$MINGW_PREFIX"/libexec/git-core/git.exe test-home >actual &&
pretend"$MINGW_PREFIX"/libexec/git-core/git.exe test-bin >>actual &&
pretend"$MINGW_PREFIX"/bin/git.exe test-bin2 >>actual
) &&
test_write_lines MSYSTEM=$MSYSTEM mingw64 usr >expect &&
test_write_lines MSYSTEM=$MSYSTEM "${MINGW_PREFIX#/}" usr >expect &&
test_cmp expect actual
'

Expand Down
Loading