Skip to content

Commit dea266b

Browse files
authored
Experimental support for ARM64 (#1086)
1 parent 446b469 commit dea266b

12 files changed

Lines changed: 187 additions & 50 deletions

File tree

.ci/Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
ifeq ($(DOCKERFILE),)
22
ifeq ($(BUILD_ARCHITECTURE), linuxmusl-x86-64)
33
DOCKERFILE := Dockerfile.alpine
4+
else ifeq ($(BUILD_ARCHITECTURE), linuxmusl-arm64)
5+
DOCKERFILE := Dockerfile.alpine
46
else
57
DOCKERFILE := Dockerfile
68
endif
79
endif
810

11+
DOCKER_PLATFORM := linux/x86_64
12+
ifeq ($(BUILD_ARCHITECTURE), linux-arm64)
13+
DOCKER_PLATFORM := linux/arm64
14+
else ifeq ($(BUILD_ARCHITECTURE), linuxmusl-arm64)
15+
DOCKER_PLATFORM := linux/arm64
16+
endif
17+
18+
919
SHELL=/bin/bash -o pipefail
1020
MAKEFLAGS += --no-print-directory
1121
IMAGE := test-php
@@ -45,6 +55,7 @@ prepare: ## Build docker image for building and testing the project
4555
docker build \
4656
--build-arg PHP_VERSION=${PHP_VERSION} --build-arg SEL_DISTRO=${SEL_DISTRO}\
4757
--tag $(IMAGE):${PHP_VERSION}$(SUFFIX) \
58+
--platform $(DOCKER_PLATFORM) \
4859
-f ${DOCKERFILE} .
4960
@echo "::endgroup::"
5061

@@ -59,8 +70,8 @@ build:
5970
-w /source/agent/native \
6071
-e CONAN_USER_HOME=$(CONAN_USER_HOME) \
6172
elasticobservability/apm-agent-php-dev:native-build-gcc-12.2.0-$(BUILD_ARCHITECTURE)-0.0.2 \
62-
sh -c "cmake --preset $(BUILD_ARCHITECTURE)-release \
63-
&& cmake --build --preset $(BUILD_ARCHITECTURE)-release -j$(nproc)\
73+
sh -c "cmake --preset $(BUILD_ARCHITECTURE)-release \
74+
&& cmake --build --preset $(BUILD_ARCHITECTURE)-release \
6475
&& ctest --preset $(BUILD_ARCHITECTURE)-release --verbose"
6576
@echo "::endgroup::"
6677

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
3+
# Runs the build based on the provided files in test.yml
4+
name: build
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
build_arch:
10+
required: true
11+
type: string
12+
default: 'x86_64'
13+
outputs:
14+
matrix-combinations:
15+
description: "Matrix of architectures to build for"
16+
value: ${{ jobs.setup-build-matrix.outputs.matrix-combinations }}
17+
18+
jobs:
19+
setup-build-matrix:
20+
name: setup-build-matrix
21+
runs-on: ubuntu-latest
22+
env:
23+
SELECTED_ARCH: ${{ inputs.build_arch }}
24+
outputs:
25+
matrix-combinations: ${{ steps.setup-matrix-combinations.outputs.matrix-combinations }}
26+
steps:
27+
- name: Create build matrix
28+
id: setup-matrix-combinations
29+
run: |
30+
MATRIX=''
31+
if [ "${SELECTED_ARCH}" == "x86_64" ] || [ "${SELECTED_ARCH}" == "all" ]; then
32+
echo "${SELECTED_ARCH} selected. Adding x86_64"
33+
MATRIX+='{"arch": "linux-x86-64"}, {"arch": "linuxmusl-x86-64"}'
34+
fi
35+
if [ "${SELECTED_ARCH}" == "arm64" ] || [ "${SELECTED_ARCH}" == "all" ]; then
36+
echo "${SELECTED_ARCH} selected. Adding arm64"
37+
if [ ! -z "${MATRIX}" ]; then
38+
MATRIX+=','
39+
fi
40+
MATRIX+='{"arch": "linux-arm64", "run_qemu": 1},{"arch": "linuxmusl-arm64", "run_qemu": 1}'
41+
fi
42+
echo "matrix-combinations={\"include\":[$MATRIX]}"
43+
44+
echo "matrix-combinations={\"include\":[$MATRIX]}" >> $GITHUB_OUTPUT

.github/workflows/build-packages.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,28 @@ jobs:
1313
runs-on: ubuntu-latest
1414
permissions:
1515
packages: read
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
BUILD_ARCH: ["x86-64", "arm64"]
20+
env:
21+
BUILD_ARCH: ${{ matrix.BUILD_ARCH }}
1622
steps:
1723
- uses: actions/checkout@v4
1824
- uses: actions/download-artifact@v3
1925
with:
20-
name: package-parts-linux-x86-64
21-
path: agent/native/_build/linux-x86-64-release/
26+
name: package-parts-linux-${{ matrix.BUILD_ARCH }}
27+
path: agent/native/_build/linux-${{ matrix.BUILD_ARCH }}-release/
2228
- uses: actions/download-artifact@v3
2329
with:
24-
name: package-parts-linuxmusl-x86-64
25-
path: agent/native/_build/linuxmusl-x86-64-release/
26-
30+
name: package-parts-linuxmusl-${{ matrix.BUILD_ARCH }}
31+
path: agent/native/_build/linuxmusl-${{ matrix.BUILD_ARCH }}-release/
2732
- name: Log in to the Container registry
2833
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
2934
with:
3035
registry: ghcr.io
3136
username: ${{ github.actor }}
3237
password: ${{ secrets.GITHUB_TOKEN }}
33-
3438
- name: package
3539
run: make -C packaging package
3640
- name: package info

.github/workflows/build.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,54 @@
44
name: build
55

66
on:
7-
workflow_call: ~
7+
workflow_call:
8+
inputs:
9+
build_arch:
10+
required: false
11+
type: string
12+
default: 'x86_64'
13+
workflow_dispatch:
14+
inputs:
15+
build_arch:
16+
type: choice
17+
description: Build architecture
18+
default: 'x86_64'
19+
options:
20+
- all
21+
- x86_64
22+
- arm64
823

924
permissions:
1025
contents: read
1126

1227
jobs:
28+
setup-build-matrix:
29+
uses: ./.github/workflows/build-arch-matrix-generator.yml
30+
with:
31+
build_arch: ${{ inputs.build_arch }}
32+
1333
build:
1434
name: build-agent-library
1535
runs-on: ubuntu-latest
16-
timeout-minutes: 30
36+
needs: setup-build-matrix
37+
timeout-minutes: 300
1738
strategy:
1839
fail-fast: false
19-
matrix:
20-
arch:
21-
- "linux-x86-64"
22-
- "linuxmusl-x86-64"
40+
matrix: ${{ fromJson(needs.setup-build-matrix.outputs.matrix-combinations) }}
2341
env:
2442
BUILD_ARCHITECTURE: ${{ matrix.arch }}
2543
steps:
2644
- uses: actions/checkout@v4
45+
- if: ${{ matrix.run_qemu }}
46+
uses: docker/setup-qemu-action@v3
47+
with:
48+
platforms: arm64
2749
- name: Build
28-
run: make -f .ci/Makefile build
50+
run: |
51+
uname -a
52+
echo "Detected CPUs: $(nproc)"
53+
make -f .ci/Makefile build
54+
2955
- uses: actions/upload-artifact@v3
3056
with:
3157
name: package-parts-${{ matrix.arch }}

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ permissions:
55
contents: read
66

77
on:
8+
workflow_dispatch: ~
89
push:
910
tags: [ "v[0-9]+*" ]
1011
branches:
@@ -28,6 +29,8 @@ jobs:
2829
2930
build:
3031
uses: ./.github/workflows/build.yml
32+
with:
33+
build_arch: all
3134

3235
build-packages:
3336
permissions:

.github/workflows/test-packages.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ jobs:
7373
name: package-parts-linuxmusl-x86-64
7474
path: agent/native/_build/linuxmusl-x86-64-release
7575

76+
- name: Remove ARM64 artifacts
77+
run: |
78+
rm ${BUILD_PACKAGES}/apm-agent-php*arm64*
79+
rm ${BUILD_PACKAGES}/apm-agent-php*aarch64*
80+
7681
- if: ${{ env.TESTING_TYPE == 'lifecycle' }}
7782
name: lifecycle test
7883
run: |

.github/workflows/test.yml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: test
22

33
on:
4+
workflow_call:
5+
inputs:
6+
build_arch:
7+
required: true
8+
type: string
9+
default: 'all'
410
pull_request:
511
paths-ignore:
612
- "**/*.asciidoc"
@@ -26,13 +32,21 @@ concurrency:
2632
jobs:
2733
build:
2834
uses: ./.github/workflows/build.yml
35+
with:
36+
build_arch: all
37+
38+
setup-build-matrix:
39+
uses: ./.github/workflows/build-arch-matrix-generator.yml
40+
with:
41+
build_arch: all
2942

3043
phpt-tests:
3144
name: phpt-tests
3245
runs-on: ubuntu-latest
3346
needs:
3447
- build
35-
timeout-minutes: 10
48+
- setup-build-matrix
49+
timeout-minutes: 120
3650
strategy:
3751
fail-fast: false
3852
matrix:
@@ -44,25 +58,27 @@ jobs:
4458
- "8.1"
4559
- "8.2"
4660
- "8.3"
47-
arch:
48-
- "linux-x86-64"
49-
- "linuxmusl-x86-64"
61+
data: ${{ fromJson(needs.setup-build-matrix.outputs.matrix-combinations).include }}
5062
env:
5163
PHP_VERSION: ${{ matrix.php-version }}
52-
BUILD_ARCHITECTURE: ${{ matrix.arch }}
64+
BUILD_ARCHITECTURE: ${{ matrix.data.arch }}
5365
steps:
5466
- uses: actions/checkout@v4
55-
- name: Prepare
56-
run: make -f .ci/Makefile prepare
5767
- uses: actions/download-artifact@v3
5868
with:
59-
name: package-parts-${{ matrix.arch }}
60-
path: agent/native/_build/${{ matrix.arch }}-release/
61-
- name: Display structure of downloaded files
62-
run: ls -R
69+
name: package-parts-${{ matrix.data.arch }}
70+
path: agent/native/_build/${{ matrix.data.arch }}-release/
71+
- if: ${{ matrix.data.run_qemu }}
72+
uses: docker/setup-qemu-action@v3
73+
with:
74+
platforms: arm64
75+
- name: Prepare
76+
run: make -f .ci/Makefile prepare
6377
- name: phpt-unit-tests
64-
run: make -f .ci/Makefile run-phpt-tests
65-
78+
run: |
79+
tree agent/native/_build/
80+
uname -a
81+
make -f .ci/Makefile run-phpt-tests
6682
static-checks-unit-tests:
6783
name: static-checks-unit-tests
6884
runs-on: ubuntu-latest

agent/native/ext/constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#pragma once
2121

22+
2223
#include "basic_macros.h"
2324
#include "elastic_apm_assert.h"
2425

docs/setup.asciidoc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ endif::[]
1111
=== Prerequisites
1212

1313
[discrete]
14-
==== Operating system
15-
The agent is currently only available for the Linux operating system.
14+
==== Operating system and architecture
15+
We officially support Linux systems (glibc, deb and rpm packages) and Alpine Linux (musl libc - apk packages) for x86_64 (AMD64) processors.
16+
17+
NOTE: Experimentally, we also provide packages for the ARM64 architecture - please note that these packages have not been fully tested.
1618

1719
[discrete]
1820
==== PHP
19-
The agent supports PHP versions 7.2-8.2.
21+
The agent supports PHP versions 7.2-8.3.
2022

2123
[discrete]
2224
==== curl

docs/supported-technologies.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ We will use the results to add support for the most requested technologies.
1414
[[supported-os]]
1515
=== Operating systems
1616

17-
The agent supports Linux operating system.
17+
We officially support Linux systems (glibc, deb and rpm packages) and Alpine Linux (musl libc - apk packages) for x86_64 (AMD64) processors.
18+
Experimentally, we also provide packages for the ARM64 architecture - please note that these packages have not been fully tested.
1819

1920
[float]
2021
[[supported-php-versions]]

0 commit comments

Comments
 (0)