Skip to content

Commit c19e512

Browse files
authored
Merge pull request #5 from TEN-framework/fix/linux_arm64
fix: use QEMU for Linux ARM64 builds to avoid runner wait time
2 parents 60ef3a1 + 7d66fc3 commit c19e512

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

.github/workflows/build_node_shared.yml

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ jobs:
2828
container: ghcr.io/ten-framework/ten_building_ubuntu2204
2929
lib_name: libnode.so.127
3030
nproc_cmd: nproc
31-
# Linux ARM64 builds
32-
- os: ubuntu-latest-arm
31+
# Linux ARM64 builds (using QEMU)
32+
- os: ubuntu-latest
3333
platform: linux
3434
arch: arm64
3535
compiler: gcc
36-
container: ghcr.io/ten-framework/ten_building_ubuntu2204
36+
container: ""
3737
lib_name: libnode.so.127
3838
nproc_cmd: nproc
39-
- os: ubuntu-latest-arm
39+
- os: ubuntu-latest
4040
platform: linux
4141
arch: arm64
4242
compiler: clang
43-
container: ghcr.io/ten-framework/ten_building_ubuntu2204
43+
container: ""
4444
lib_name: libnode.so.127
4545
nproc_cmd: nproc
4646
# macOS x64 builds
@@ -72,13 +72,50 @@ jobs:
7272
repository: nodejs/node
7373
ref: v22.12.0
7474

75+
- name: Create out directory (Linux ARM64)
76+
if: matrix.platform == 'linux' && matrix.arch == 'arm64'
77+
run: |
78+
# Due to the use of QEMU, running as root inside the Docker container
79+
# is required. However, outside the container, the user is not root.
80+
# This causes issues when trying to handle the contents of the out/
81+
# folder from outside the container. To resolve this, the out/ folder
82+
# is first created by a regular non-root user to prevent it from being
83+
# created during the build stage, thus avoiding permission issues with
84+
# the out/ folder being created by the root user.
85+
mkdir -p out/Release
86+
87+
- name: Set up QEMU (Linux ARM64)
88+
if: matrix.platform == 'linux' && matrix.arch == 'arm64'
89+
uses: docker/setup-qemu-action@v3
90+
with:
91+
platforms: arm64
92+
7593
- name: Setup Python (macOS)
7694
if: matrix.platform == 'mac'
7795
uses: actions/setup-python@v5
7896
with:
7997
python-version: '3.11'
8098

81-
- name: Configure and Build
99+
- name: Configure and Build (Linux ARM64 with QEMU)
100+
if: matrix.platform == 'linux' && matrix.arch == 'arm64'
101+
run: |
102+
docker run --rm --platform linux/arm64 \
103+
-v $(pwd):${{ github.workspace }} -w ${{ github.workspace }} \
104+
ghcr.io/ten-framework/ten_building_ubuntu2204 \
105+
bash -c "
106+
if [ '${{ matrix.compiler }}' = 'gcc' ]; then
107+
export CC=gcc
108+
export CXX=g++
109+
else
110+
export CC=clang
111+
export CXX=clang++
112+
fi && \
113+
./configure --shared && \
114+
make -j\$(nproc)
115+
"
116+
117+
- name: Configure and Build (Linux x64 and macOS)
118+
if: matrix.platform != 'linux' || matrix.arch != 'arm64'
82119
run: |
83120
if [ "${{ matrix.compiler }}" = "gcc" ]; then
84121
export CC=gcc
@@ -92,6 +129,11 @@ jobs:
92129
93130
make -j$(${{ matrix.nproc_cmd }})
94131
132+
- name: Fix permissions for build outputs (Linux ARM64)
133+
if: matrix.platform == 'linux' && matrix.arch == 'arm64'
134+
run: |
135+
sudo chown -R "$(id -u)":"$(id -g)" out/Release
136+
95137
- name: Package assets
96138
if: startsWith(github.ref, 'refs/tags/')
97139
run: |

0 commit comments

Comments
 (0)