Skip to content

Commit b3275f1

Browse files
committed
Add steps for testing the jit with arm64 architecture in docker
1 parent 88371fb commit b3275f1

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Force this to build with arm64 even when the host architecture is different.
2+
# This requires that cross-compilation support be enabled with the steps in https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
3+
FROM --platform=arm64 ubuntu:20.04
4+
RUN apt-get update -y
5+
# DEBIAN_FRONTEND=noninteractive is needed to stop the tzdata installation from hanging.
6+
ENV DEBIAN_FRONTEND=noninteractive
7+
RUN apt-get install -y tzdata
8+
RUN apt-get install -y pkg-config build-essential autoconf bison re2c \
9+
libxml2-dev libsqlite3-dev
10+
11+
ADD . /php-src/
12+
WORKDIR /php-src
13+
RUN ./buildconf
14+
# Compile a minimal debug build. --enable-debug adds runtime assertions and is slower than regular builds.
15+
RUN ./configure --enable-debug --disable-all --enable-opcache && make clean && make -j$(nproc)

ext/opcache/jit/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,26 @@ make -j$(nproc)
114114
#### Running tests of the JIT on 32-bit builds
115115

116116
See the section "Running tests of the JIT".
117+
118+
### Testing the jit with arm64 on x86 computers
119+
120+
https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
121+
may be useful for local development.
122+
123+
Note that this is slower than compiling and testing natively.
124+
125+
```
126+
# After following steps in https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
127+
cp .gitignore .dockerignore
128+
echo .git >> .dockerignore
129+
130+
docker build --network=host -t php-src-arm64-example -f ext/opcache/jit/Dockerfile.arm64.example .
131+
docker run -it --rm php-src-arm64-example
132+
```
133+
134+
Then, the docker image can be used to run tests with `make test`.
135+
For example, to test `ext/opcache` in parallel with the tracing JIT enabled:
136+
137+
```
138+
docker run -it php-src-arms-example make test TESTS="-d opcache.jit_buffer_size=16M -d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.protect_memory=1 -d opcache.jit=tracing --repeat 2 --show-diff -j$(nproc) ext/opcache"
139+
```

0 commit comments

Comments
 (0)