@@ -68,15 +68,13 @@ target_sources(
6868 array.c
6969 assert.c
7070 base64.c
71- basic_functions.c
7271 basic_functions.stub.php
7372 browscap.c
7473 crc32.c
7574 credits.c
7675 crypt.c
7776 css.c
7877 datetime.c
79- dir.c
8078 dir.stub.php
8179 dl.c
8280 dl.stub.php
@@ -522,8 +520,55 @@ block()
522520 add_dependencies (php_standard php_standard_credits)
523521endblock()
524522
525- # TODO: Check whether to enable the chroot() function by checking which SAPI is
526- # being built.
527- set (ENABLE_CHROOT_FUNC TRUE )
523+ ################################################################################
524+ # Add chroot() based on the SAPI type. It should be enabled only for the
525+ # CLI-based SAPIs. This enables building all SAPIs in a single build invocation.
526+ # Here, a build-time solution is integrated, although this would be better
527+ # resolved as mentioned in the issue report.
528+ # See: https://github.com/php/php-src/issues/11984
529+ ################################################################################
530+
531+ check_symbol_exists(chroot "unistd.h" HAVE_CHROOT)
532+
533+ add_library (php_standard_functions_cli OBJECT)
534+ add_library (php_standard_functions OBJECT)
535+
536+ target_sources (php_standard_functions_cli PRIVATE basic_functions.c dir.c)
537+ target_sources (php_standard_functions PRIVATE basic_functions.c dir.c)
538+
539+ target_compile_definitions (php_standard_functions_cli PRIVATE )
540+
541+ target_include_directories (
542+ php_standard_functions_cli
543+ PRIVATE
544+ $<TARGET_PROPERTY:php_standard,INCLUDE_DIRECTORIES >
545+ )
546+ target_include_directories (
547+ php_standard_functions
548+ PRIVATE
549+ $<TARGET_PROPERTY:php_standard,INCLUDE_DIRECTORIES >
550+ )
551+ target_compile_definitions (
552+ php_standard_functions_cli
553+ PRIVATE
554+ $<TARGET_PROPERTY:php_standard,COMPILE_DEFINITIONS >
555+ ENABLE_CHROOT_FUNC
556+ )
557+ target_compile_definitions (
558+ php_standard_functions
559+ PRIVATE $<TARGET_PROPERTY:php_standard,COMPILE_DEFINITIONS >
560+ )
561+ target_link_libraries (
562+ php_standard_functions_cli
563+ PRIVATE $<TARGET_PROPERTY:php_standard,LINK_LIBRARIES >
564+ )
565+ target_link_libraries (
566+ php_standard_functions
567+ PRIVATE $<TARGET_PROPERTY:php_standard,LINK_LIBRARIES >
568+ )
569+
570+ ################################################################################
571+ # Configuration header
572+ ################################################################################
528573
529574configure_file (config.cmake.h.in config.h)
0 commit comments