Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
.llvm
vendor
node_modules
*.o
*.a
build/
12 changes: 11 additions & 1 deletion Docker/dev/ubuntu-22.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common gnupg \
&& add-apt-repository -y ppa:ondrej/php \
&& apt-get update && apt-get install -y --no-install-recommends \
git curl unzip ca-certificates \
git curl unzip ca-certificates dpkg \
php8.2-cli php8.2-mbstring php8.2-xml php8.2-ffi php8.2-posix php8.2-phar \
php8.2-tokenizer php8.2-dom php8.2-xmlwriter \
build-essential clang llvm-14-dev libjansson4 \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Pre-install LLVM 9 toolchain for JIT/AOT CI (#237). Build from repo root:
# docker build -f Docker/dev/ubuntu-22.04/Dockerfile -t php-compiler:22.04-dev .
COPY script/install-llvm9.sh /tmp/install-llvm9.sh
RUN chmod +x /tmp/install-llvm9.sh \
&& PHP_COMPILER_LLVM_INSTALL_DIR=/opt/llvm9 /tmp/install-llvm9.sh \
&& rm -f /tmp/install-llvm9.sh

ENV PHP_COMPILER_LLVM_PATH=/opt/llvm9
ENV LD_LIBRARY_PATH=/opt/llvm9

WORKDIR /compiler

CMD ["/bin/bash"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ LOCAL_DEV_IMAGE ?= php-compiler:22.04-dev

.PHONY: docker-build-22
docker-build-22:
docker build -t $(LOCAL_DEV_IMAGE) -t $(PHP_COMPILER_DEV_IMAGE) Docker/dev/ubuntu-22.04
docker build -f Docker/dev/ubuntu-22.04/Dockerfile -t $(LOCAL_DEV_IMAGE) -t $(PHP_COMPILER_DEV_IMAGE) .

# Run full local CI inside Docker (mount repo; harness hosts may need: tar | docker run -i …)
.PHONY: test-docker
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,16 @@ Docker is optional on a normal dev machine. On **Runforge / harness hosts** (no

### Container development (PHP 8.2, Ubuntu 22.04)

Build the dev image once:
Build the dev image once (from the repository root; LLVM 9 is baked into `/opt/llvm9`):

```console
make docker-build-22
# equivalent:
docker build -f Docker/dev/ubuntu-22.04/Dockerfile -t php-compiler:22.04-dev .
```

When you bind-mount the repo, a host `.llvm/` directory (if present) overrides the image toolchain; otherwise `PHP_COMPILER_LLVM_PATH` defaults to `/opt/llvm9` and JIT/AOT tests run without re-downloading.

Run the full local CI suite inside the container (same as `./script/ci-local.sh` on the host):

```console
Expand Down
10 changes: 6 additions & 4 deletions script/ci-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ fi
"${COMPOSER[@]}" install --no-interaction --ignore-platform-reqs 2>/dev/null || true

chmod +x script/install-llvm9.sh script/apply-patches.sh 2>/dev/null || true
if [[ -x script/install-llvm9.sh ]]; then
script/install-llvm9.sh || true
if [[ -z "${PHP_COMPILER_LLVM_PATH:-}" || ! -f "${PHP_COMPILER_LLVM_PATH}/libLLVM-9.so.1" ]]; then
if [[ -x script/install-llvm9.sh ]]; then
script/install-llvm9.sh || true
fi
fi
if [[ -x script/apply-patches.sh ]]; then
script/apply-patches.sh || true
Expand All @@ -27,9 +29,9 @@ fi
"$PHP_BIN" "${PHP_OPTS[@]}" script/capability-matrix.php --check
"$PHP_BIN" "${PHP_OPTS[@]}" script/bootstrap-inventory.php --check

LLVM_DIR="$(cd "$(dirname "$0")/.." && pwd)/.llvm"
LLVM_DIR="${PHP_COMPILER_LLVM_PATH:-$(cd "$(dirname "$0")/.." && pwd)/.llvm}"
if [[ -f "$LLVM_DIR/libLLVM-9.so.1" ]]; then
echo "LLVM 9 found: JIT compliance, AOT fixtures (simple_web_*, static_web), and ExampleWebAotTest will run."
echo "LLVM 9 found at $LLVM_DIR: JIT compliance, AOT fixtures (simple_web_*, static_web), and ExampleWebAotTest will run."
else
echo "LLVM 9 missing: @group llvm tests (JIT, AOT, web AOT) are skipped. Run: script/install-llvm9.sh"
fi
Expand Down
2 changes: 1 addition & 1 deletion script/install-llvm9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Fetch libLLVM-9, clang-9, linker, and crt bits for AOT/JIT on hosts with only LLVM 17+.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
LLVM_DIR="$ROOT/.llvm"
LLVM_DIR="${PHP_COMPILER_LLVM_INSTALL_DIR:-$ROOT/.llvm}"
DEB_BASE="http://deb.debian.org/debian/pool/main/l/llvm-toolchain-9"
BINUTILS_BASE="http://deb.debian.org/debian/pool/main/b/binutils"
GCC9_BASE="http://deb.debian.org/debian/pool/main/g/gcc-9"
Expand Down
20 changes: 15 additions & 5 deletions script/php-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,22 @@ if ! command -v "$PHP_BIN" >/dev/null 2>&1; then
done
fi
export PHP_COMPILER_EXT_DIR="${PHP_COMPILER_EXT_DIR:-/usr/lib/php/20220829}"
LLVM_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/.llvm"
if [[ -f "$LLVM_DIR/libLLVM-9.so.1" ]]; then
export LD_LIBRARY_PATH="$LLVM_DIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export PATH="$LLVM_DIR${PATH:+:$PATH}"
export PHP_COMPILER_LLVM_PATH="$LLVM_DIR"
_REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
_REPO_LLVM="$_REPO_ROOT/.llvm"
_LLVM_DIR=""
if [[ -f "$_REPO_LLVM/libLLVM-9.so.1" ]]; then
_LLVM_DIR="$_REPO_LLVM"
elif [[ -n "${PHP_COMPILER_LLVM_PATH:-}" && -f "${PHP_COMPILER_LLVM_PATH}/libLLVM-9.so.1" ]]; then
_LLVM_DIR="$PHP_COMPILER_LLVM_PATH"
elif [[ -f /opt/llvm9/libLLVM-9.so.1 ]]; then
_LLVM_DIR=/opt/llvm9
fi
if [[ -n "$_LLVM_DIR" ]]; then
export LD_LIBRARY_PATH="$_LLVM_DIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export PATH="$_LLVM_DIR${PATH:+:$PATH}"
export PHP_COMPILER_LLVM_PATH="$_LLVM_DIR"
fi
unset _REPO_ROOT _REPO_LLVM _LLVM_DIR
EXT_DIR="$PHP_COMPILER_EXT_DIR"
PHP_OPTS=()
if [[ -d "$EXT_DIR" ]]; then
Expand Down
Loading