Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing build regression [BISON COMPILE] #871

Closed
wants to merge 25 commits into from

Conversation

seanmorris
Copy link
Contributor

@seanmorris seanmorris commented Dec 14, 2023

What is this PR doing?

This installs the necessary version of Bison in a separate docker image and uses that image as a base image for the PHP build. This allows us to only build Bison twice: once for v2.7 and again for v3.

What problem is it solving?

Currently Bison 2.7 isn't installing correctly and thus we cannot build PHP <=7.3.

ARG BISON_VERSION
FROM playground-php-wasm:bison${BISON_VERSION}

How is the problem addressed?

  • Installs the necessary version of Bison in a separate docker image and uses that image as a base image for the PHP build.

Testing Instructions

Checkout the branch & install the dependencies:

git checkout sm-fixing-build-regression
npm install

Run the build and ensure it succeeds:

npm run recompile:php:node
npm run recompile:php:web

Start the dev server:

npm run dev

Then, navigate to:

... and ensure that wordpress works as-expected in each environment.

@seanmorris seanmorris changed the title [DRAFT] Fixing build regression for PHP <=7.3 Fixing build regression for PHP <=7.3 Dec 15, 2023
@seanmorris seanmorris added [Type] Bug An existing feature does not function as intended [Feature] PHP.wasm labels Dec 15, 2023
@seanmorris seanmorris self-assigned this Dec 17, 2023
@seanmorris seanmorris requested a review from dmsnell December 17, 2023 16:52
@adamziel
Copy link
Collaborator

I tried running the updated build script and ran into the following errors:

(Reading database ... 17310 files and directories currently installed.)
#20 2.045 Preparing to unpack .../bison_2%3a3.8.2+dfsg-1build1_arm64.deb ...
#20 2.047 Unpacking bison (2:3.8.2+dfsg-1build1) ...
#20 2.073 dpkg: error processing archive /root/libbison-dev_2.7.1.dfsg-1_amd64.deb (--unpack):
#20 2.073  package architecture (amd64) does not match system (arm64)
#20 2.079 Errors were encountered while processing:
#20 2.079  /root/libbison-dev_2.7.1.dfsg-1_amd64.deb
#20 2.092 E: Sub-process /usr/bin/dpkg returned an error code (1)
#20 2.097
#20 2.097 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#20 2.097
#20 2.115 Reading package lists...
#20 2.489 Building dependency tree...
#20 2.570 Reading state information...
#20 2.617 Some packages could not be installed. This may mean that you have
#20 2.617 requested an impossible situation or if you are using the unstable
#20 2.617 distribution that some required packages have not yet been created
#20 2.617 or been moved out of Incoming.
#20 2.617 The following information may help to resolve the situation:
#20 2.617
#20 2.617 The following packages have unmet dependencies:
#20 2.684  bison:amd64 : Depends: libc6:amd64 (>= 2.15) but it is not installable
#20 2.684                Depends: libbison-dev:amd64 (= 2:2.7.1.dfsg-1) but it is not installable
#20 2.692 E: Unable to correct problems, you have held broken packages.
#20 3.095 libbison-dev set on hold.
#20 3.469 bison set on hold.

I expected the build to stop at this point, but it kept going.

@seanmorris seanmorris changed the title Fixing build regression for PHP <=7.3 Fixing build regression Dec 18, 2023
@seanmorris seanmorris requested a review from adamziel December 18, 2023 13:41
@seanmorris
Copy link
Contributor Author

seanmorris commented Dec 19, 2023

I tried running the updated build script and ran into the following errors:

(Reading database ... 17310 files and directories currently installed.)
#20 2.045 Preparing to unpack .../bison_2%3a3.8.2+dfsg-1build1_arm64.deb ...
#20 2.047 Unpacking bison (2:3.8.2+dfsg-1build1) ...
#20 2.073 dpkg: error processing archive /root/libbison-dev_2.7.1.dfsg-1_amd64.deb (--unpack):
#20 2.073  package architecture (amd64) does not match system (arm64)
#20 2.079 Errors were encountered while processing:
#20 2.079  /root/libbison-dev_2.7.1.dfsg-1_amd64.deb
#20 2.092 E: Sub-process /usr/bin/dpkg returned an error code (1)
#20 2.097
#20 2.097 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#20 2.097
#20 2.115 Reading package lists...
#20 2.489 Building dependency tree...
#20 2.570 Reading state information...
#20 2.617 Some packages could not be installed. This may mean that you have
#20 2.617 requested an impossible situation or if you are using the unstable
#20 2.617 distribution that some required packages have not yet been created
#20 2.617 or been moved out of Incoming.
#20 2.617 The following information may help to resolve the situation:
#20 2.617
#20 2.617 The following packages have unmet dependencies:
#20 2.684  bison:amd64 : Depends: libc6:amd64 (>= 2.15) but it is not installable
#20 2.684                Depends: libbison-dev:amd64 (= 2:2.7.1.dfsg-1) but it is not installable
#20 2.692 E: Unable to correct problems, you have held broken packages.
#20 3.095 libbison-dev set on hold.
#20 3.469 bison set on hold.

I expected the build to stop at this point, but it kept going.

Thats why we need to maintain a compile step. We can't guarantee that we know what architecture the user will be building on.

I've gone ahead and restored the compilation, and made sure it only builds Bison twice, once for v2.7 and again for v3. I've confirmed the full build works on both arm64 and amd64 machines.

# Must be 2.7 for PHP <= 7.3
# Must be 3 for PHP >= 7.4
ARG BISON_VERSION
FROM playground-php-wasm:bison${BISON_VERSION}
Copy link
Collaborator

@adamziel adamziel Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to compute the bison version in this Dockerfile here instead of in build.js?

Copy link
Contributor Author

@seanmorris seanmorris Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamziel If we do that, we can't cache it and we'll be forced to rebuild on every iteration.

I think we should move as much of this calculation into the build JS as possible, then think about re-ordering the dockerfile with the implicit layer-caching mechanism in mind.

If we can cache the identical steps between different builds, and re-use them, we should be able to get the build to run a lot faster.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that logic lives in build.js, then the Dockerfile is no longer self-contained – you need prior knowledge about the mapping between specific PHP versions and Bison versions to be able to use it. Is there a way to keep that mapping inside the Dockerfile and still benefit from caching?

Copy link
Contributor Author

@seanmorris seanmorris Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamziel Nope. If Docker considers a PHP_VERSION arg that is different from that of a previous build, then the layer-hash will differ and the cache will not be used for that build.

I think that the value we gain from a shorter build is greater than the value we lose from compromising a self-contained dockerfile. Our build system architecture is already relatively highly coupled, and the existing dockerfile already has dependencies it cannot invoke on its own.

I think this still represents a step forward.

Edit: I can put some error-checking logic in to clarify things a bit.

Copy link
Contributor Author

@seanmorris seanmorris Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errors will print in red if incompatible versions are provided:

FROM playground-php-wasm:bison${BISON_VERSION}
ARG BISON_VERSION
ARG PHP_VERSION
RUN set -euxo pipefail; \
if [[ "${PHP_VERSION:0:1}" -le "7" && "${PHP_VERSION:2:1}" -le "3" ]]; then \
if [[ "${BISON_VERSION}" != "2.7" ]]; then \
echo -e "\e[31mBISON_VERSION must be 2.7 for PHP "${PHP_VERSION}". Got" ${BISON_VERSION} "\e[0m"; \
exit 128; \
fi; \
else \
if [[ "${BISON_VERSION}" != "3" ]]; then \
echo -e "\e[31mBISON_VERSION must be 3 for PHP "${PHP_VERSION}". Got" ${BISON_VERSION} "\e[0m"; \
exit 128; \
fi; \
fi;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Docker considers a PHP_VERSION arg that is different from that of a previous build, then the layer-hash will differ and the cache will not be used for that build.

Using the --download-only flag for apt would do the trick here, though. Both Bison 2.7 and Bison 3.0 may then exist in the docker cache as static files, and then a bash if could just plug-in the correct version depending on the PHP_VERSION.

the value we gain from a shorter build

How much shorter is it, though? Are we talking about minutes or seconds?

Our build system architecture is already relatively highly coupled, and the existing dockerfile already has dependencies it cannot invoke on its own.

Oh, interesting, I haven't thought of it like that. What would be an example of such a dependency?

@adamziel
Copy link
Collaborator

adamziel commented Dec 19, 2023

It seems like the bison change may require some more iterations. Would you mind splitting this PR in two? One PR would only fix the paths, as that fix seems urgent. The bison update would make more sense as a separate PR, as it blocks fixing the build regression and is only a quality of life improvement.

@seanmorris seanmorris changed the title [WIP] Fixing build regression [Part II] Fixing build regression [Part II] Dec 20, 2023
@adamziel
Copy link
Collaborator

About this PR's description – it's not really fixing a build regression, right? That's the other PR with the same title. This one seems to be splitting Bison 3 into a separate Dockerfile for speed gains. What is the order of magnitude of the speed increase? Is this one worth pursuing?

@seanmorris
Copy link
Contributor Author

About this PR's description – it's not really fixing a build regression, right? That's the other PR with the same title. This one seems to be splitting Bison 3 into a separate Dockerfile for speed gains. What is the order of magnitude of the speed increase? Is this one worth pursuing?

This fixes Bison 2.7. If thats broken we can't build PHP <=7.3.

@seanmorris seanmorris requested a review from adamziel December 21, 2023 17:23
@adamziel
Copy link
Collaborator

Is Bison 2.7 broken in any way without this PR, though?

@seanmorris
Copy link
Contributor Author

seanmorris commented Dec 21, 2023

Is Bison 2.7 broken in any way without this PR, though?

@adamziel Without it, I'm getting the error below for npm run recompile:php:web:light:7.3. I'm only getting the error on my debian machine, however. Not the macbook.


Fails on:
Git Commit: 30a561d97bdd7dee6674528dfff95c912bc734d3
Docker Version: 24.0.7, build afdd53b
OS: Debian GNU/Linux 12 (bookworm) x86_64
Arch: Amd64 Intel i7-7700K (8)


Works on:
Git Commit: 30a561d97bdd7dee6674528dfff95c912bc734d3
Docker Version: 24.0.7, build afdd53b
OS: macOS 14.1 23B2073 arm64
Arch: Arm64 Apple M3 Max


------
 > [33/66] RUN source /root/emsdk/emsdk_env.sh &&       emconfigure ./configure         PKG_CONFIG_PATH=/root/lib/lib/pkgconfig         --disable-fiber-asm     --enable-json           --enable-embed=static   --with-layout=GNU       --disable-cgi           --disable-all           --enable-hash           --enable-static=yes     --enable-shared=no      --enable-session     --enable-filter         --enable-calendar       --disable-rpath         --disable-phpdbg        --without-pear          --with-valgrind=no      --without-pcre-jit      --enable-bcmath         --enable-ctype          --enable-tokenizer      $(cat /root/.php-configure-flags):
no
7.023 checking for nawk... nawk
7.024 checking if nawk is broken... no
7.025 checking for bison... bison -y
7.025 checking for bison version... invalid
7.029 configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: none, min: 204, excluded: ).
7.030 checking for re2c... re2c
7.030 checking for re2c version... 3.0 (ok)
7.036 configure: error: bison is required to build PHP/Zend when building a GIT checkout!
7.060 emconfigure: error: './configure PKG_CONFIG_PATH=/root/lib/lib/pkgconfig --disable-fiber-asm --enable-json --enable-embed=static --with-layout=GNU --disable-cgi --disable-all --enable-hash --enable-static=yes --enable-shared=no --enable-session --enable-filter --enable-calendar --disable-rpath --disable-phpdbg --without-pear --with-valgrind=no --without-pcre-jit --enable-bcmath --enable-ctype --enable-tokenizer --with-zlib --with-zlib-dir=/root/lib --enable-zip --with-libzip=/root/lib --disable-cli --disable-libxml --without-libxml --disable-dom --disable-xml --disable-simplexml --disable-xmlwriter --with-sqlite3 --enable-pdo --with-pdo-sqlite=/root/lib --disable-mbstring --disable-mbregex' failed (returned 1)
------
Dockerfile:207
--------------------
 206 |     WORKDIR /root/php-src
 207 | >>> RUN source /root/emsdk/emsdk_env.sh && \
 208 | >>>      emconfigure ./configure \
 209 | >>>      PKG_CONFIG_PATH=$PKG_CONFIG_PATH \
 210 | >>>      # Fibers are a PHP 8.1+ feature. They are compiled as
 211 | >>>      # a custom assembly implementation by default. However,
 212 | >>>      # that implementation does not work with emscripten.
 213 | >>>      #
 214 | >>>      # The line below disables it, forcing PHP to use the
 215 | >>>      # C implementation instead.
 216 | >>>      #
 217 | >>>      # See https://github.com/WordPress/wordpress-playground/issues/92
 218 | >>>      # for more context.
 219 | >>>      --disable-fiber-asm \
 220 | >>>      # --enable-json for PHP < 8.0:
 221 | >>>      --enable-json      \
 222 | >>>      --enable-embed=static \
 223 | >>>      --with-layout=GNU  \
 224 | >>>      --disable-cgi      \
 225 | >>>      --disable-all      \
 226 | >>>      --enable-hash      \
 227 | >>>      --enable-static=yes \
 228 | >>>      --enable-shared=no \
 229 | >>>      --enable-session   \
 230 | >>>      --enable-filter    \
 231 | >>>      --enable-calendar  \
 232 | >>>      --disable-rpath    \
 233 | >>>      --disable-phpdbg   \
 234 | >>>      --without-pear     \
 235 | >>>      --with-valgrind=no \
 236 | >>>      --without-pcre-jit \
 237 | >>>      --enable-bcmath    \
 238 | >>>      --enable-ctype     \
 239 | >>>      --enable-tokenizer \
 240 | >>>      $(cat /root/.php-configure-flags)
 241 |
--------------------
ERROR: failed to solve: process "/bin/bash -c source /root/emsdk/emsdk_env.sh && \temconfigure ./configure \tPKG_CONFIG_PATH=$PKG_CONFIG_PATH \t--disable-fiber-asm \t--enable-json      \t--enable-embed=static \t--with-layout=GNU  \t--disable-cgi      \t--disable-all      \t--enable-hash      \t--enable-static=yes \t--enable-shared=no \t--enable-session   \t--enable-filter    \t--enable-calendar  \t--disable-rpath    \t--disable-phpdbg   \t--without-pear     \t--with-valgrind=no \t--without-pcre-jit \t--enable-bcmath    \t--enable-ctype     \t--enable-tokenizer \t$(cat /root/.php-configure-flags)" did not complete successfully: exit code: 1
file:///home/sean/mattic/wordpress-playground/packages/php-wasm/compile/build.js:253
                        else reject(new Error(`Process exited with code ${code}`));
                                    ^
Error: Process exited with code 1
    at ChildProcess.<anonymous> (file:///home/sean/mattic/wordpress-playground/packages/php-wasm/compile/build.js:253:16)
    at ChildProcess.emit (node:events:514:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
Node.js v20.8.0
Warning: run-commands command "node packages/php-wasm/compile/build.js --PLATFORM=web-light --output-dir=packages/php-wasm/web/public/light --PHP_VERSION=7.3" exited with non-zero status code

 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target recompile-php:light for project php-wasm-web (16s)

         With additional flags:
           --PHP_VERSION=7.3

    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

sean@hyperterminal:~/mattic/wordpress-playground$ 

@seanmorris
Copy link
Contributor Author

seanmorris commented Dec 22, 2023

Similar error on my Debian laptop, but I need to checkout #887 to get to this point:

Git Commit: 956697664a0a7b8a53dcdbf43f9c493aea95d011
Docker Version: 20.10.5+dfsg1, build 55c4c88
OS: Debian GNU/Linux 11 (bullseye) x86_64
Arch: Amd64 Intel i7-7500U (4 cores)

checking if nawk is broken... no
checking for bison... bison -y
checking for bison version... invalid
checking for re2c... configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: none, min: 204, excluded: ).
re2c
checking for re2c version... 3.0 (ok)
configure: error: bison is required to build PHP/Zend when building a GIT checkout!
emconfigure: error: './configure PKG_CONFIG_PATH=/root/lib/lib/pkgconfig --disable-fiber-asm --enable-json --enable-embed=static --with-layout=GNU --disable-cgi --disable-all --enable-hash --enable-static=yes --enable-shared=no --enable-session --enable-filter --enable-calendar --disable-rpath --disable-phpdbg --without-pear --with-valgrind=no --without-pcre-jit --enable-bcmath --enable-ctype --enable-tokenizer --with-zlib --with-zlib-dir=/root/lib --enable-zip --with-libzip=/root/lib --disable-cli --disable-libxml --without-libxml --disable-dom --disable-xml --disable-simplexml --disable-xmlwriter --with-sqlite3 --enable-pdo --with-pdo-sqlite=/root/lib --disable-mbstring --disable-mbregex' failed (returned 1)
The command '/bin/bash -c source /root/emsdk/emsdk_env.sh &&    emconfigure ./configure         PKG_CONFIG_PATH=$PKG_CONFIG_PATH        --disable-fiber-asm    --enable-json           --enable-embed=static   --with-layout=GNU       --disable-cgi           --disable-all           --enable-hash         --enable-static=yes      --enable-shared=no      --enable-session        --enable-filter         --enable-calendar       --disable-rpath         --disable-phpdbg       --without-pear          --with-valgrind=no      --without-pcre-jit      --enable-bcmath         --enable-ctype          --enable-tokenizer     $(cat /root/.php-configure-flags)' returned a non-zero code: 1
file:///home/sean/mattic/wordpress-playground/packages/php-wasm/compile/build.js:253
                        else reject(new Error(`Process exited with code ${code}`));
                                    ^
Error: Process exited with code 1
    at ChildProcess.<anonymous> (file:///home/sean/mattic/wordpress-playground/packages/php-wasm/compile/build.js:253:16)
    at ChildProcess.emit (node:events:517:28)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:303:5)
Node.js v18.19.0
Warning: run-commands command "node packages/php-wasm/compile/build.js --PLATFORM=web-light --output-dir=packages/php-wasm/web/public/light --PHP_VERSION=7.3" exited with non-zero status code


 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target recompile-php:light for project php-wasm-web (22s)

         With additional flags:
           --PHP_VERSION=7.3

    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

@seanmorris seanmorris changed the title Fixing build regression [Part II] Fixing build regression [BISON COMPILE] Dec 22, 2023
@seanmorris
Copy link
Contributor Author

About this PR's description – it's not really fixing a build regression, right? That's the other PR with the same title. This one seems to be splitting Bison 3 into a separate Dockerfile for speed gains. What is the order of magnitude of the speed increase? Is this one worth pursuing?

@adamziel This PR fixes the issue a little more simply. Let me know what you think: #892

@dmsnell
Copy link
Member

dmsnell commented Dec 22, 2023

Since "why does this work?" is a far more terrifying question than "why doesn't this work?"

Couldn't agree more. "Accidentally working" is my biggest fear in software.

seanmorris added a commit that referenced this pull request Dec 26, 2023
## What is this PR doing?

This corrects some paths in the docker file used to copy libraries into
the build image.

## What problem is it solving?

Newer versions of Docker will ignore leading `../` that lead outside of
the build context, but older versions will throw an error in that case.

## How is the problem addressed?

This removes the extra `../` at the start of the paths in question.
Newer versions of docker will ignore `../`s that lead outside of the
build context, but older versions will throw an error. The following
paths will work on later versions but fail on earlier ones:

```
# Bring in the libraries
RUN mkdir -p /root/lib/include /root/lib/lib /libs
COPY ../../../../../../../../../../bison2.7/dist/ /libs/bison2.7
COPY ../../../../../../../../../../libedit/dist/root/lib /root/lib
COPY ../../../../../../../../../../libiconv/dist/root/lib /root/lib
COPY ../../../../../../../../../../libncurses/dist/root/lib /root/lib
COPY ../../../../../../../../../../libopenssl/dist/root/lib /root/lib
COPY ../../../../../../../../../../libpng16/dist/root/lib /root/lib
COPY ../../../../../../../../../../libsqlite3/dist/root/lib /root/lib
COPY ../../../../../../../../../../libxml2/dist/root/lib /root/lib
COPY ../../../../../../../../../../libz/dist/root/lib /root/lib
COPY ../../../../../../../../../../libzip/dist/1.2.0/root/lib /libs/libzip/1.2.0
COPY ../../../../../../../../../../libzip/dist/1.9.2/root/lib /libs/libzip/1.9.2
COPY ../../../../../../../../../../oniguruma/dist/root/lib /root/lib
```

## Testing Instructions

Checkout the branch and pull dependencies:

```
git checkout sm-correcting-build-paths
npm install
```

Build the libraries:
```
cd packages/php-wasm/compile
make clean
make all
```

In a new terminal, build PHP 7.4 - 8.3: (PHP <=7.3 is fixed in
#871)

```
npm run recompile:php:web:light:8.3
npm run recompile:php:web:light:8.2
npm run recompile:php:web:light:8.1
npm run recompile:php:web:light:8.0
npm run recompile:php:web:light:7.4
```
```
npm run recompile:php:web:kitchen-sink:8.3
npm run recompile:php:web:kitchen-sink:8.2
npm run recompile:php:web:kitchen-sink:8.1
npm run recompile:php:web:kitchen-sink:8.0
npm run recompile:php:web:kitchen-sink:7.4
```
```
npm run recompile:php:node:8.3
npm run recompile:php:node:8.2
npm run recompile:php:node:8.1
npm run recompile:php:node:8.0
npm run recompile:php:node:7.4
```

Ensure the build works:

```
npm run build
npm run dev
```

Navigate to the following URLs:

*
http://localhost:5400/website-server/?plugin=web-stories&php-extension-bundle=kitchen-sink&php=8.3
*
http://localhost:5400/website-server/?plugin=web-stories&php-extension-bundle=kitchen-sink&php=8.2
*
http://localhost:5400/website-server/?plugin=web-stories&php-extension-bundle=kitchen-sink&php=8.1
*
http://localhost:5400/website-server/?plugin=web-stories&php-extension-bundle=kitchen-sink&php=8.0
*
http://localhost:5400/website-server/?plugin=web-stories&php-extension-bundle=kitchen-sink&php=7.4
seanmorris added a commit that referenced this pull request Dec 26, 2023
## What is this PR doing?

This PR corrects the same Bison2.7 issue as
#871, in a much
simpler fashion.

## What problem is it solving?

Bison2.7 will not be built in some cases, blocking the build of PHP <=
7.3.

## How is the problem addressed?

This invokes dependency builds before building PHP.

## Testing Instructions

Checkout the branch & install the dependencies:

```
git checkout sm-make-deps-before-compile
npm install
```

In a separate terminal, clear the artifacts:

```bash
docker system prune -af
cd packages/php-wasm/compile
make clean
```

Run the build and ensure it succeeds:

```bash
npm run recompile:php:node
npm run recompile:php:web
```

Start the dev server:

```bash
npm run dev
```

Then, navigate to:

* http://localhost:5400/website-server/?php=8.3
* http://localhost:5400/website-server/?php=8.2
* http://localhost:5400/website-server/?php=8.1
* http://localhost:5400/website-server/?php=8.0
* http://localhost:5400/website-server/?php=7.4
* http://localhost:5400/website-server/?php=7.3
* http://localhost:5400/website-server/?php=7.2
* http://localhost:5400/website-server/?php=7.1
* http://localhost:5400/website-server/?php=7.0

... and ensure that wordpress works as-expected in each environment.
@brandonpayton
Copy link
Member

Just a note:

I ran into this issue for PHP 7.3, and it turns out it was for a very good reason. My Mac is currently intel-based, and we are using a binary for ARM.

$ uname -m
x86_64

$ file ~/src/playground/packages/php-wasm/compile/bison2.7/dist/usr/local/bison/bin/bison
bison: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=dea33bfc44b1b46331e33e883336e626fd95c7c7, for GNU/Linux 3.7.0, with debug_info, not stripped

It would probably be good to fix this at some point, but not being able to build PHP 7.3 is not currently a blocker for me.

@brandonpayton
Copy link
Member

brandonpayton commented Mar 18, 2024

Ah, I guess the architecture mismatch with the prebuilt binary is the known problem.

@brandonpayton
Copy link
Member

brandonpayton commented Mar 19, 2024

@adamziel, I was able to get the PHP 7.3 light build succeeding with this change:
brandonpayton@f6b2bd4

It doesn't cache the build output across PHP builds, but it seemed reasonable as an initial fix since builds for PHP 7.3 and below appear to be completely broken for intel right now.

Is this the kind of fix you had in mind?

A few of notes:

This has not been tested on an arm64 device because I do not have one handy, and I have not tested the build output yet because the recompile:php:web build is still running.

I took hints from the bison 2.7 Dockerfile here but don't know the reason for changing the libiconv prefix here:

./configure --prefix=/usr/local --with-libiconv-prefix=/usr/local/libiconv/

Do you recall why this path setting was important or necessary?

Also related to the bison 2.7 Dockerfile, the URL was adjusted to use HTTPS instead of HTTP to reduce the possibility of MITM attacks. If we are still using the original Dockerfile, we should probably fix it to use HTTPS as well.

@adamziel
Copy link
Collaborator

It doesn't cache the build output across PHP builds, but it seemed reasonable as an initial fix since builds for PHP 7.3 and below appear to be completely broken for intel right now.
Is this the kind of fix you had in mind?

@brandonpayton I think that's reasonable! I'm happy to test on an arm machine – can I just apply that patch and run the build process?

I took hints from the bison 2.7 Dockerfile here but don't know the reason for changing the libiconv prefix here:

I can't remember either. If it runs without that prefix change, it's most likely not needed.

Also related to the bison 2.7 Dockerfile, the URL was adjusted to use HTTPS instead of HTTP to reduce the possibility of MITM attacks. If we are still using the original Dockerfile, we should probably fix it to use HTTPS as well.

❤️

@brandonpayton
Copy link
Member

brandonpayton commented Mar 19, 2024

@brandonpayton I think that's reasonable! I'm happy to test on an arm machine – can I just apply that patch and run the build process?

@adamziel, great! Yep, just apply the patch and npm run recompile:php:web. There is a new PR for this change here.

I went ahead and removed the libiconv prefix and didn't see any build problems. I also tested loading Playground with some PHP versions 7.3 and below, and there didn't appear to be problems loading WP. (Actually, there was a problem loading WP for PHP 7.1, but I experienced the same when switching to trunk and using npm run dev.

@adamziel
Copy link
Collaborator

Superseded by #1115

@adamziel adamziel closed this Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] PHP.wasm [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants