diff --git a/disabled-packages/kphp-timelib/build.sh b/disabled-packages/kphp-timelib/build.sh new file mode 100644 index 0000000000..1d79cc5318 --- /dev/null +++ b/disabled-packages/kphp-timelib/build.sh @@ -0,0 +1,22 @@ +TERMUX_PKG_HOMEPAGE=https://github.com/derickr/timelib +TERMUX_PKG_DESCRIPTION="timelib 2020.02 library fork for KPHP" +TERMUX_PKG_LICENSE="MIT" +TERMUX_PKG_LICENSE_FILE="LICENSE.rst" +TERMUX_PKG_MAINTAINER="@termux" +_COMMIT=59ee82faa8d9ed42b1b9b9339e0b989cc929cd4a +TERMUX_PKG_VERSION=2021.03.01 +TERMUX_PKG_SRCURL=https://github.com/VKCOM/timelib.git +TERMUX_PKG_GIT_BRANCH=master +TERMUX_PKG_NO_STATICSPLIT=true + +termux_step_post_get_source() { + git fetch --unshallow + git checkout $_COMMIT + + local version="$(git log -1 --format=%cs | sed 's/-/./g')" + if [ "$version" != "$TERMUX_PKG_VERSION" ]; then + echo -n "ERROR: The specified version \"$TERMUX_PKG_VERSION\"" + echo " is different from what is expected to be: \"$version\"" + return 1 + fi +} diff --git a/disabled-packages/kphp/build.sh b/disabled-packages/kphp/build.sh new file mode 100644 index 0000000000..898b33b07a --- /dev/null +++ b/disabled-packages/kphp/build.sh @@ -0,0 +1,71 @@ +TERMUX_PKG_HOMEPAGE=https://vkcom.github.io/kphp/ +TERMUX_PKG_DESCRIPTION="A PHP compiler" +TERMUX_PKG_LICENSE="GPL-3.0" +TERMUX_PKG_MAINTAINER="@termux" +_COMMIT=b1b2cec0f0e1206e1c134830ebd1f28e21bbd330 +TERMUX_PKG_VERSION=2021.12.30 +TERMUX_PKG_REVISION=3 +TERMUX_PKG_SRCURL=https://github.com/VKCOM/kphp.git +TERMUX_PKG_GIT_BRANCH=master +TERMUX_PKG_DEPENDS="fmt, libandroid-execinfo, libc++, libcurl, libmsgpack-cxx, libre2, libuber-h3, libucontext, libyaml-cpp, openssl-1.1, pcre, zstd" +TERMUX_PKG_BUILD_DEPENDS="kphp-timelib" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" +-DKPHP_TESTS=OFF +-DOPENSSL_INCLUDE_DIR=$TERMUX_PREFIX/include/openssl-1.1 +-DOPENSSL_LIBRARIES=$TERMUX_PREFIX/lib/openssl-1.1 +-DOPENSSL_CRYPTO_LIBRARY=$TERMUX_PREFIX/lib/openssl-1.1/libcrypto.so.1.1 +-DOPENSSL_SSL_LIBRARY=$TERMUX_PREFIX/lib/openssl-1.1/libssl.so.1.1" +TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686" + +termux_step_post_get_source() { + git fetch --unshallow + git checkout $_COMMIT + + local version="$(git log -1 --format=%cs | sed 's/-/./g')" + if [ "$version" != "$TERMUX_PKG_VERSION" ]; then + echo -n "ERROR: The specified version \"$TERMUX_PKG_VERSION\"" + echo " is different from what is expected to be: \"$version\"" + return 1 + fi +} + +termux_step_pre_configure() { + LDFLAGS+=" -landroid-execinfo" + + _NEED_DUMMY_LIBPTHREAD_A= + _LIBPTHREAD_A=$TERMUX_PREFIX/lib/libpthread.a + if [ ! -e $_LIBPTHREAD_A ]; then + _NEED_DUMMY_LIBPTHREAD_A=true + echo '!' > $_LIBPTHREAD_A + fi + CFLAGS="-I$TERMUX_PREFIX/include/openssl-1.1 $CFLAGS" + CPPFLAGS="-I$TERMUX_PREFIX/include/openssl-1.1 $CPPFLAGS" + CXXFLAGS="-I$TERMUX_PREFIX/include/openssl-1.1 $CXXFLAGS" + LDFLAGS="-L$TERMUX_PREFIX/lib/openssl-1.1 -Wl,-rpath=$TERMUX_PREFIX/lib/openssl-1.1 $LDFLAGS" +} + +termux_step_post_configure() { + local f + if [ "$TERMUX_CMAKE_BUILD" == "Ninja" ]; then + f=build.ninja + else + f=CMakeFiles/kphp2cpp.dir/link.txt + fi + sed -i -e 's/-l:libyaml-cpp\.a/-lyaml-cpp/g' \ + -e 's/-l:libre2\.a/-lre2/g' \ + $f + + local bin=$TERMUX_PKG_BUILDDIR/_prefix/bin + mkdir -p $bin + for exe in generate_unicode_utils prepare_unicode_data; do + $CC_FOR_BUILD $TERMUX_PKG_SRCDIR/common/unicode/${exe//_/-}.cpp \ + -o ${bin}/${exe} + done + export PATH=$bin:$PATH +} + +termux_step_post_make_install() { + if [ $_NEED_DUMMY_LIBPTHREAD_A ]; then + rm -f $_LIBPTHREAD_A + fi +} diff --git a/disabled-packages/kphp/cmake-init-compilation-flags.cmake.patch b/disabled-packages/kphp/cmake-init-compilation-flags.cmake.patch new file mode 100644 index 0000000000..6dec73bfa7 --- /dev/null +++ b/disabled-packages/kphp/cmake-init-compilation-flags.cmake.patch @@ -0,0 +1,15 @@ +--- a/cmake/init-compilation-flags.cmake ++++ b/cmake/init-compilation-flags.cmake +@@ -80,9 +80,11 @@ + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + add_compile_options(-march=sandybridge -fno-common) + add_link_options(-fno-common) ++elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") ++ add_compile_options(-march=armv8-a+crc+aes) + endif() + +-add_compile_options(-Werror -Wall -Wextra -Wunused-function -Wfloat-conversion -Wno-sign-compare ++add_compile_options(-Wall -Wextra -Wunused-function -Wfloat-conversion -Wno-sign-compare + -Wuninitialized -Wno-redundant-move -Wno-missing-field-initializers) + + if(NOT APPLE) diff --git a/disabled-packages/kphp/cmake-init-global-vars.cmake.patch b/disabled-packages/kphp/cmake-init-global-vars.cmake.patch new file mode 100644 index 0000000000..fc25f8b6a7 --- /dev/null +++ b/disabled-packages/kphp/cmake-init-global-vars.cmake.patch @@ -0,0 +1,25 @@ +--- a/cmake/init-global-vars.cmake ++++ b/cmake/init-global-vars.cmake +@@ -7,12 +7,9 @@ + set(GENERATED_DIR "${OBJS_DIR}/generated") + set(AUTO_DIR "${GENERATED_DIR}/auto") + +-if(APPLE) ++if(TRUE) + set(CURL_LIB curl) + set(ICONV_LIB iconv) +-else() +- set(CURL_LIB /opt/curl7600/lib/libcurl.a) +- set(RT_LIB rt) + endif() + + find_package(Git REQUIRED) +@@ -72,7 +69,7 @@ + set(CMAKE_INSTALL_PREFIX "/." CACHE PATH "install prefix" FORCE) + endif() + +-set(VK_INSTALL_DIR usr/share/vkontakte) ++set(VK_INSTALL_DIR share/vkontakte) + set(INSTALL_KPHP_SOURCE ${VK_INSTALL_DIR}/kphp_source) + + set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) diff --git a/disabled-packages/kphp/common-algorithms-simd-int-to-string.h.patch b/disabled-packages/kphp/common-algorithms-simd-int-to-string.h.patch new file mode 100644 index 0000000000..12a246736f --- /dev/null +++ b/disabled-packages/kphp/common-algorithms-simd-int-to-string.h.patch @@ -0,0 +1,27 @@ +--- a/common/algorithms/simd-int-to-string.h ++++ b/common/algorithms/simd-int-to-string.h +@@ -274,6 +274,9 @@ + // todo anyone who wants to practice some low-level magic — welcome to implement a proper SIMD form with ARM intrinsics + #include + #include ++#ifdef __ANDROID__ ++#include ++#endif + + inline char *simd_uint32_to_string(uint32_t value, char *out_buffer) noexcept { + int n = sprintf(out_buffer, "%u", value); +@@ -286,12 +289,12 @@ + } + + inline char *simd_uint64_to_string(uint64_t value, char *out_buffer) { +- int n = sprintf(out_buffer, "%llu", value); ++ int n = sprintf(out_buffer, "%" PRIu64, value); + return out_buffer + n; + } + + inline char *simd_int64_to_string(int64_t value, char *out_buffer) { +- int n = sprintf(out_buffer, "%lld", value); ++ int n = sprintf(out_buffer, "%" PRId64, value); + return out_buffer + n; + } + diff --git a/disabled-packages/kphp/common-binlog-binlog-buffer-aio.cpp.patch b/disabled-packages/kphp/common-binlog-binlog-buffer-aio.cpp.patch new file mode 100644 index 0000000000..26255ae52c --- /dev/null +++ b/disabled-packages/kphp/common-binlog-binlog-buffer-aio.cpp.patch @@ -0,0 +1,12 @@ +--- a/common/binlog/binlog-buffer-aio.cpp ++++ b/common/binlog/binlog-buffer-aio.cpp +@@ -2,7 +2,9 @@ + // Copyright (c) 2020 LLC «V Kontakte» + // Distributed under the GPL v3 License, see LICENSE.notice.txt + ++#ifndef __ANDROID__ + #include ++#endif + #include + #include + #include diff --git a/disabled-packages/kphp/common-binlog-binlog-buffer.h.patch b/disabled-packages/kphp/common-binlog-binlog-buffer.h.patch new file mode 100644 index 0000000000..d66b6055ac --- /dev/null +++ b/disabled-packages/kphp/common-binlog-binlog-buffer.h.patch @@ -0,0 +1,12 @@ +--- a/common/binlog/binlog-buffer.h ++++ b/common/binlog/binlog-buffer.h +@@ -5,7 +5,9 @@ + #ifndef __KDB_BINLOG_BUFFER_H__ + #define __KDB_BINLOG_BUFFER_H__ + ++#ifndef __ANDROID__ + #include ++#endif + #include + #include + diff --git a/disabled-packages/kphp/common-crc32c_aarch64.cpp.patch b/disabled-packages/kphp/common-crc32c_aarch64.cpp.patch new file mode 100644 index 0000000000..ecd9572146 --- /dev/null +++ b/disabled-packages/kphp/common-crc32c_aarch64.cpp.patch @@ -0,0 +1,20 @@ +--- a/common/crc32c_aarch64.cpp ++++ b/common/crc32c_aarch64.cpp +@@ -25,7 +25,7 @@ + + static uint32_t aarch64_native_crc(const void *buffer, long int len, + uint32_t crc) { +- const uint8_t *p = buffer; ++ const uint8_t *p = (const uint8_t *)buffer; + int64_t length = len; + + while ((length -= sizeof(uint64_t)) >= 0) { +@@ -98,7 +98,7 @@ + // k2=CRC(x^(SEGMENTBYTES*8)) + const poly64_t k0 = 0x8d96551c, k1 = 0xbd6f81f8, k2 = 0xdcb17aa4; + +- const uint8_t *p = buf; ++ const uint8_t *p = (const uint8_t *)buf; + + while (length >= KBYTES) { + crc0 = crc; diff --git a/disabled-packages/kphp/common-crypto-aes256-aarch64.cpp.patch b/disabled-packages/kphp/common-crypto-aes256-aarch64.cpp.patch new file mode 100644 index 0000000000..30fd25740a --- /dev/null +++ b/disabled-packages/kphp/common-crypto-aes256-aarch64.cpp.patch @@ -0,0 +1,56 @@ +--- a/common/crypto/aes256-aarch64.cpp ++++ b/common/crypto/aes256-aarch64.cpp +@@ -78,7 +78,7 @@ + void crypto_aarch64_aes256_set_decrypt_key(vk_aes_ctx_t *vk_ctx, const uint8_t key[32]) { + crypto_aarch64_aes256_set_encrypt_key(vk_ctx, key); + +- unsigned char *a = align16(&vk_ctx->u.ctx.a); ++ unsigned char *a = (unsigned char *)align16(&vk_ctx->u.ctx.a); + for (int i = 1; i <= 13; i++) { + asm volatile("mov x9, %[key] ;" + "ld1 {v0.16b}, [x9] ;" +@@ -97,7 +97,7 @@ + + asm volatile("mov x9, %[iv] ;" // move IV address in x9 + "mov x10, %[out] ;" // move out address in x10 +- "mov x11, %[size] ;" // move size value in x11 ++ "mov w11, %w[size] ;" // move size value in x11 + "mov x12, %[in] ;" // move plaintext address in x12 + "mov x13, %[key] ;" // move key address in x13 + "ld1 {v25.16b}, [x9] ;" // load IV to v0.16b +@@ -167,7 +167,7 @@ + + asm volatile("mov x9, %[iv] ;" // move IV address in x9 + "mov x10, %[out] ;" // move out address in x10 +- "mov x11, %[size] ;" // move size value in x11 ++ "mov w11, %w[size] ;" // move size value in x11 + "mov x12, %[in] ;" // move ciphertext address in x12 + "mov x13, %[key] ;" // move key address in x13 + "ld1 {v25.16b}, [x9] ;" // load IV to v25.16b +@@ -238,7 +238,7 @@ + + asm volatile("mov x9, %[iv] ;" // move IGE IV address in x9 + "mov x10, %[out] ;" // move out address in x10 +- "mov x11, %[size] ;" // move size value in x11 ++ "mov w11, %w[size] ;" // move size value in x11 + "mov x12, %[in] ;" // move plaintext address in x12 + "mov x13, %[key] ;" // move key address in x13 + "ld1 {v25.16b}, [x9], #16 ;" // load IGE IV Y to v25.16b +@@ -313,7 +313,7 @@ + + asm volatile("mov x9, %[iv] ;" // move IGE IV address in x9 + "mov x10, %[out] ;" // move out address in x10 +- "mov x11, %[size] ;" // move size value in x11 ++ "mov w11, %w[size] ;" // move size value in x11 + "mov x12, %[in] ;" // move cyphertext address in x12 + "mov x13, %[key] ;" // move key address in x13 + "ld1 {v25.16b}, [x9], #16 ;" // load IGE IV Y to v25.16b +@@ -439,7 +439,7 @@ + "mov x10, %[in] ;" // move plaintext address in x10 + "mov x11, %[key] ;" // move key address in x11 + "mov x12, %[iv] ;" // move IV address in x12 +- "mov x13, %[n] ;" // move n value in x11 ++ "mov w13, %w[n] ;" // move n value in x11 + "ld1 {v26.16b}, [x12] ;" // load IV to v0.16b + "eor v25.16b, v25.16b, v25.16b ;" + "mov w15, #1 ;" diff --git a/disabled-packages/kphp/common-fast-backtrace.cpp.patch b/disabled-packages/kphp/common-fast-backtrace.cpp.patch new file mode 100644 index 0000000000..ba40bea73f --- /dev/null +++ b/disabled-packages/kphp/common-fast-backtrace.cpp.patch @@ -0,0 +1,11 @@ +--- a/common/fast-backtrace.cpp ++++ b/common/fast-backtrace.cpp +@@ -53,7 +53,7 @@ + #error "Unsupported arch" + #endif + +-#if defined(__APPLE__) ++#if defined(__aarch64__) || defined(__APPLE__) + int fast_backtrace_without_recursions(void **, int) noexcept { + return 0; + } diff --git a/disabled-packages/kphp/common-resolver.cpp.patch b/disabled-packages/kphp/common-resolver.cpp.patch new file mode 100644 index 0000000000..1cdac0315f --- /dev/null +++ b/disabled-packages/kphp/common-resolver.cpp.patch @@ -0,0 +1,18 @@ +--- a/common/resolver.cpp ++++ b/common/resolver.cpp +@@ -15,10 +15,14 @@ + #include + #include + ++#ifdef __ANDROID__ ++#include ++#endif ++ + #include "common/kprintf.h" + #include "common/options.h" + +-#define HOSTS_FILE "/etc/hosts" ++#define HOSTS_FILE "@TERMUX_PREFIX@/etc/hosts" + #define MAX_HOSTS_SIZE (1L << 24) + + int kdb_hosts_loaded; diff --git a/disabled-packages/kphp/common-server-crash-dump.cpp.patch b/disabled-packages/kphp/common-server-crash-dump.cpp.patch new file mode 100644 index 0000000000..92a830b82f --- /dev/null +++ b/disabled-packages/kphp/common-server-crash-dump.cpp.patch @@ -0,0 +1,11 @@ +--- a/common/server/crash-dump.cpp ++++ b/common/server/crash-dump.cpp +@@ -116,6 +116,8 @@ + crash_dump_write_reg(LITERAL_WITH_LENGTH("R15=0x"), uc->uc_mcontext.gregs[REG_R15], buffer); + + #elif defined(__aarch64__) ++ const auto *uc = static_cast(ucontext); ++ + crash_dump_write_reg(LITERAL_WITH_LENGTH("SP=0x"), uc->uc_mcontext.sp, buffer); + crash_dump_write_reg(LITERAL_WITH_LENGTH("PC=0x"), uc->uc_mcontext.pc, buffer); + crash_dump_write_reg(LITERAL_WITH_LENGTH("PSTATE=0x"), uc->uc_mcontext.pstate, buffer); diff --git a/disabled-packages/kphp/common-server-signals.cpp.patch b/disabled-packages/kphp/common-server-signals.cpp.patch new file mode 100644 index 0000000000..05bbf1e99c --- /dev/null +++ b/disabled-packages/kphp/common-server-signals.cpp.patch @@ -0,0 +1,13 @@ +--- a/common/server/signals.cpp ++++ b/common/server/signals.cpp +@@ -224,6 +224,10 @@ + } + + ++#ifdef __ANDROID__ ++#define valloc(size) memalign(sysconf(_SC_PAGESIZE),size) ++#endif ++ + void set_debug_handlers() { + stack_t stack; + int res = sigaltstack(nullptr, &stack); diff --git a/disabled-packages/kphp/compiler-compiler-settings.cpp.patch b/disabled-packages/kphp/compiler-compiler-settings.cpp.patch new file mode 100644 index 0000000000..fbe5fc2c6c --- /dev/null +++ b/disabled-packages/kphp/compiler-compiler-settings.cpp.patch @@ -0,0 +1,11 @@ +--- a/compiler/compiler-settings.cpp ++++ b/compiler/compiler-settings.cpp +@@ -127,7 +127,7 @@ + + void append_curl(std::string &cxx_flags, std::string &ld_flags) noexcept { + if (!contains_lib(ld_flags, "curl")) { +-#if defined(__APPLE__) ++#if defined(__APPLE__) || defined(__ANDROID__) + static_cast(cxx_flags); + ld_flags += " -lcurl"; + #else diff --git a/disabled-packages/kphp/compiler-compiler.cpp.patch b/disabled-packages/kphp/compiler-compiler.cpp.patch new file mode 100644 index 0000000000..a0759233f1 --- /dev/null +++ b/disabled-packages/kphp/compiler-compiler.cpp.patch @@ -0,0 +1,11 @@ +--- a/compiler/compiler.cpp ++++ b/compiler/compiler.cpp +@@ -119,7 +119,7 @@ + std::string dest_path = G->settings().dest_dir.get(); + + std::stringstream ss; +- ss << "/tmp/" << std::hex << vk::std_hash(dest_path) << "_kphp_temp_lock"; ++ ss << "@TERMUX_PREFIX@/tmp/" << std::hex << vk::std_hash(dest_path) << "_kphp_temp_lock"; + locked_filename_ = ss.str(); + + fd_ = open(locked_filename_.c_str(), O_RDWR | O_CREAT, 0666); diff --git a/disabled-packages/kphp/runtime-allocator.cpp.patch b/disabled-packages/kphp/runtime-allocator.cpp.patch new file mode 100644 index 0000000000..c4b70c42f0 --- /dev/null +++ b/disabled-packages/kphp/runtime-allocator.cpp.patch @@ -0,0 +1,70 @@ +--- a/runtime/allocator.cpp ++++ b/runtime/allocator.cpp +@@ -9,6 +9,36 @@ + #include + #include + ++static void *(* volatile malloc_hook_dummy)(size_t, const void *); ++static decltype(malloc_hook_dummy) *malloc_hook_ptr; ++static void *(* volatile realloc_hook_dummy)(void *, size_t, const void *); ++static decltype(realloc_hook_dummy) *realloc_hook_ptr; ++static void (* volatile free_hook_dummy)(void *, const void *); ++static decltype(free_hook_dummy) *free_hook_ptr; ++static void *(* volatile memalign_hook_dummy)(size_t, size_t, const void *); ++static decltype(memalign_hook_dummy) *memalign_hook_ptr; ++ ++static void malloc_hook_init(void) { ++ static bool initialized = false; ++ if (initialized) return; ++ void *libc_handle = dlopen("libc.so", RTLD_NOW); ++ if (libc_handle != NULL) { ++ malloc_hook_ptr = (decltype(malloc_hook_ptr))dlsym(libc_handle, "__malloc_hook"); ++ realloc_hook_ptr = (decltype(realloc_hook_ptr))dlsym(libc_handle, "__realloc_hook"); ++ free_hook_ptr = (decltype(free_hook_ptr))dlsym(libc_handle, "__free_hook"); ++ memalign_hook_ptr = (decltype(memalign_hook_ptr))dlsym(libc_handle, "__memalign_hook"); ++ } ++ if (malloc_hook_ptr == NULL) ++ malloc_hook_ptr = &malloc_hook_dummy; ++ if (realloc_hook_ptr == NULL) ++ realloc_hook_ptr = &realloc_hook_dummy; ++ if (free_hook_ptr == NULL) ++ free_hook_ptr = &free_hook_dummy; ++ if (memalign_hook_ptr == NULL) ++ memalign_hook_ptr = &memalign_hook_dummy; ++ initialized = true; ++} ++ + #include "common/algorithms/find.h" + #include "common/containers/final_action.h" + #include "common/macos-ports.h" +@@ -246,10 +276,11 @@ + void switch_hooks(bool malloc_hooks_are_replaced_before) noexcept { + php_assert(malloc_hooks_are_replaced_before == malloc_hooks_are_replaced_); + CriticalSectionGuard critical_section; +- std::swap(malloc_hook_, __malloc_hook); +- std::swap(realloc_hook_, __realloc_hook); +- std::swap(memalign_hook_, __memalign_hook); +- std::swap(free_hook_, __free_hook); ++ malloc_hook_init(); ++ std::swap(malloc_hook_, *malloc_hook_ptr); ++ std::swap(realloc_hook_, *realloc_hook_ptr); ++ std::swap(memalign_hook_, *memalign_hook_ptr); ++ std::swap(free_hook_, *free_hook_ptr); + malloc_hooks_are_replaced_ = !malloc_hooks_are_replaced_; + } + +@@ -274,10 +305,10 @@ + return script_allocator_free(ptr); + }} {} + +- decltype(__malloc_hook) malloc_hook_{nullptr}; +- decltype(__realloc_hook) realloc_hook_{nullptr}; +- decltype(__memalign_hook) memalign_hook_{nullptr}; +- decltype(__free_hook) free_hook_{nullptr}; ++ decltype(malloc_hook_dummy) malloc_hook_{nullptr}; ++ decltype(realloc_hook_dummy) realloc_hook_{nullptr}; ++ decltype(memalign_hook_dummy) memalign_hook_{nullptr}; ++ decltype(free_hook_dummy) free_hook_{nullptr}; + bool malloc_hooks_are_replaced_{false}; + }; + diff --git a/disabled-packages/kphp/runtime-files.cpp.patch b/disabled-packages/kphp/runtime-files.cpp.patch new file mode 100644 index 0000000000..e03d2fdc6d --- /dev/null +++ b/disabled-packages/kphp/runtime-files.cpp.patch @@ -0,0 +1,13 @@ +--- a/runtime/files.cpp ++++ b/runtime/files.cpp +@@ -10,6 +10,10 @@ + #include + #include + ++#ifdef __ANDROID__ ++#define __xpg_basename __posix_basename ++#endif ++ + #undef basename + + #include "common/macos-ports.h" diff --git a/disabled-packages/kphp/runtime-openssl.cpp.patch b/disabled-packages/kphp/runtime-openssl.cpp.patch new file mode 100644 index 0000000000..a94bdbfbb9 --- /dev/null +++ b/disabled-packages/kphp/runtime-openssl.cpp.patch @@ -0,0 +1,14 @@ +--- a/runtime/openssl.cpp ++++ b/runtime/openssl.cpp +@@ -21,6 +21,11 @@ + #include + #include + ++#ifdef __ANDROID__ ++#include ++#include ++#endif ++ + #include "common/crc32.h" + #include "common/resolver.h" + #include "common/smart_ptrs/unique_ptr_with_delete_function.h" diff --git a/disabled-packages/kphp/runtime-string_functions.cpp.patch b/disabled-packages/kphp/runtime-string_functions.cpp.patch new file mode 100644 index 0000000000..4452f2ac78 --- /dev/null +++ b/disabled-packages/kphp/runtime-string_functions.cpp.patch @@ -0,0 +1,13 @@ +--- a/runtime/string_functions.cpp ++++ b/runtime/string_functions.cpp +@@ -7,6 +7,10 @@ + #include + #include + ++#ifdef __ANDROID__ ++#include ++#endif ++ + #include "common/macos-ports.h" + #include "common/unicode/unicode-utils.h" + diff --git a/disabled-packages/kphp/runtime-udp.cpp.patch b/disabled-packages/kphp/runtime-udp.cpp.patch new file mode 100644 index 0000000000..3f75e9b952 --- /dev/null +++ b/disabled-packages/kphp/runtime-udp.cpp.patch @@ -0,0 +1,14 @@ +--- a/runtime/udp.cpp ++++ b/runtime/udp.cpp +@@ -8,6 +8,11 @@ + #include + #include + ++#ifdef __ANDROID__ ++#include ++#include ++#endif ++ + #include "common/resolver.h" + + #include "runtime/critical_section.h" diff --git a/disabled-packages/kphp/server-php-master-restart.cpp.patch b/disabled-packages/kphp/server-php-master-restart.cpp.patch new file mode 100644 index 0000000000..33f027c941 --- /dev/null +++ b/disabled-packages/kphp/server-php-master-restart.cpp.patch @@ -0,0 +1,78 @@ +--- a/server/php-master-restart.cpp ++++ b/server/php-master-restart.cpp +@@ -12,6 +12,48 @@ + #include + #include + ++#ifdef __ANDROID__ ++#include ++ ++static int shm_open(const char *name, int oflag, mode_t mode) { ++ size_t namelen; ++ char *fname; ++ int fd; ++ ++ /* Construct the filename. */ ++ while (name[0] == '/') ++name; ++ ++ if (name[0] == '\0') { ++ /* The name "/" is not supported. */ ++ errno = EINVAL; ++ return -1; ++ } ++ ++ namelen = strlen(name); ++ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1); ++ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1); ++ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1); ++ ++ fd = open(fname, oflag, mode); ++ if (fd != -1) { ++ /* We got a descriptor. Now set the FD_CLOEXEC bit. */ ++ int flags = fcntl(fd, F_GETFD, 0); ++ flags |= FD_CLOEXEC; ++ flags = fcntl(fd, F_SETFD, flags); ++ ++ if (flags == -1) { ++ /* Something went wrong. We cannot return the descriptor. */ ++ int save_errno = errno; ++ close(fd); ++ fd = -1; ++ errno = save_errno; ++ } ++ } ++ ++ return fd; ++} ++#endif /* __ANDROID__ */ ++ + #include "common/dl-utils-lite.h" + #include "common/kprintf.h" + #include "common/macos-ports.h" +@@ -29,8 +71,10 @@ + int err; + err = pthread_mutexattr_init(&attr); + assert (err == 0 && "failed to init mutexattr"); ++#ifndef __ANDROID__ + err = pthread_mutexattr_setrobust_np(&attr, PTHREAD_MUTEX_ROBUST_NP); + assert (err == 0 && "failed to setrobust_np for mutex"); ++#endif + err = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); + assert (err == 0 && "failed to setpshared for mutex"); + +@@ -98,11 +142,15 @@ + void shared_data_lock(shared_data_t *data) { + int err = pthread_mutex_lock(&data->main_mutex); + if (err != 0) { ++#ifdef __ANDROID__ ++ if (0) { ++#else + if (err == EOWNERDEAD) { + vkprintf(1, "owner of shared memory mutex is dead. trying to make mutex and memory consitent\n"); + + err = pthread_mutex_consistent_np(&data->main_mutex); + assert (err == 0 && "failed to make mutex constistent_np"); ++#endif + } else { + assert (0 && "unknown mutex lock error"); + } diff --git a/disabled-packages/kphp/server-php-master-restart.h.patch b/disabled-packages/kphp/server-php-master-restart.h.patch new file mode 100644 index 0000000000..94a6447230 --- /dev/null +++ b/disabled-packages/kphp/server-php-master-restart.h.patch @@ -0,0 +1,14 @@ +--- a/server/php-master-restart.h ++++ b/server/php-master-restart.h +@@ -51,7 +51,11 @@ + #if !defined(__APPLE__) + + static constexpr size_t MASTER_DATA_T_SIZEOF = 272; ++#ifdef __ANDROID__ ++static constexpr size_t SHARED_DATA_T_SIZEOF = 648; ++#else + static constexpr size_t SHARED_DATA_T_SIZEOF = 656; ++#endif + + static_assert(sizeof(master_data_t) == MASTER_DATA_T_SIZEOF, "Layout of this struct must be the same in any KPHP version unless shared data magic is used, " + "otherwise restart won't work"); diff --git a/disabled-packages/kphp/server-php-runner.cpp.patch b/disabled-packages/kphp/server-php-runner.cpp.patch new file mode 100644 index 0000000000..f184cc804a --- /dev/null +++ b/disabled-packages/kphp/server-php-runner.cpp.patch @@ -0,0 +1,13 @@ +--- a/server/php-runner.cpp ++++ b/server/php-runner.cpp +@@ -14,6 +14,10 @@ + #include + #include + ++#ifdef __ANDROID__ ++#define valloc(size) memalign(sysconf(_SC_PAGESIZE),size) ++#endif ++ + #include "common/fast-backtrace.h" + #include "common/kernel-version.h" + #include "common/kprintf.h" diff --git a/disabled-packages/kphp/server-ucontext-portable.h.patch b/disabled-packages/kphp/server-ucontext-portable.h.patch new file mode 100644 index 0000000000..127ea16703 --- /dev/null +++ b/disabled-packages/kphp/server-ucontext-portable.h.patch @@ -0,0 +1,21 @@ +--- a/server/ucontext-portable.h ++++ b/server/ucontext-portable.h +@@ -4,7 +4,7 @@ + + #pragma once + +-#if defined(__x86_64__) ++#if defined(__x86_64__) && !defined(__ANDROID__) + // for x86, we just use makecontext(), ucontext_t and other native functions + #include + +@@ -14,7 +14,8 @@ + #define makecontext_portable makecontext + #define swapcontext_portable swapcontext + +-#elif defined(__arm64__) ++#elif defined(__arm64__) || \ ++ defined(__ANDROID__) && (defined(__aarch64__) || defined(__x86_64__)) + // for M1, we can't use native makecontext() and others: they compile, but hang up when called + // instead, we require the ucontext library: https://github.com/kaniini/libucontext + // see the docs: https://vkcom.github.io/kphp/kphp-internals/developing-and-extending-kphp/compiling-kphp-from-sources.html