Skip to content

Commit 7447694

Browse files
authored
Support clangarm64 environment (#21)
* Support clangarm64 environment * Remove code used for bootstrap msys2-arm64
1 parent aa15221 commit 7447694

File tree

6 files changed

+117
-46
lines changed

6 files changed

+117
-46
lines changed

.github/workflows/windows-build-tools.yml

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,43 @@ on:
1111
jobs:
1212
msys2:
1313
name: >-
14-
msys2 tools
14+
${{ matrix.name }} tools
1515
#env:
1616
# FORCE_UPDATE: true
17-
runs-on: windows-2022
17+
permissions:
18+
contents: write
19+
runs-on: ${{ matrix.os }}
1820
strategy:
1921
fail-fast: false
22+
matrix:
23+
include:
24+
- { os: windows-2022, ruby: ucrt, name: msys2 }
25+
- { os: windows-11-arm, ruby: 3.4, name: msys2-arm64 }
2026
steps:
2127
- name: Checkout
2228
uses: actions/checkout@v4
2329

2430
- name: Copy msys2 files to temp dir
2531
run: |
26-
$temp = $env:RUNNER_TEMP
27-
md $temp\msys64
28-
# copy current msys2 to temp folder, needed to determine what files to include
29-
# in zip file (only newer files)
30-
xcopy C:\msys64 $temp\msys64 /s /q
32+
if (Test-Path -LiteralPath C:\msys64 -PathType Container) {
33+
$temp = $env:RUNNER_TEMP
34+
md $temp\msys64
35+
# copy current msys2 to temp folder, needed to determine what files to include
36+
# in zip file (only newer files)
37+
xcopy C:\msys64 $temp\msys64 /s /q
38+
}
3139
timeout-minutes: 15
3240

3341
- name: Set up Ruby
3442
uses: ruby/setup-ruby@v1
3543
with:
36-
ruby-version: ucrt
44+
ruby-version: ${{ matrix.ruby }}
3745
timeout-minutes: 7
3846

3947
- name: Update msys2 tools 7z and Upload
40-
run: ruby create_msys2_pkg.rb
48+
run: ruby create_msys2_pkg.rb ${{ matrix.name }}
4149
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
GITHUB_TOKEN: ${{ github.token }}
4351
timeout-minutes: 10
4452

4553
gcc-mingw:
@@ -49,6 +57,8 @@ jobs:
4957
${{ matrix.gcc }} gcc
5058
#env:
5159
# FORCE_UPDATE: true
60+
permissions:
61+
contents: write
5262
runs-on: windows-2022
5363
strategy:
5464
fail-fast: false
@@ -69,16 +79,18 @@ jobs:
6979
- name: Update ${{ matrix.gcc }} gcc 7z and Upload
7080
run: ruby create_gcc_pkg.rb ${{ matrix.gcc }}
7181
env:
72-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
GITHUB_TOKEN: ${{ github.token }}
7383
timeout-minutes: 13
7484

7585
gcc-ucrt:
7686
if: ${{ always() }}
77-
needs: gcc-mingw
87+
needs: msys2
7888
name: >-
7989
${{ matrix.gcc }} gcc
8090
#env:
8191
# FORCE_UPDATE: true
92+
permissions:
93+
contents: write
8294
runs-on: windows-2022
8395
strategy:
8496
fail-fast: false
@@ -99,6 +111,37 @@ jobs:
99111
- name: Update ${{ matrix.gcc }} gcc 7z and Upload
100112
run: ruby create_gcc_pkg.rb ${{ matrix.gcc }}
101113
env:
102-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
GITHUB_TOKEN: ${{ github.token }}
115+
timeout-minutes: 13
116+
117+
gcc-clangarm64:
118+
if: ${{ always() }}
119+
needs: msys2
120+
name: >-
121+
${{ matrix.gcc }} gcc
122+
#env:
123+
# FORCE_UPDATE: true
124+
permissions:
125+
contents: write
126+
runs-on: windows-11-arm
127+
strategy:
128+
fail-fast: false
129+
matrix:
130+
include:
131+
- { gcc: clangarm64-3.0 , ruby: 3.4 }
132+
steps:
133+
- name: Checkout
134+
uses: actions/checkout@v4
135+
136+
- name: Set up Ruby
137+
uses: ruby/setup-ruby@v1
138+
with:
139+
ruby-version: ${{ matrix.ruby }}
140+
timeout-minutes: 7
141+
142+
- name: Update ${{ matrix.gcc }} gcc 7z and Upload
143+
run: ruby create_gcc_pkg.rb ${{ matrix.gcc }}
144+
env:
145+
GITHUB_TOKEN: ${{ github.token }}
103146
timeout-minutes: 13
104147

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,42 @@ Below summarizes the default MSYS2 installations on Actions Windows images:
1616

1717
| Actions<br/>Image | MSYS<br/>Base | MSYS<br/>Build Tools | mingw64<br/>gcc & tools | mingw64<br/>packages | ucrt64<br/>gcc & tools | ucrt64<br/>packages |
1818
|--------------------|:--------------:|:--------------------:|:-----------------------:|:--------------------:|:----------------------:|:-------------------:|
19+
| **11-arm** | No | No | No | No | No | No |
1920
| **2022 and later** | Yes | No | No | No | No | No |
2021
| **2016, 2019** | Yes | Yes | Yes | Some | No | No |
2122

2223
### Notes
2324

24-
Six package files are stored in a GitHub release, and are used by
25+
Eight package files are stored in a GitHub release, and are used by
2526
[ruby/setup-ruby](https://github.com/ruby/setup-ruby). They are:
2627

2728
* **`msys2.7z`** The base msys2 installation on Actions Windows images contains a minimal
2829
set of bash tools, and no shared build tools. Code updates the MSYS2 files, and saves only
29-
updated files to the 7z. All Ruby Windows releases from version 2.4 and later use these
30+
updated files to the 7z. All Ruby Windows x64 releases from version 2.4 and later use these
3031
tools.
3132

33+
* **`msys2-arm64.7z`** The base msys2 installation on Actions Windows images contains a minimal
34+
set of bash tools, and no shared build tools. Code saves complate base MSYS2 files to the 7z.
35+
All Ruby Windows arm64 releases from version 3.4 and later use these tools.
36+
3237
* **`mingw64.7z`** This contains the mingw64 gcc chain and any packages needed to build
3338
Ruby. This has OpenSSL 1.1.1 installed, as of 26-Apr-2024, 1.1.1.w. Normal Ruby Windows
3439
releases from version 2.4 thru 3.0 use these tools.
3540

3641
* **`mingw64-3.0.7z`** This contains the mingw64 gcc chain and any packages needed to build
37-
Ruby. The MSYS2 OpenSSL 3.3.z package is installed. The mingw Ruby master build is the
42+
Ruby. The MSYS2 OpenSSL 3.y.z package is installed. The mingw Ruby master build is the
3843
only build that uses this.
3944

4045
* **`ucrt64.7z`** This contains the ucrt64 gcc chain and any packages needed to build
4146
Ruby. This has OpenSSL 1.1.1 installed, as of 26-Apr-2024, 1.1.1.w. Ruby version 3.1 is
4247
the only release that uses this.
4348

4449
* **`ucrt64-3.0.7z`** This contains the ucrt64 gcc chain and any packages needed to build
45-
Ruby. The MSYS2 OpenSSL 3.3.z package is installed. Ruby 3.2, head, & ucrt builds use this.
50+
Ruby. The MSYS2 OpenSSL 3.y.z package is installed. Ruby 3.2, head, & ucrt builds use this.
51+
52+
* **`clangarm64-3.0.7z`** This contains the clangarm64 gcc chain and any packages needed to build
53+
Ruby. The MSYS2 OpenSSL 3.y.z package is installed. Ruby 3.4 and head builds on windows arm64
54+
use this.
4655

4756
* **`mswin.7z`** This contains files needed to compile Windows Ruby mswin builds. It contains
4857
libffi, libyaml, openssl, readline, and zlib, built with the Microsoft vcpkg system. This

common.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,9 @@ module Common
3434
PACMAN = 'C:/msys64/usr/bin/pacman.exe'
3535
BASH = 'C:/msys64/usr/bin/bash.exe'
3636

37-
SSL_3_SAVE_FILES = %w[
38-
bin/libcrypto-3-x64.dll
39-
bin/libssl-3-x64.dll
40-
etc/ssl/openssl.cnf
41-
]
42-
4337
def gh_api_graphql(http, query)
4438
body = {}
4539
body["query"] = query
46-
response = nil
4740

4841
req = Net::HTTP::Post.new '/gh_api_graphql'
4942
req['Authorization'] = "Bearer #{TOKEN}"
@@ -315,12 +308,12 @@ def refresh_keys
315308
system 'taskkill /f /fi "MODULES eq msys-2.0.dll"'
316309

317310
STDOUT.syswrite "#{str}\n#{END_GROUP}"
318-
311+
319312
str.match?(/new signatures:|signatures cleaned:/) ? true : nil
320313
end
321314

322315
def pacman_syuu(ignore = nil)
323-
316+
324317
usr_bin = "#{MSYS2_ROOT}/usr/bin"
325318

326319
exit 1 unless system "#{usr_bin}/sed -i 's/^CheckSpace/#CheckSpace/g' C:/msys64/etc/pacman.conf"

create_gcc_pkg.rb

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,26 @@ class << self
3838
['mingw64', 'mingw-w64-x86_64-']
3939
when 'mingw32'
4040
['mingw32', 'mingw-w64-i686-']
41+
when 'clangarm64'
42+
['clangarm64', 'mingw-w64-clang-aarch64-']
4143
else
42-
STDOUT.syswrite "Invalid package type, must be ucrt64, mingw64, or mingw32\n"
44+
STDOUT.syswrite "Invalid package type, must be ucrt64, mingw64, mingw32, or clangarm64\n"
4345
exit 1
4446
end
4547

4648
MSYS2_PKG = "#{MSYS2_ROOT}/#{PKG_DIR}"
47-
48-
SSL_1_DLLS = %w[bin/libcrypto-1_1-x64.dll bin/libssl-1_1-x64.dll]
49+
50+
SSL_1_DLLS = if PKG_DIR == 'clangarm64'
51+
%w[bin/libcrypto-1_1.dll bin/libssl-1_1.dll]
52+
else
53+
%w[bin/libcrypto-1_1-x64.dll bin/libssl-1_1-x64.dll]
54+
end
55+
56+
SSL_3_SAVE_FILES = if PKG_DIR == 'clangarm64'
57+
%w[bin/libcrypto-3.dll bin/libssl-3.dll etc/ssl/openssl.cnf]
58+
else
59+
%w[bin/libcrypto-3-x64.dll bin/libssl-3-x64.dll etc/ssl/openssl.cnf]
60+
end
4961

5062
def add_ri2_key
5163
# appveyor ri2 package signing key
@@ -99,11 +111,9 @@ def openssl_upgrade
99111
pkg_name = "openssl-3.0.7-1-any.pkg.tar.zst"
100112
pkg = "https://github.com/oneclick/rubyinstaller2-packages/releases/download/ci.ri2/#{PKG_PRE}#{pkg_name}"
101113
pkg_sig = "#{pkg}.sig"
102-
old_dlls = %w[libcrypto-1_1-x64.dll libssl-1_1-x64.dll]
103-
dll_root = "#{MSYS2_ROOT}/#{PKG_DIR}/bin"
104114

105115
# save previous dll files so we can copy back into folder
106-
old_dlls.each { |fn| FileUtils.cp "#{dll_root}/#{fn}", "." }
116+
SSL_1_DLLS.each { |fn| FileUtils.cp "#{MSYS2_PKG}/#{fn}", "." }
107117

108118
download pkg , "./#{PKG_PRE}#{pkg_name}"
109119
download pkg_sig, "./#{PKG_PRE}#{pkg_name}.sig"
@@ -112,11 +122,7 @@ def openssl_upgrade
112122
exec_check "Install OpenSSL Upgrade", "pacman.exe -Udd --noconfirm --noprogressbar #{PKG_PRE}#{pkg_name}"
113123

114124
# copy previous dlls back into MSYS2 folder
115-
old_dlls.each do |fn|
116-
unless File.exist? "#{dll_root}/#{fn}"
117-
FileUtils.cp fn , "#{dll_root}/#{fn}"
118-
end
119-
end
125+
SSL_1_DLLS.each { |fn| FileUtils.cp_r File.basename(fn) , "#{MSYS2_PKG}/#{fn}" }
120126
end
121127

122128
# Below files are part of the 'ca-certificates' package, they are not
@@ -264,6 +270,10 @@ def run
264270
STDOUT.syswrite "\n#{GRN}** Creating and Uploading #{PKG_DIR} gcc tools 7z **#{RST}\n\n"
265271
end
266272

273+
exec_check "Remove all uninstalled packages" , "#{BASH} -c \"paccache -r -f -u -k0\""
274+
exec_check "Keep the newest for all other packages" , "#{BASH} -c \"paccache -r -f -k1\""
275+
exec_check "Remove all cached packages" , "#{PACMAN} -Scc --noconfirm"
276+
267277
copy_to_temp
268278

269279
clean_package

create_mswin_pkg.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def generate_package_files
6060
Dir.chdir VCPKG do |d|
6161

6262
install_info = %x(./vcpkg install #{PACKAGES} --triplet=x64-windows --dry-run)
63-
63+
6464
installed_packages = install_info.include?('The following packages will be built and installed')
6565

6666
exec_check "Installing #{PACKAGES}",
@@ -101,7 +101,7 @@ def generate_package_files
101101

102102
def run
103103
generate_package_files
104-
104+
105105
copy_ssl_files
106106

107107
# create 7z archive file

create_msys2_pkg.rb

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,22 @@ class << self
2121
LOCAL = 'var/lib/pacman/local'
2222
CACHE = 'var/cache/pacman/pkg'
2323

24-
MSYS2_PKG = RUBY_PLATFORM.include?('ucrt') ?
25-
"#{MSYS2_ROOT}/ucrt64" : "#{MSYS2_ROOT}/mingw64"
24+
MSYS2_PKG = case RUBY_PLATFORM
25+
when 'aarch64-mingw-ucrt'
26+
"#{MSYS2_ROOT}/clangarm64"
27+
when /ucrt$/
28+
"#{MSYS2_ROOT}/ucrt64"
29+
else
30+
"#{MSYS2_ROOT}/mingw64"
31+
end
32+
33+
PKG_NAME = ARGV[0].downcase
34+
35+
SSL_3_SAVE_FILES = %w[
36+
bin/libcrypto-3-x64.dll
37+
bin/libssl-3-x64.dll
38+
etc/ssl/openssl.cnf
39+
]
2640

2741
def update_msys2
2842

@@ -101,29 +115,31 @@ def run
101115

102116
log_array_2_column updated_pkgs, 48, "Installed MSYS2 Packages"
103117

104-
gpg_files = Dir["#{MSYS2_ROOT}/etc/pacman.d/gnupg/*"].count { |fn| File.file? fn }
105-
106118
if current_pkgs == updated_pkgs && !updated_keys && !ENV.key?('FORCE_UPDATE')
107119
STDOUT.syswrite "\n** No update to MSYS2 tools needed **\n\n"
108120
exit 0
109121
else
110122
STDOUT.syswrite "\n#{GRN}** Creating and Uploading MSYS update 7z **#{RST}\n\n"
111123
end
112124

125+
exec_check "Remove all uninstalled packages" , "#{BASH} -c \"paccache -r -f -u -k0\""
126+
exec_check "Keep the newest for all other packages" , "#{BASH} -c \"paccache -r -f -k1\""
127+
exec_check "Remove all cached packages" , "#{PACMAN} -Scc --noconfirm"
128+
113129
remove_non_msys2
114-
remove_duplicate_files
130+
remove_duplicate_files if File.exist?(ORIG_MSYS2)
115131
clean_database 'msys'
116132
clean_packages
117133

118134
# create 7z file
119135
STDOUT.syswrite "##[group]#{YEL}Create msys2 7z file#{RST}\n"
120-
tar_path = "#{Dir.pwd}\\msys2.7z".gsub '/', '\\'
136+
tar_path = "#{Dir.pwd}\\#{PKG_NAME}.7z".gsub '/', '\\'
121137
Dir.chdir MSYS2_ROOT do
122138
exit 1 unless system "\"#{SEVEN}\" a #{tar_path}"
123139
end
124140
STDOUT.syswrite "##[endgroup]\n"
125141

126-
upload_7z_update 'msys2', time
142+
upload_7z_update PKG_NAME, time
127143
end
128144
end
129145
end

0 commit comments

Comments
 (0)