diff --git a/Dockerfile b/Dockerfile
index 4ef4668ab..20f68efc7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM emscripten/emsdk:2.0.10
+FROM emscripten/emsdk:3.1.22
RUN apt-get update && \
apt-get --no-install-recommends -y install \
build-essential \
diff --git a/Makefile b/Makefile
index 4ca31980a..80950edf0 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ OPTIMIZE ?=-O2
RELEASE_SUFFIX ?=
DOCKER_IMAGE ?=soyuka/php-emscripten-builder:latest
-PHP_BRANCH ?=PHP-8.0.0
+PHP_BRANCH ?=PHP-8.1.10
LIBXML2_TAG ?=v2.9.10
DOCKER_ENV=docker run --rm \
@@ -17,13 +17,14 @@ DOCKER_ENV=docker run --rm \
-e INITIAL_MEMORY=${INITIAL_MEMORY} \
-e LIBXML_LIBS="-L/src/lib/lib" \
-e LIBXML_CFLAGS="-I/src/lib/include/libxml2" \
- -e SQLITE_CFLAGS="-I/src/third_party/sqlite-src" \
- -e SQLITE_LIBS="-L/src/third_party/sqlite-src" \
+ -e SQLITE_CFLAGS="-I/src/lib/include/sqlite3" \
+ -e SQLITE_LIBS="-L/src/lib/lib" \
-e PRELOAD_ASSETS='${PRELOAD_ASSETS}' \
-e ENVIRONMENT=${ENVIRONMENT}
DOCKER_RUN =${DOCKER_ENV} ${DOCKER_IMAGE}
DOCKER_RUN_IN_PHP =${DOCKER_ENV} -w /src/third_party/php-src/ ${DOCKER_IMAGE}
+DOCKER_RUN_IN_SQLITE =${DOCKER_ENV} -w /src/third_party/sqlite-src/ ${DOCKER_IMAGE}
DOCKER_RUN_IN_LIBXML =${DOCKER_ENV} -w /src/third_party/libxml2/ ${DOCKER_IMAGE}
.PHONY: clean build pull
@@ -32,21 +33,26 @@ all: lib/pib_eval.o php-web.wasm
########### Collect & patch the source code. ###########
-third_party/sqlite-src/sqlite3.c:
+third_party/sqlite-src:
mkdir -p third_party
wget https://sqlite.org/2020/sqlite-amalgamation-3330000.zip
${DOCKER_RUN} unzip sqlite-amalgamation-3330000.zip
${DOCKER_RUN} rm sqlite-amalgamation-3330000.zip
${DOCKER_RUN} mv sqlite-amalgamation-3330000 third_party/sqlite-src
-third_party/php-src/patched: third_party/sqlite-src/sqlite3.c
+third_party/sqlite-src/sqlite3.o: third_party/sqlite-src
+ ${DOCKER_RUN_IN_SQLITE} emcc -Oz -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DISABLE_LFS -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_NORMALIZE -c sqlite3.c -o sqlite3.o
+ ${DOCKER_RUN} mkdir -p /src/lib/include/sqlite3
+ ${DOCKER_RUN} cp -v third_party/sqlite-src/sqlite3.h /src/lib/include/sqlite3/sqlite3.h
+ ${DOCKER_RUN} cp -v third_party/sqlite-src/sqlite3.o /src/lib/lib/sqlite3.o
+
+third_party/php-src/patched:
${DOCKER_RUN} git clone https://github.com/php/php-src.git third_party/php-src \
--branch ${PHP_BRANCH} \
--single-branch \
--depth 1
- ${DOCKER_RUN} cp -v third_party/sqlite-src/sqlite3.h third_party/php-src/main/sqlite3.h
- ${DOCKER_RUN} cp -v third_party/sqlite-src/sqlite3.c third_party/php-src/main/sqlite3.c
- ${DOCKER_RUN} git apply --directory=third_party/php-src --no-index patch/${PHP_BRANCH}.patch
+ ${DOCKER_RUN_IN_PHP} sed -i -s 's/headers_sent) = 1/headers_sent) = 0/' sapi/embed/php_embed.c
+ ${DOCKER_RUN_IN_PHP} sed -i -s 's/no_headers = 1/no_headers = 0/' sapi/embed/php_embed.c
${DOCKER_RUN} touch third_party/php-src/patched
third_party/libxml2/README:
@@ -64,7 +70,7 @@ third_party/libxml2/configure: third_party/libxml2/README
########### Build the objects. ###########
-third_party/php-src/configure: third_party/php-src/patched third_party/libxml2/configure
+third_party/php-src/configure: third_party/php-src/patched third_party/libxml2/configure third_party/sqlite-src/sqlite3.o
mkdir -p build
${DOCKER_RUN_IN_PHP} bash -c "./buildconf --force && emconfigure ./configure \
--enable-embed=static \
@@ -73,14 +79,12 @@ third_party/php-src/configure: third_party/php-src/patched third_party/libxml2/c
--enable-xml \
--disable-cgi \
--disable-cli \
+ --disable-fiber-asm \
--disable-all \
- --with-sqlite3 \
--enable-session \
--enable-filter \
--enable-calendar \
--enable-dom \
- --enable-pdo \
- --with-pdo-sqlite \
--disable-rpath \
--disable-phpdbg \
--without-pear \
@@ -93,9 +97,12 @@ third_party/php-src/configure: third_party/php-src/patched third_party/libxml2/c
--disable-mbregex \
--enable-tokenizer \
--enable-simplexml \
+ --enable-pdo \
+ --with-pdo-sqlite \
+ --with-sqlite3 \
"
-lib/libphp.a: third_party/php-src/configure third_party/php-src/patched third_party/sqlite-src/sqlite3.c
+lib/libphp.a: third_party/php-src/configure third_party/php-src/patched
${DOCKER_RUN_IN_PHP} emmake make -j8
# PHP7 outputs a libphp7 whereas php8 a libphp
${DOCKER_RUN_IN_PHP} bash -c '[[ -f .libs/libphp7.la ]] && mv .libs/libphp7.la .libs/libphp.la && mv .libs/libphp7.a .libs/libphp.a && mv .libs/libphp7.lai .libs/libphp.lai || exit 0'
@@ -107,12 +114,10 @@ lib/pib_eval.o: lib/libphp.a source/pib_eval.c
-I Zend \
-I main \
-I TSRM/ \
- -I /src/third_party/libxml2 \
- -I /src/third_party/sqlite-src \
-c \
/src/source/pib_eval.c \
-o /src/lib/pib_eval.o \
- -s ERROR_ON_UNDEFINED_SYMBOLS=0
+ -s ERROR_ON_UNDEFINED_SYMBOLS=0
########### Build the final files. ###########
@@ -131,7 +136,7 @@ FINAL_BUILD=${DOCKER_RUN_IN_PHP} emcc ${OPTIMIZE} \
-s MODULARIZE=1 \
-s INVOKE_RUN=0 \
-lidbfs.js \
- /src/lib/pib_eval.o /src/lib/libphp.a /src/lib/lib/libxml2.a
+ /src/lib/pib_eval.o /src/lib/lib/sqlite3.o /src/lib/libphp.a /src/lib/lib/libxml2.a
php-web.wasm: ENVIRONMENT=web
php-web.wasm: lib/libphp.a lib/pib_eval.o
diff --git a/index.html b/index.html
new file mode 100644
index 000000000..431aa3f96
--- /dev/null
+++ b/index.html
@@ -0,0 +1,33 @@
+
+
diff --git a/patch/PHP-7.4.patch b/patch/PHP-7.4.patch
deleted file mode 100644
index 1e305891d..000000000
--- a/patch/PHP-7.4.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-diff --git a/ext/pdo_sqlite/php_pdo_sqlite_int.h b/ext/pdo_sqlite/php_pdo_sqlite_int.h
-index c1d3a953..55c18393 100644
---- a/ext/pdo_sqlite/php_pdo_sqlite_int.h
-+++ b/ext/pdo_sqlite/php_pdo_sqlite_int.h
-@@ -19,7 +19,7 @@
- #ifndef PHP_PDO_SQLITE_INT_H
- #define PHP_PDO_SQLITE_INT_H
-
--#include
-+#include "main/sqlite3.h"
-
- typedef struct {
- const char *file;
-diff --git a/ext/sqlite3/php_sqlite3_structs.h b/ext/sqlite3/php_sqlite3_structs.h
-index 3de8aac0..401e93d7 100644
---- a/ext/sqlite3/php_sqlite3_structs.h
-+++ b/ext/sqlite3/php_sqlite3_structs.h
-@@ -19,7 +19,7 @@
- #ifndef PHP_SQLITE_STRUCTS_H
- #define PHP_SQLITE_STRUCTS_H
-
--#include
-+#include "main/sqlite3.h"
-
- /* for backwards compatibility reasons */
- #ifndef SQLITE_OPEN_READONLY
-diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
-index f4d8066a..afb61446 100644
---- a/ext/sqlite3/sqlite3.c
-+++ b/ext/sqlite3/sqlite3.c
-@@ -27,7 +27,8 @@
- #include "php_sqlite3_structs.h"
- #include "main/SAPI.h"
-
--#include
-+#include "main/sqlite3.c"
-+#include "main/sqlite3.h"
-
- #include "zend_exceptions.h"
- #include "zend_interfaces.h"
-diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
-index 4c7dec6d..65762b8a 100644
---- a/sapi/embed/php_embed.c
-+++ b/sapi/embed/php_embed.c
-@@ -211,8 +211,8 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv)
- return FAILURE;
- }
-
-- SG(headers_sent) = 1;
-- SG(request_info).no_headers = 1;
-+ SG(headers_sent) = 0;
-+ SG(request_info).no_headers = 0;
- php_register_variable("PHP_SELF", "-", NULL);
-
- return SUCCESS;
diff --git a/patch/PHP-8.0.0.patch b/patch/PHP-8.0.0.patch
deleted file mode 100644
index 635595190..000000000
--- a/patch/PHP-8.0.0.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-diff --git a/ext/pdo_sqlite/php_pdo_sqlite_int.h b/ext/pdo_sqlite/php_pdo_sqlite_int.h
-index 31fa7cc9..539a7bb2 100644
---- a/ext/pdo_sqlite/php_pdo_sqlite_int.h
-+++ b/ext/pdo_sqlite/php_pdo_sqlite_int.h
-@@ -17,7 +17,7 @@
- #ifndef PHP_PDO_SQLITE_INT_H
- #define PHP_PDO_SQLITE_INT_H
-
--#include
-+#include "main/sqlite3.h"
-
- typedef struct {
- const char *file;
-diff --git a/ext/sqlite3/php_sqlite3_structs.h b/ext/sqlite3/php_sqlite3_structs.h
-index 80e915da..641aff5a 100644
---- a/ext/sqlite3/php_sqlite3_structs.h
-+++ b/ext/sqlite3/php_sqlite3_structs.h
-@@ -17,7 +17,7 @@
- #ifndef PHP_SQLITE_STRUCTS_H
- #define PHP_SQLITE_STRUCTS_H
-
--#include
-+#include "main/sqlite3.h"
-
- /* for backwards compatibility reasons */
- #ifndef SQLITE_OPEN_READONLY
-diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
-index cd91e68f..727e5256 100644
---- a/ext/sqlite3/sqlite3.c
-+++ b/ext/sqlite3/sqlite3.c
-@@ -26,7 +26,8 @@
- #include "sqlite3_arginfo.h"
- #include "main/SAPI.h"
-
--#include
-+#include "main/sqlite3.c"
-+#include "main/sqlite3.h"
-
- #include "zend_exceptions.h"
- #include "zend_interfaces.h"
-diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
-index b510d510..97cc812e 100644
---- a/sapi/embed/php_embed.c
-+++ b/sapi/embed/php_embed.c
-@@ -204,8 +204,8 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv)
- return FAILURE;
- }
-
-- SG(headers_sent) = 1;
-- SG(request_info).no_headers = 1;
-+ SG(headers_sent) = 0;
-+ SG(request_info).no_headers = 0;
- php_register_variable("PHP_SELF", "-", NULL);
-
- return SUCCESS;
diff --git a/patch/master.patch b/patch/master.patch
deleted file mode 100644
index 635595190..000000000
--- a/patch/master.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-diff --git a/ext/pdo_sqlite/php_pdo_sqlite_int.h b/ext/pdo_sqlite/php_pdo_sqlite_int.h
-index 31fa7cc9..539a7bb2 100644
---- a/ext/pdo_sqlite/php_pdo_sqlite_int.h
-+++ b/ext/pdo_sqlite/php_pdo_sqlite_int.h
-@@ -17,7 +17,7 @@
- #ifndef PHP_PDO_SQLITE_INT_H
- #define PHP_PDO_SQLITE_INT_H
-
--#include
-+#include "main/sqlite3.h"
-
- typedef struct {
- const char *file;
-diff --git a/ext/sqlite3/php_sqlite3_structs.h b/ext/sqlite3/php_sqlite3_structs.h
-index 80e915da..641aff5a 100644
---- a/ext/sqlite3/php_sqlite3_structs.h
-+++ b/ext/sqlite3/php_sqlite3_structs.h
-@@ -17,7 +17,7 @@
- #ifndef PHP_SQLITE_STRUCTS_H
- #define PHP_SQLITE_STRUCTS_H
-
--#include
-+#include "main/sqlite3.h"
-
- /* for backwards compatibility reasons */
- #ifndef SQLITE_OPEN_READONLY
-diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
-index cd91e68f..727e5256 100644
---- a/ext/sqlite3/sqlite3.c
-+++ b/ext/sqlite3/sqlite3.c
-@@ -26,7 +26,8 @@
- #include "sqlite3_arginfo.h"
- #include "main/SAPI.h"
-
--#include
-+#include "main/sqlite3.c"
-+#include "main/sqlite3.h"
-
- #include "zend_exceptions.h"
- #include "zend_interfaces.h"
-diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
-index b510d510..97cc812e 100644
---- a/sapi/embed/php_embed.c
-+++ b/sapi/embed/php_embed.c
-@@ -204,8 +204,8 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv)
- return FAILURE;
- }
-
-- SG(headers_sent) = 1;
-- SG(request_info).no_headers = 1;
-+ SG(headers_sent) = 0;
-+ SG(request_info).no_headers = 0;
- php_register_variable("PHP_SELF", "-", NULL);
-
- return SUCCESS;