Skip to content

Commit 246cd40

Browse files
committed
Simplify the PR
1 parent 768a74f commit 246cd40

File tree

14 files changed

+162528
-13561
lines changed

14 files changed

+162528
-13561
lines changed

.libs/xdebug.la

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# xdebug.la - a libtool library file
2+
# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)
3+
#
4+
# Please DO NOT delete this file!
5+
# It is necessary for linking the library.
6+
7+
# The name that we can dlopen(3).
8+
dlname='xdebug.so'
9+
10+
# Names of this library.
11+
library_names='xdebug.so xdebug.so xdebug.so'
12+
13+
# The name of the static archive.
14+
old_library=''
15+
16+
# Libraries that this one depends upon.
17+
dependency_libs=' -lm'
18+
19+
# Version information for xdebug.
20+
current=0
21+
age=0
22+
revision=0
23+
24+
# Is this an already installed library?
25+
installed=no
26+
27+
# Should we warn about portability when linking against -modules?
28+
shouldnotlink=yes
29+
30+
# Files to dlopen/dlpreopen
31+
dlopen=''
32+
dlpreopen=''
33+
34+
# Directory that this library needs to be installed in:
35+
libdir='/Users/cloudnik/www/Automattic/core/xdebug/modules'

.libs/xdebug.lai

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# xdebug.la - a libtool library file
2+
# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)
3+
#
4+
# Please DO NOT delete this file!
5+
# It is necessary for linking the library.
6+
7+
# The name that we can dlopen(3).
8+
dlname='xdebug.so'
9+
10+
# Names of this library.
11+
library_names='xdebug.so xdebug.so xdebug.so'
12+
13+
# The name of the static archive.
14+
old_library=''
15+
16+
# Libraries that this one depends upon.
17+
dependency_libs=' -lm'
18+
19+
# Version information for xdebug.
20+
current=0
21+
age=0
22+
revision=0
23+
24+
# Is this an already installed library?
25+
installed=yes
26+
27+
# Should we warn about portability when linking against -modules?
28+
shouldnotlink=yes
29+
30+
# Files to dlopen/dlpreopen
31+
dlopen=''
32+
dlpreopen=''
33+
34+
# Directory that this library needs to be installed in:
35+
libdir='/Users/cloudnik/www/Automattic/core/xdebug/modules'

.libs/xdebug.o

102 KB
Binary file not shown.

.libs/xdebug.so

770 KB
Binary file not shown.

packages/php-wasm/cli/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async function run() {
7575

7676
const hasMinusCOption = args.some((arg) => arg.startsWith('-c'));
7777
if (!hasMinusCOption) {
78-
args.unshift('-c', defaultPhpIniPath);
78+
// args.unshift('-c', defaultPhpIniPath);
7979
}
8080

8181
await php

packages/php-wasm/compile/build.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ const argParser = yargs(process.argv.slice(2))
5151
choices: ['yes', 'no'],
5252
description: 'Build with mbregex support',
5353
},
54+
WITH_READLINE: {
55+
type: 'string',
56+
choices: ['yes', 'no'],
57+
description: 'Build with Readline support',
58+
},
5459
WITH_CLI_SAPI: {
5560
type: 'string',
5661
choices: ['yes', 'no'],
@@ -126,16 +131,15 @@ const platformDefaults = {
126131
WITH_OPENSSL: 'yes',
127132
},
128133
node: {
129-
WITH_ICONV: 'yes',
130-
WITH_LIBXML: 'yes',
131-
WITH_LIBPNG: 'yes',
132-
WITH_ICONV: 'yes',
133-
WITH_MBSTRING: 'yes',
134-
WITH_MBREGEX: 'yes',
134+
// WITH_ICONV: 'yes',
135+
// WITH_LIBXML: 'yes',
136+
// WITH_LIBPNG: 'yes',
137+
// WITH_MBSTRING: 'yes',
138+
// WITH_MBREGEX: 'yes',
135139
WITH_CLI_SAPI: 'yes',
136-
WITH_OPENSSL: 'yes',
140+
// WITH_OPENSSL: 'yes',
137141
WITH_NODEFS: 'yes',
138-
WITH_MYSQL: 'yes',
142+
// WITH_MYSQL: 'yes',
139143
WITH_WS_NETWORKING_PROXY: 'yes',
140144
},
141145
};
@@ -195,6 +199,8 @@ await asyncSpawn(
195199
'--build-arg',
196200
getArg('WITH_CLI_SAPI'),
197201
'--build-arg',
202+
getArg('WITH_READLINE'),
203+
'--build-arg',
198204
getArg('WITH_OPENSSL'),
199205
'--build-arg',
200206
getArg('WITH_NODEFS'),

packages/php-wasm/compile/php/Dockerfile

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ ARG WITH_SQLITE
4545
ARG WITH_MYSQL
4646
ARG WITH_OPENSSL
4747
ARG WITH_ICONV
48+
ARG WITH_READLINE
4849
ARG WITH_SOURCEMAPS
4950
ARG WITH_WS_NETWORKING_PROXY
5051

@@ -93,22 +94,28 @@ RUN if [ "$WITH_LIBZIP" = "yes" ]; then \
9394
fi;
9495

9596

96-
# Add ncurses if needed and libedit if needed
9797
RUN if [ "$WITH_CLI_SAPI" = "yes" ]; \
9898
then \
9999
# Configure build flags
100-
echo -n ' --enable-phar --enable-cli=static --enable-readline --with-libedit=/root/lib ' >> /root/.php-configure-flags && \
100+
echo -n ' --enable-phar --enable-cli=static ' >> /root/.php-configure-flags && \
101101
echo -n ' sapi/cli/php_cli_process_title.c sapi/cli/ps_title.c sapi/cli/php_http_parser.c sapi/cli/php_cli_server.c sapi/cli/php_cli.c ' \
102102
>> /root/.emcc-php-wasm-sources && \
103103
echo -n ', "_run_cli", "_wasm_add_cli_arg"' >> /root/.EXPORTED_FUNCTIONS && \
104-
echo -n ' -DWITH_CLI_SAPI=1 -lncurses -ledit ' >> /root/.emcc-php-wasm-flags && \
105-
# Disable dlopen() in the readline PHP extension
106-
echo '#undef COMPILE_DL_READLINE' >> /root/php-src/main/php_config.h && \
107-
/root/replace.sh 's/GET_SHELL_CB\(cb\);/(cb) = php_cli_get_shell_callbacks();/g' /root/php-src/ext/readline/readline_cli.c; \
104+
echo -n ' -DWITH_CLI_SAPI=1 ' >> /root/.emcc-php-wasm-flags; \
108105
else \
109106
echo -n ' --disable-cli ' >> /root/.php-configure-flags; \
110107
fi;
111108

109+
# Add ncurses if needed and libedit if needed
110+
RUN if [ "$WITH_READLINE" = "yes" ]; \
111+
then \
112+
echo -n ' --enable-readline --with-libedit=/root/lib ' >> /root/.php-configure-flags && \
113+
echo -n ' -lncurses -ledit ' >> /root/.emcc-php-wasm-flags && \
114+
# Disable dlopen() in the readline PHP extension
115+
/root/replace.sh 's/GET_SHELL_CB\(cb\);/(cb) = php_cli_get_shell_callbacks();/g' /root/php-src/ext/readline/readline_cli.c; \
116+
echo '#undef COMPILE_DL_READLINE' >> /root/php-src/main/php_config.h; \
117+
fi;
118+
112119
# Add Libxml2 if needed
113120
RUN if [ "$WITH_LIBXML" = "yes" ]; \
114121
then \
@@ -202,6 +209,9 @@ RUN if [ "$WITH_MYSQL" = "yes" ]; then \
202209
echo -n ' --enable-mysql --enable-pdo --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd ' >> /root/.php-configure-flags; \
203210
fi
204211

212+
# @TODO: Figure out why this is needed:
213+
RUN sed -i 's/HARDCODED_INI/HARDCODED_INI2/g' /root/php-src/sapi/cli/php_cli.c
214+
205215
# Build the patched PHP
206216
WORKDIR /root/php-src
207217
RUN source /root/emsdk/emsdk_env.sh && \
@@ -225,7 +235,7 @@ RUN source /root/emsdk/emsdk_env.sh && \
225235
--disable-all \
226236
--enable-hash \
227237
--enable-static=yes \
228-
--enable-shared=no \
238+
--enable-shared=yes \
229239
--enable-session \
230240
--enable-filter \
231241
--enable-calendar \
@@ -434,6 +444,11 @@ RUN echo -n ' -s ASYNCIFY=1 -s ASYNCIFY_IGNORE_INDIRECT=1 ' >> /root/.emcc-php-w
434444
"zif_fwrite",\
435445
"php_stdiop_write",\
436446
"zif_array_filter",\
447+
"dlopen",\
448+
"zend_load_extension",\
449+
"zend_llist_apply",\
450+
"php_ini_register_extensions",\
451+
"php_load_zend_extension_cb",\
437452
"zend_call_known_instance_method_with_2_params",\
438453
"zend_fetch_dimension_address_read_R",\
439454
"_zval_dtor_func_for_ptr",\
@@ -739,6 +754,7 @@ RUN set -euxo pipefail; \
739754
mkdir -p /build/output; \
740755
source /root/emsdk/emsdk_env.sh; \
741756
export EXPORTED_FUNCTIONS=$'["_exit", \n\
757+
"_compiler_globals", \n\
742758
"_php_wasm_init", \n\
743759
"_phpwasm_destroy_uploaded_files_hash", \n\
744760
"_phpwasm_init_uploaded_files_hash", \n\
@@ -783,6 +799,7 @@ RUN set -euxo pipefail; \
783799
-s INITIAL_MEMORY=1024MB \
784800
-s ALLOW_MEMORY_GROWTH=1 \
785801
-s ASSERTIONS=0 \
802+
-s MAIN_MODULE \
786803
-s ERROR_ON_UNDEFINED_SYMBOLS=0 \
787804
-s NODEJS_CATCH_EXIT=0 \
788805
-s NODEJS_CATCH_REJECTION=0 \
@@ -876,6 +893,8 @@ RUN set -euxo pipefail; \
876893
# wrapper function.
877894
/root/replace.sh $'s/ENVIRONMENT_IS_([A-Z]+)\s*=\s*(true|false)/ENVIRONMENT_IS_$1=RuntimeName==="$1"/g' /root/output/php.js; \
878895
/root/replace.sh 's/var ENV\s*=\s*\{/var ENV = PHPLoader.ENV || {/g' /root/output/php.js; \
896+
/root/replace.sh 's/__dlopen_js\./__dlopen_js_unused./g' /root/output/php.js; \
897+
/root/replace.sh 's/__dlopen_js\s*=/__dlopen_js_unused =/g' /root/output/php.js; \
879898
# Turn the php.js file into an ES module
880899
# Manually turn the output into a esm module instead of relying on -s MODULARIZE=1.
881900
# which pollutes the global namespace and does not play well with import() mechanics.

packages/php-wasm/compile/php/esm-prefix.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@ export function init(RuntimeName, PHPLoader) {
3434
}
3535
}
3636

37+
const __dlopen_js = function (handle) {
38+
var jsflags = { loadAsync: false }
39+
return dlopenInternal(handle, jsflags);
40+
};
41+
__dlopen_js.isAsync = false;
42+
3743
// The rest of the code comes from the built php.js file and esm-suffix.js

packages/php-wasm/compile/php/php_wasm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,3 +1581,9 @@ int EMSCRIPTEN_KEEPALIVE del_callback(zend_function *fptr)
15811581
}
15821582
#endif
15831583

1584+
EMSCRIPTEN_KEEPALIVE void emscripten_console_log(char *a){}
1585+
EMSCRIPTEN_KEEPALIVE void emscripten_console_warn(char *a){}
1586+
EMSCRIPTEN_KEEPALIVE void emscripten_console_error(char *a){}
1587+
EMSCRIPTEN_KEEPALIVE void emscripten_out(char *a){}
1588+
EMSCRIPTEN_KEEPALIVE void emscripten_err(char *a){}
1589+
EMSCRIPTEN_KEEPALIVE void emscripten_dbg(char *a){}
-2.38 MB
Binary file not shown.

0 commit comments

Comments
 (0)