Skip to content

Commit 54af0ff

Browse files
committed
Build libjpeg-turbo, OpenSSL, OpenBLAS, and FFmpeg packages using MSYS2 MinGW toolchain
1 parent ca7d780 commit 54af0ff

10 files changed

Lines changed: 216 additions & 23 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e # exit on error
4+
set -x # echo on
5+
set -o pipefail # fail of any command in pipeline is an error
6+
7+
pushd /
8+
patch -p1 -i `cygpath "$GITHUB_WORKSPACE"`/patches/makepkg/0001-cross-compilation.patch
9+
cat /etc/makepkg_mingw.conf
10+
cat /etc/profile
11+
cat /usr/share/makepkg/tidy/strip.sh
12+
popd
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e # exit on error
44
set -x # echo on
55
set -o pipefail # fail of any command in pipeline is an error
66

7-
pacman -Syu --noconfirm
7+
pacman -Syuu --noconfirm
88

99
# Add WoArm64 custom repository.
1010
REPO='[woarm64]
@@ -15,4 +15,3 @@ SigLevel = Optional
1515
echo -e "$REPO$(cat /etc/pacman.conf)" > /etc/pacman.conf
1616

1717
pacman -Sy --noconfirm
18-
pacman -S mingw-w64-cross-gcc --noconfirm

.github/workflows/build-package.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@ on:
1313
description: "Install additional dependencies"
1414
type: string
1515
default: ""
16-
msys2_packages_branch:
17-
description: "MSYS2-packages branch to build"
16+
packages_repository:
17+
description: "MSYS2 packages repository to build from"
18+
type: string
19+
default: "Windows-on-ARM-Experiments/MSYS2-packages"
20+
packages_branch:
21+
description: "MSYS2 packages branch to build from"
1822
type: string
1923
default: "woarm64"
24+
cross_compile:
25+
description: "Use cross-compiler for the package build"
26+
type: boolean
27+
default: false
2028

2129
defaults:
2230
run:
@@ -35,24 +43,34 @@ jobs:
3543
msystem: MSYS
3644
update: true
3745

46+
- name: Checkout repository
47+
uses: actions/checkout@v4
48+
49+
- name: Setup packages repository
50+
run: |
51+
`cygpath "${{ github.workspace }}"`/.github/scripts/setup-repository.sh
52+
3853
- name: Install dependencies
3954
run: |
4055
pacman -S --noconfirm \
4156
base-devel \
4257
git \
4358
mingw-w64-x86_64-github-cli \
4459
mingw-w64-x86_64-jq \
60+
${{ inputs.cross_compile && 'mingw-w64-cross-gcc' || '' }} \
4561
${{ inputs.dependencies }}
4662
47-
- name: Checkout repository
48-
uses: actions/checkout@v4
63+
- name: Setup cross-compilation environment
64+
if: ${{ inputs.cross_compile }}
65+
run: |
66+
`cygpath "${{ github.workspace }}"`/.github/scripts/setup-cross-compilation.sh
4967
50-
- name: Checkout MSYS2 packages repository
68+
- name: Checkout ${{ inputs.packages_repository }} repository
5169
uses: actions/checkout@v4
5270
with:
53-
repository: Windows-on-ARM-Experiments/MSYS2-packages
54-
ref: ${{ inputs.msys2_packages_branch }}
55-
path: ${{ github.workspace }}/MSYS2-packages
71+
repository: ${{ inputs.packages_repository }}
72+
ref: ${{ inputs.packages_branch }}
73+
path: ${{ github.workspace }}/packages
5674

5775
- name: Download artifacts
5876
if: ${{ inputs.needs }}
@@ -67,21 +85,27 @@ jobs:
6785
run: |
6886
pacman -U --noconfirm *.pkg.tar.zst
6987
70-
- name: Copy missing headers
88+
- name: Copy missing headers for mingw-w64-cross-crt
7189
if: ${{ inputs.package_name == 'mingw-w64-cross-crt' }}
7290
run: |
7391
cp /opt/x86_64-w64-mingw32/include/pthread_signal.h /opt/aarch64-w64-mingw32/include/
7492
cp /opt/x86_64-w64-mingw32/include/pthread_unistd.h /opt/aarch64-w64-mingw32/include/
7593
cp /opt/x86_64-w64-mingw32/include/pthread_time.h /opt/aarch64-w64-mingw32/include/
7694
7795
- name: Build ${{ inputs.package_name }}
78-
working-directory: ${{ github.workspace }}/MSYS2-packages/${{ inputs.package_name }}
96+
working-directory: ${{ github.workspace }}/packages/${{ inputs.package_name }}
7997
run: |
80-
makepkg --syncdeps --rmdeps --cleanbuild --noconfirm --noprogressbar --nocheck --force
98+
if [[ "${{ inputs.packages_repository }}" == *MINGW* ]]; then
99+
command="makepkg-mingw"
100+
else
101+
command="makepkg"
102+
fi
103+
MINGW_ARCH=mingw64 \
104+
$command --syncdeps --rmdeps --cleanbuild --skippgpcheck --noconfirm --noprogressbar --nocheck --force
81105
82106
- name: Upload ${{ inputs.package_name }}
83107
uses: actions/upload-artifact@v4
84108
with:
85109
name: ${{ inputs.package_name }}
86110
retention-days: 1
87-
path: ${{ github.workspace }}/MSYS2-packages/${{ inputs.package_name }}/*.pkg.tar.zst
111+
path: ${{ github.workspace }}/packages/${{ inputs.package_name }}/*.pkg.tar.zst

.github/workflows/check-repository.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ jobs:
2121
- name: Checkout repository
2222
uses: actions/checkout@v4
2323

24+
- name: Setup packages repository
25+
run: |
26+
`cygpath "${{ github.workspace }}"`/.github/scripts/setup-repository.sh
27+
2428
- name: Install toolchain
2529
run: |
26-
`cygpath "${{ github.workspace }}"`/.github/scripts/install-toolchain.sh
30+
pacman -S mingw-w64-cross-gcc --noconfirm
2731
2832
- name: Build hello-world.exe
2933
run: |

.github/workflows/ffmpeg.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build MinGW FFmpeg using MSYS2 toolchain
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
mingw_packages_branch:
8+
description: "MINGW-packages branch to build"
9+
type: string
10+
required: false
11+
default: "woarm64"
12+
13+
jobs:
14+
mingw-w64-ffmpeg:
15+
uses: ./.github/workflows/build-package.yml
16+
with:
17+
package_name: mingw-w64-ffmpeg
18+
packages_repository: Windows-on-ARM-Experiments/MINGW-packages
19+
packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }}
20+
cross_compile: true
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build MinGW libjpeg-turbo using MSYS2 toolchain
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
mingw_packages_branch:
8+
description: "MINGW-packages branch to build"
9+
type: string
10+
required: false
11+
default: "woarm64"
12+
13+
jobs:
14+
mingw-w64-libjpeg-turbo:
15+
uses: ./.github/workflows/build-package.yml
16+
with:
17+
package_name: mingw-w64-libjpeg-turbo
18+
packages_repository: Windows-on-ARM-Experiments/MINGW-packages
19+
packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }}
20+
cross_compile: true

.github/workflows/main.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
87
workflow_dispatch:
98
inputs:
109
msys2_packages_branch:
@@ -18,31 +17,35 @@ jobs:
1817
uses: ./.github/workflows/build-package.yml
1918
with:
2019
package_name: mingw-w64-cross-headers
21-
msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
20+
packages_repository: Windows-on-ARM-Experiments/MSYS2-packages
21+
packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
2222

2323
mingw-w64-cross-binutils:
2424
needs: mingw-w64-cross-headers
2525
uses: ./.github/workflows/build-package.yml
2626
with:
2727
package_name: mingw-w64-cross-binutils
2828
needs: ${{ toJson(needs) }}
29-
msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
29+
packages_repository: Windows-on-ARM-Experiments/MSYS2-packages
30+
packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
3031

3132
mingw-w64-cross-gcc-stage1:
3233
needs: [mingw-w64-cross-headers, mingw-w64-cross-binutils]
3334
uses: ./.github/workflows/build-package.yml
3435
with:
3536
package_name: mingw-w64-cross-gcc-stage1
3637
needs: ${{ toJson(needs) }}
37-
msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
38+
packages_repository: Windows-on-ARM-Experiments/MSYS2-packages
39+
packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
3840

3941
mingw-w64-cross-windows-default-manifest:
4042
needs: [mingw-w64-cross-binutils, mingw-w64-cross-gcc-stage1]
4143
uses: ./.github/workflows/build-package.yml
4244
with:
4345
package_name: mingw-w64-cross-windows-default-manifest
4446
needs: ${{ toJson(needs) }}
45-
msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
47+
packages_repository: Windows-on-ARM-Experiments/MSYS2-packages
48+
packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
4649

4750
mingw-w64-cross-crt:
4851
needs:
@@ -56,7 +59,8 @@ jobs:
5659
package_name: mingw-w64-cross-crt
5760
needs: ${{ toJson(needs) }}
5861
dependencies: mingw-w64-cross-winpthreads
59-
msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
62+
packages_repository: Windows-on-ARM-Experiments/MSYS2-packages
63+
packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
6064

6165
mingw-w64-cross-winpthreads:
6266
needs:
@@ -70,7 +74,8 @@ jobs:
7074
with:
7175
package_name: mingw-w64-cross-winpthreads
7276
needs: ${{ toJson(needs) }}
73-
msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
77+
packages_repository: Windows-on-ARM-Experiments/MSYS2-packages
78+
packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
7479

7580
mingw-w64-cross-gcc:
7681
needs:
@@ -86,7 +91,8 @@ jobs:
8691
with:
8792
package_name: mingw-w64-cross-gcc
8893
needs: ${{ toJson(needs) }}
89-
msys2_packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
94+
packages_repository: Windows-on-ARM-Experiments/MSYS2-packages
95+
packages_branch: ${{ github.event.inputs.msys2_packages_branch || 'woarm64' }}
9096

9197
repository:
9298
needs:

.github/workflows/openblas.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build MinGW OpenBLAS using MSYS2 toolchain
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
mingw_packages_branch:
8+
description: "MINGW-packages branch to build"
9+
type: string
10+
required: false
11+
default: "woarm64"
12+
13+
jobs:
14+
mingw-w64-openblas:
15+
uses: ./.github/workflows/build-package.yml
16+
with:
17+
package_name: mingw-w64-openblas
18+
packages_repository: Windows-on-ARM-Experiments/MINGW-packages
19+
packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }}
20+
cross_compile: true

.github/workflows/openssl.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build MinGW OpenSSL using MSYS2 toolchain
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
mingw_packages_branch:
8+
description: "MINGW-packages branch to build"
9+
type: string
10+
required: false
11+
default: "woarm64"
12+
13+
jobs:
14+
mingw-w64-openssl:
15+
uses: ./.github/workflows/build-package.yml
16+
with:
17+
package_name: mingw-w64-openssl
18+
packages_repository: Windows-on-ARM-Experiments/MINGW-packages
19+
packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }}
20+
dependencies: mingw-w64-cross-zlib
21+
cross_compile: true
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
diff --git a/etc/makepkg_mingw.conf b/etc/makepkg_mingw.conf
2+
--- a/etc/makepkg_mingw.conf
3+
+++ b/etc/makepkg_mingw.conf
4+
@@ -34,15 +34,17 @@
5+
#
6+
7+
if [[ "$MSYSTEM" == "MINGW64" ]]; then
8+
- CARCH="x86_64"
9+
+ CARCH="aarch64"
10+
CHOST="x86_64-w64-mingw32"
11+
MINGW_CHOST="x86_64-w64-mingw32"
12+
MINGW_PREFIX="/mingw64"
13+
MINGW_PACKAGE_PREFIX="mingw-w64-x86_64"
14+
- CC="gcc"
15+
- CXX="g++"
16+
+ CC="aarch64-w64-mingw32-gcc"
17+
+ CXX="aarch64-w64-mingw32-g++"
18+
+ STRIP="aarch64-w64-mingw32-strip"
19+
+ OBJDUMP="aarch64-w64-mingw32-objdump"
20+
CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1"
21+
- CFLAGS="-march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong"
22+
+ CFLAGS="-O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong"
23+
CXXFLAGS="$CFLAGS"
24+
LDFLAGS=""
25+
elif [[ "$MSYSTEM" == "MINGW32" ]]; then
26+
diff --git a/etc/profile b/etc/profile
27+
--- a/etc/profile
28+
+++ b/etc/profile
29+
@@ -49,7 +49,7 @@
30+
case "${MSYSTEM}" in
31+
MINGW*|CLANG*|UCRT*)
32+
MINGW_MOUNT_POINT="${MINGW_PREFIX}"
33+
- PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
34+
+ PATH="/opt/bin:${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
35+
PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
36+
PKG_CONFIG_SYSTEM_INCLUDE_PATH="${MINGW_MOUNT_POINT}/include"
37+
PKG_CONFIG_SYSTEM_LIBRARY_PATH="${MINGW_MOUNT_POINT}/lib"
38+
diff --git a/usr/share/makepkg/tidy/strip.sh b/usr/share/makepkg/tidy/strip.sh
39+
--- a/usr/share/makepkg/tidy/strip.sh
40+
+++ b/usr/share/makepkg/tidy/strip.sh
41+
@@ -85,7 +85,7 @@
42+
strip_file(){
43+
local binary=$1; shift
44+
local tempfile=$(mktemp "$binary.XXXXXX")
45+
- if strip "$@" "$binary" -o "$tempfile"; then
46+
+ if $STRIP "$@" "$binary" -o "$tempfile"; then
47+
cat "$tempfile" > "$binary"
48+
fi
49+
rm -f "$tempfile"
50+
@@ -95,7 +95,7 @@
51+
local binary=$1;
52+
53+
local tempfile=$(mktemp "$binary.XXXXXX")
54+
- if strip -R .gnu.lto_* -R .gnu.debuglto_* -N __gnu_lto_v1 "$binary" -o "$tempfile"; then
55+
+ if $STRIP -R .gnu.lto_* -R .gnu.debuglto_* -N __gnu_lto_v1 "$binary" -o "$tempfile"; then
56+
cat "$tempfile" > "$binary"
57+
fi
58+
rm -f "$tempfile"
59+
@@ -176,7 +176,7 @@
60+
case "${binary##*/}" in
61+
*.dll|*.exe|*.sfx|*.so|*.so.[0-9]*|*.oct|*.cmxs) ;;
62+
# make sure this isn't some oddly named DLL
63+
- *) if LANG=en_US.UTF-8 LC_ALL=C objdump -f "${binary}" | grep -Eq '^start address 0x(0000000[01])?00401[0-9a-e][0-9a-e]0'
64+
+ *) if LANG=en_US.UTF-8 LC_ALL=C $OBJDUMP -f "${binary}" | grep -Eq '^start address 0x(0000000[01])?00401[0-9a-e][0-9a-e]0'
65+
then
66+
mv "${binary}" "${binary}.exe"
67+
binary+=.exe

0 commit comments

Comments
 (0)