Skip to content

php_glob.c interferes with build targets #19152

@Lewiscowles1986

Description

@Lewiscowles1986

Description

The following code:

main/php_glob.c ported from WIN32 to all build targets temporarily in #18164

causes an error when building php wasm

docker buildx bake --set default.args.PHP_VERSION=8.5.0alpha1

using https://github.com/derickr/php-wasm-builder

Resulted in this output:

32.04 /local/src/php-src/main/php_glob.c:207:1: error: static declaration of 'reallocarray' follows non-static declaration
32.04   207 | reallocarray(void *optr, size_t nmemb, size_t size)
32.04       | ^
32.04 /local/src/emsdk/upstream/emscripten/cache/sysroot/include/stdlib.h:150:7: note: previous declaration is here
32.04   150 | void *reallocarray (void *, size_t, size_t);
32.04       |       ^
32.04 1 error generated.
32.05 make: *** [Makefile:1720: main/php_glob.lo] Error 1
32.05 make: *** Waiting for unfinished jobs....
33.67 emmake: error: 'make -j4' failed (returned 2)

But I expected this output instead:

warning: undefined symbol: getdtablesize (referenced by root reference (e.g. compiled C/C++ code))
warning: undefined symbol: makecontext (referenced by root reference (e.g. compiled C/C++ code))
warning: undefined symbol: php_glob (referenced by root reference (e.g. compiled C/C++ code))
warning: undefined symbol: php_globfree (referenced by root reference (e.g. compiled C/C++ code))
warning: undefined symbol: posix_spawnp (referenced by root reference (e.g. compiled C/C++ code))
warning: undefined symbol: swapcontext (referenced by root reference (e.g. compiled C/C++ code))
emcc: warning: warnings in JS library compilation [-Wjs-compiler]

Working around this by deleting the file leads to a different output:

28.22 make: *** No rule to make target '/local/src/php-src/main/php_glob.c', needed by 'main/php_glob.lo'.  Stop.
28.22 make: *** Waiting for unfinished jobs....
29.26 emmake: error: 'make -j4' failed (returned 2)

Using --enable-system-glob causes more failures

270.7 /local/src/php-src/ext/standard/dir.c:429:7: error: use of undeclared identifier 'PHP_GLOB_BRACE'
270.7   429 |         if ((PHP_GLOB_AVAILABLE_FLAGS & flags) != flags) {
270.7       |              ^~~~~~~~~~~~~~~~~~~~~~~~
270.7 /local/src/php-src/main/php_glob.h:177:39: note: expanded from macro 'PHP_GLOB_AVAILABLE_FLAGS'
270.7   177 | #define PHP_GLOB_AVAILABLE_FLAGS (0 | PHP_GLOB_BRACE | PHP_GLOB_MARK | PHP_GLOB_NOSORT | PHP_GLOB_NOCHECK | PHP_GLOB_NOESCAPE | PHP_GLOB_ERR | PHP_GLOB_ONLYDIR)
270.7       |                                       ^~~~~~~~~~~~~~
270.8 2 errors generated.
270.8 make: *** [Makefile:1450: ext/standard/dir.lo] Error 1

But, deleting the section for realloc (because I failed to deactivate it) works, as does using touch with an empty file. Proving it is indeed not needed outside of win32...

PHP Version

N/A (8.5 alpha targetted for build)

Operating System

debian bookworm

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions