-
Notifications
You must be signed in to change notification settings - Fork 626
portable + installer: add CLANGARM64 support #437
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
portable + installer: add CLANGARM64 support #437
Conversation
This one will probably compile fine for clangarm64, msys2 seems to compile it already with clang and ubuntu/debian seem to compile it for arm64 with no arch specific patches.
This one will probably need some changes regarding this patch
xpdf-tools, that's from https://github.com/git-for-windows/MINGW-packages/blob/main/mingw-w64-xpdf, we'd need our own |
@rimrul I was able to get all the deps to work.
Will continue work on this PR soon. It's currently in a "very rough but sort of working" state 😅 |
13f6d65
to
4e06cec
Compare
4e06cec
to
157aae6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dscho @rimrul This is now ready for a first round of reviews. I was able to generate working portable + installer artifacts for 2.38.1 with this setup 🎉
Curious to hear your thoughts on my general approach here. Especially make-file-list.sh
was a bit tricky, but everything is looking good in my testing so far.
Thanks in advance!
ARCH="$(uname -m)" | ||
case "$ARCH" in | ||
i686) | ||
case "$MSYSTEM" in | ||
MINGW32) | ||
BITNESS=32 | ||
ARCH=i686 | ||
ARTIFACT_SUFFIX=32 | ||
MD_ARG=128M | ||
;; | ||
x86_64) | ||
MINGW64) | ||
BITNESS=64 | ||
ARCH=x86_64 | ||
ARTIFACT_SUFFIX=64 | ||
MD_ARG=256M | ||
;; | ||
CLANGARM64) | ||
BITNESS=64 | ||
ARCH=aarch64 | ||
ARTIFACT_SUFFIX=ARM64 | ||
MD_ARG=256M | ||
;; | ||
*) | ||
die "Unhandled architecture: $ARCH" | ||
die "Unhandled MSYSTEM: $MSYSTEM" | ||
;; | ||
esac | ||
MSYSTEM_LOWER=${MSYSTEM,,} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$MSYSTEM
doesn't seem to be defined in Git for Windows' CI. Is that intentional? Do you have another suggestion on how to handle this? Note that uname -m
doesn't work as we build CLANGARM64 using git-sdk-64
(which is x86_64).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the environment variable in 17a3a4a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MSYSTEM
variable is defined either in /etc/profile
or in git-bash.exe
, depending on the exact scenario, or in the case of CI runs by the setup-git-for-windows-sdk
Action. It should not be necessary to set it yourself unless it is set incorrectly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that defining this incorrectly is responsible for this breakage: Note how the 32-bit build talks about wanting to install an x86_64
package? It should detect the presence of /var/lib/pacman/local/mingw-w64-i686-git-[1-9]*/files
, but instead looks for /var/lib/pacman/local/mingw-w64-x86_64-git-[1-9]*/files
which isn't there, so it tries to build mingw-w64-git
, which is not supported anymore in the 32-bit version of Git for Windows' SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example of when it failed without me explicitly setting the MSYSTEM
in CI: https://github.com/git-for-windows/build-extra/actions/runs/3357168162/jobs/5562796433. The build-artifacts
and sdk-artifacts
CI jobs don't use setup-git-for-windows-sdk
so that explains why it failed. If you want, I can set MSYSTEM: mingw64
only to the build-artifacts
and sdk-artifacts
CI jobs, or we should use setup-git-for-windows-sdk
there too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, setting MSYSTEM
should be scoped to the particular SDK instance. In other words, here, here and here, we need to insert a line like this (in a separate, preparatory commit):
echo "MSYSTEM=MINGW${{matrix.bitness}}" >>$GITHUB_ENV &&
(The first instance is not inside a matrix, it needs to hard-code MINGW64
.)
157aae6
to
98ad73e
Compare
98ad73e
to
93f19e3
Compare
make-file-list.sh
Outdated
-e '^/usr/include/' -e '^/mingw../include/' \ | ||
-e '^/(mingw|clang(arm)?)../bin/.*zstd\.exe$' \ | ||
-e '^/(mingw|clang(arm)?)../share/doc/openssl/' \ | ||
-e '^/(mingw|clang(arm)?)../share/doc/gettext/' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dscho after some testing, I found that this capturing group (or the non-capturing group alternative: '^/(?:mingw|clang(arm)?)../share/doc/gettext/'
) only works when -P
is specified in grep
:
Regexp selection and interpretation:
-E, --extended-regexp PATTERN is an extended regular expression (ERE)
-F, --fixed-strings PATTERN is a set of newline-separated strings
-G, --basic-regexp PATTERN is a basic regular expression (BRE)
-P, --perl-regexp PATTERN is a Perl regular expression
-e, --regexp=PATTERN use PATTERN for matching
-f, --file=FILE obtain PATTERN from FILE
-i, --ignore-case ignore case distinctions
-w, --word-regexp force PATTERN to match only whole words
-x, --line-regexp force PATTERN to match only whole lines
-z, --null-data a data line ends in 0 byte, not newline
However, when I tested with -P
, I ran into the following error:
grep: the -P option only supports a single pattern
🤦🏼♂️ this is slightly getting out of hand.
Would it also be ok for you if I simply add the MSYSTEM_LOWER
variable to the pattern, like this:
-e "^/$MSYSTEM_LOWER/share/doc/gettext/" \
... or do you really need mingw..
so that it matches both mingw32
and mingw64
? Just checking!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that $MSYSTEM_LOWER
would work. Except in the case of clangarm64
where we expect to also have to handle mingw64
... But why not simply -e "^/\(mingw\|clang\)[^/]*/share/doc/gettext/"
, i.e. match any top-level directory starting either with mingw
or with clang
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works. I compared the output of the "before" and "after" make-file-list.sh
and they're the exact same after this change. Thanks!
917147d
to
6b4653c
Compare
@dscho This is ready for review. The |
6b4653c
to
99c6913
Compare
ARCH="$(uname -m)" | ||
|
||
case "$ARCH" in | ||
i686) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer the change from uname -m
to $MSYSTEM
to be done in a separate commit that still only handles i686 and x86_64, and add the aarch64 part in a separate commit.
Please let me know if you want assistance with that.
ARCH="$(uname -m)" | ||
case "$ARCH" in | ||
i686) | ||
case "$MSYSTEM" in | ||
MINGW32) | ||
BITNESS=32 | ||
ARCH=i686 | ||
ARTIFACT_SUFFIX=32 | ||
MD_ARG=128M | ||
;; | ||
x86_64) | ||
MINGW64) | ||
BITNESS=64 | ||
ARCH=x86_64 | ||
ARTIFACT_SUFFIX=64 | ||
MD_ARG=256M | ||
;; | ||
CLANGARM64) | ||
BITNESS=64 | ||
ARCH=aarch64 | ||
ARTIFACT_SUFFIX=ARM64 | ||
MD_ARG=256M | ||
;; | ||
*) | ||
die "Unhandled architecture: $ARCH" | ||
die "Unhandled MSYSTEM: $MSYSTEM" | ||
;; | ||
esac | ||
MSYSTEM_LOWER=${MSYSTEM,,} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, setting MSYSTEM
should be scoped to the particular SDK instance. In other words, here, here and here, we need to insert a line like this (in a separate, preparatory commit):
echo "MSYSTEM=MINGW${{matrix.bitness}}" >>$GITHUB_ENV &&
(The first instance is not inside a matrix, it needs to hard-code MINGW64
.)
make-file-list.sh
Outdated
usr/bin/column.exe | ||
EOF | ||
|
||
[[ -z "$MINIMAL_GIT" && $MSYSTEM_LOWER == mingw* ]] && cat <<EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The [[ ... ]] &&
syntax is not used anywhere else in this file, therefore it threw me quite a bit. Let's not?
Also, maybe it's better to introduce a new variable like PDFTOTEXT_FILES
, and set it in an architecture-specific way before using it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used it so that I could do mingw*
(wildcard). test
can't do that. Do you have a better alternative to this: if test -z "$MINIMAL_GIT" && (test "$MSYSTEM_LOWER" = "mingw64" || test "$MSYSTEM_LOWER" = "mingw32")
I'm not sure whether I get the comment regarding pdftotext
. That executable is supported on all platforms, so no need to introduce architecture-specific logic for it, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the wildcard. The classical Unix method is to use case
, like so:
case "$MINIMAL_GIT,$MSYSTEM_LOWER" in
,mingw*)
...
;;
esac
But that's a lot more verbose, so I guess I'm fine with the [[
construct.
I'm not sure whether I get the comment regarding pdftotext.
What I mean is this: https://github.com/git-for-windows/build-extra/pull/437/files#diff-9b50f413340b32f6bc699741e8b09ab52b3e9c7698d787cc26c4c95e78580916L375-R401
-mingw$BITNESS/bin/pdftotext.exe
-mingw$BITNESS/bin/libstdc++-6.dll
+$MSYSTEM_LOWER/bin/pdftotext.exe
usr/bin/column.exe
EOF
+if test -z "$MINIMAL_GIT" && (test "$MSYSTEM_LOWER" = "mingw64" || test "$MSYSTEM_LOWER" = "mingw32"); then
+cat <<EOF
+$MSYSTEM_LOWER/bin/libstdc++-6.dll
+EOF
+fi
+
Separating the pdftotext.exe
line from the libstdc++-6.dll
line in the proposed way won't make it as obvious as the current version that pdftotext.exe
is the only reason why that .dll
is required in the first place.
What I would prefer is to have conditionals that add the appropriate lines for pdftotext depending on the platform, unless we're enumerating the files for a MinGit.
So I would define these lines somewhat like this:
case $MSYSTEM_LOWER in
mingw*)
PDFTOTEXT_FILES="$MSYSTEM_LOWER/bin/pdftotext.exe
$MSYSTEM_LOWER/bin/libstdc++-6.dll"
;;
*)
# In the clang version, we do not need the libstdc++ DLL
PDFTOTEXT_FILES="$MSYSTEM_LOWER/bin/pdftotext.exe
;;
esac
and then replace the current mentions of these files with $PDFTOTEXT_FILES
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I thought that libstdc++-6.dll
was used for other things as well. Have just updated the commit and addressed the other feedback from this PR as well. Thanks!
.github/workflows/main.yml
Outdated
@@ -4,6 +4,7 @@ on: pull_request | |||
|
|||
env: | |||
GIT_CONFIG_PARAMETERS: "'checkout.workers=56'" | |||
MSYSTEM: MINGW64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're not setting MSYSTEM=MINGW32
explicitly in the 32-bit jobs, that's what causes this problem.
Several scripts in build-extra will rely on the MSYSTEM to detect things like the architecture (x86_64, i686, aarch64). This is required because the old solution (uname -m) doesn't work for CLANGARM64, which depends on x64 emulation in MSYS2. Ref: https://www.msys2.org/wiki/arm64/ Signed-off-by: Dennis Ameling <[email protected]>
c70f4c1
to
110dba5
Compare
When using clang-based msystems like CLANG64, the folder prefix is different than what make-file-list.sh is used to (/clangxxx instead of /mingwxx). Let's teach make-file-list.sh to find and filter those files. Signed-off-by: Dennis Ameling <[email protected]>
Adds support for the CLANGARM64 MSYSTEM to make-file-list.sh. Signed-off-by: Dennis Ameling <[email protected]>
clangarm64 is a relatively new MSYSTEM added by the MSYS2 team. Let's leverage it on our journey to Git for Windows ARM64 support. Signed-off-by: Dennis Ameling <[email protected]>
$(uname -m) returns the architecture of the MSYS2 shell. This works for x64 and x86 on Windows, but not for ARM64, for which we'll add support in a follow-up PR. The reason is that MSYS2 can only be run using x64 emulation on ARM64 due to lacking Cygwin support for that platform. To prepare for ARM64 support and to be more consistent with other MSYS2 logic, let's leverage $MSYSTEM instead of $(uname -m). Ref: https://www.msys2.org/wiki/arm64/ Signed-off-by: Dennis Ameling <[email protected]>
This replaces our earlier efforts to support ARM64 for Git for Windows. It uses the new CLANGARM64 MSYSTEM, so ARM64 now becomes a first-class citizen. Signed-off-by: Dennis Ameling <[email protected]>
$(uname -m) returns the architecture of the MSYS2 shell. This works for x64 and x86 on Windows, but not for ARM64, for which we'll add support in a follow-up PR. The reason is that MSYS2 can only be run using x64 emulation on ARM64 due to lacking Cygwin support for that platform. To prepare for ARM64 support and to be more consistent with other MSYS2 logic, let's leverage $MSYSTEM instead of $(uname -m). Ref: https://www.msys2.org/wiki/arm64/ Signed-off-by: Dennis Ameling <[email protected]>
This replaces our earlier efforts to support ARM64 for Git for Windows. It uses the new CLANGARM64 MSYSTEM, so ARM64 now becomes a first-class citizen. Signed-off-by: Dennis Ameling <[email protected]>
110dba5
to
f90fe17
Compare
Signed-off-by: Dennis Ameling <[email protected]>
f90fe17
to
2fa6f5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thank you so much!
Needs git-for-windows/MINGW-packages#56✅ mergedNeeds git-for-windows/MINGW-packages#59✅ mergedNeeds git-for-windows/MINGW-packages#58✅ mergedNeeds git-for-windows/setup-git-for-windows-sdk#397✅ mergedNeeds git-for-windows/git#3916✅ mergedNeeds msys2/MINGW-packages#13787✅ mergedNeeds git-for-windows/MINGW-packages#57✅ mergedNeeds #440✅ mergedHow to test
On an ARM64 device, do the following:
git-sdk-64
clangarm64
folder and start the SDK withMSYSTEM=clangarm64
, as well as install tools like the Clang compiler. Note that the Git SDK GitHub Action will do that for you soon - see https://github.com/git-for-windows/setup-git-for-windows-sdk/pull/397/files for all details, including a list of the dependencies you need.curl
/openssl
/xpdf-tools
/wintoast
dependencies forclangarm64
: git-build-extra-artifacts-zst.zipThen run the following command for portable:
... or this command for installer: