diff --git a/.gitignore b/.gitignore index 8ad66fa..2f6d00b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -cosmocc -ph7 -php -target +/cosmocc +/ph7 +/php +/target *.zip *.gz diff --git a/README.md b/README.md index aadd461..c7baafc 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,17 @@ carthage uses the [cosmopolitan libc][cosmo] to build [αcτµαlly pδrταblε We offer two flavors: - - The latest official [PHP][php], compiled barebones (`--disable-all`) **~13MB ape** - The embedded [PH7][PH7] engine. **~2MB ape** + - The latest official [PHP][php]. **~30MB ape** Please note that _BOTH BUILDS ARE EXPERIMENTAL_. +### Extensions + +PH7 has no extensions, Zend PHP is built with these enabled: + + - ctype filter fileinfo ftp gmp pcntl posix session sockets tokenizer + ### Building Locally You'll need wget, unzip and make. Then: diff --git a/carthage.sh b/carthage.sh index 7a19055..da8c809 100644 --- a/carthage.sh +++ b/carthage.sh @@ -52,7 +52,7 @@ export PKG_CONFIG="pkg-config --with-path=$PWD/cosmocc/lib/pkgconfig" export INSTALL="cosmoinstall" export AR="cosmoar" -if ! test -f target/bin/ph7 +if ! test -f target/bin/ph7-2.1.4 then cd ph7 $CC -o ph7 ph7.c examples/ph7_interp.c -W -Wunused -Wall -I. @@ -61,11 +61,28 @@ then cd .. fi -if ! test -f target/bin/php +if ! test -f target/bin/php-8.3.9 then cd php + + patch -Np0 -i ../patches/php-8.3.9/cosmo-multicast.patch + ./buildconf --force - ./configure --prefix=$PWD/../target --disable-all --disable-shared --disable-fiber-asm + ./configure --prefix=$PWD/../target \ + --disable-all \ + --disable-shared \ + --disable-fiber-asm \ + --enable-ctype \ + --enable-filter \ + --enable-fileinfo \ + --enable-ftp \ + --enable-gmp \ + --enable-pcntl \ + --enable-posix \ + --enable-session \ + --enable-sockets \ + --enable-tokenizer + make -j $(nproc) make install-cli install-phpdbg mv ../target/bin/php ../target/bin/php-8.3.9 diff --git a/patches/php-8.3.9/cosmo-multicast.patch b/patches/php-8.3.9/cosmo-multicast.patch new file mode 100644 index 0000000..92bba72 --- /dev/null +++ b/patches/php-8.3.9/cosmo-multicast.patch @@ -0,0 +1,49 @@ +# Copyright (c) Alexandre Gomes Gaigalas +# SPDX-License-Identifier: ISC + +--- ext/sockets/multicast.h.orig 2024-07-07 10:15:00.221335337 -0300 ++++ ext/sockets/multicast.h 2024-07-07 10:15:03.599347501 -0300 +@@ -14,11 +14,11 @@ + +----------------------------------------------------------------------+ + */ + +-#if defined(MCAST_JOIN_GROUP) && !defined(__APPLE__) ++#if defined(MCAST_JOIN_GROUP) && !defined(__APPLE__) && !defined(__COSMOCC__) + # define RFC3678_API 1 + /* has block/unblock and source membership, in this case for both IPv4 and IPv6 */ + # define HAS_MCAST_EXT 1 +-#elif defined(IP_ADD_SOURCE_MEMBERSHIP) && !defined(__APPLE__) ++#elif defined(IP_ADD_SOURCE_MEMBERSHIP) && !defined(__APPLE__) && !defined(__COSMOCC__) + /* has block/unblock and source membership, but only for IPv4 */ + # define HAS_MCAST_EXT 1 + #endif + +--- ext/sockets/multicast.c.orig 2024-07-07 09:19:04.467193555 -0300 ++++ ext/sockets/multicast.c 2024-07-07 10:01:31.563897681 -0300 +@@ -722,7 +722,7 @@ + #define ifr_ifindex ifr_index + #endif + +-#if defined(SIOCGIFNAME) ++#if defined(SIOCGIFNAME) || defined(__COSMOCC__) + if_req.ifr_ifindex = if_index; + if (ioctl(php_sock->bsd_socket, SIOCGIFNAME, &if_req) == -1) { + #elif defined(HAVE_IF_INDEXTONAME) +@@ -801,7 +801,7 @@ + if ((((struct sockaddr*)&cur_req.ifr_addr)->sa_family == AF_INET) && + (((struct sockaddr_in*)&cur_req.ifr_addr)->sin_addr.s_addr == + addr->s_addr)) { +-#if defined(SIOCGIFINDEX) ++#if defined(SIOCGIFINDEX)|| defined(__COSMOCC__) + if (ioctl(php_sock->bsd_socket, SIOCGIFINDEX, (char*)&cur_req) + == -1) { + #elif defined(HAVE_IF_NAMETOINDEX) +@@ -815,7 +815,7 @@ + errno); + goto err; + } else { +-#if defined(SIOCGIFINDEX) ++#if defined(SIOCGIFINDEX) || defined(__COSMOCC__) + *if_index = cur_req.ifr_ifindex; + #else + *if_index = index_tmp;