@@ -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
@@ -525,8 +523,55 @@ block()
525523 add_dependencies (php_standard php_standard_credits)
526524endblock()
527525
528- # TODO: Check whether to enable the chroot() function by checking which SAPI is
529- # being built.
530- set (ENABLE_CHROOT_FUNC TRUE )
526+ ################################################################################
527+ # Add chroot() based on the SAPI type. It should be enabled only for the
528+ # CLI-based SAPIs. This enables building all SAPIs in a single build invocation.
529+ # Here, a build-time solution is integrated, although this would be better
530+ # resolved as mentioned in the issue report.
531+ # See: https://github.com/php/php-src/issues/11984
532+ ################################################################################
533+
534+ check_symbol_exists(chroot "unistd.h" HAVE_CHROOT)
535+
536+ add_library (php_standard_functions_cli OBJECT)
537+ add_library (php_standard_functions OBJECT)
538+
539+ target_sources (php_standard_functions_cli PRIVATE basic_functions.c dir.c)
540+ target_sources (php_standard_functions PRIVATE basic_functions.c dir.c)
541+
542+ target_compile_definitions (php_standard_functions_cli PRIVATE )
543+
544+ target_include_directories (
545+ php_standard_functions_cli
546+ PRIVATE
547+ $<TARGET_PROPERTY:php_standard,INCLUDE_DIRECTORIES >
548+ )
549+ target_include_directories (
550+ php_standard_functions
551+ PRIVATE
552+ $<TARGET_PROPERTY:php_standard,INCLUDE_DIRECTORIES >
553+ )
554+ target_compile_definitions (
555+ php_standard_functions_cli
556+ PRIVATE
557+ $<TARGET_PROPERTY:php_standard,COMPILE_DEFINITIONS >
558+ ENABLE_CHROOT_FUNC
559+ )
560+ target_compile_definitions (
561+ php_standard_functions
562+ PRIVATE $<TARGET_PROPERTY:php_standard,COMPILE_DEFINITIONS >
563+ )
564+ target_link_libraries (
565+ php_standard_functions_cli
566+ PRIVATE $<TARGET_PROPERTY:php_standard,LINK_LIBRARIES >
567+ )
568+ target_link_libraries (
569+ php_standard_functions
570+ PRIVATE $<TARGET_PROPERTY:php_standard,LINK_LIBRARIES >
571+ )
572+
573+ ################################################################################
574+ # Configuration header
575+ ################################################################################
531576
532577configure_file (config.cmake.h.in config.h)
0 commit comments