diff --git a/disabled-packages/fex/FEXCore-Source-Common-JitSymbols.patch b/disabled-packages/fex/FEXCore-Source-Common-JitSymbols.patch new file mode 100644 index 0000000000..35dae7ace6 --- /dev/null +++ b/disabled-packages/fex/FEXCore-Source-Common-JitSymbols.patch @@ -0,0 +1,16 @@ +diff --git a/FEXCore/Source/Common/JitSymbols.cpp b/FEXCore/Source/Common/JitSymbols.cpp +index 662215c..7329773 100644 +--- a/FEXCore/Source/Common/JitSymbols.cpp ++++ b/FEXCore/Source/Common/JitSymbols.cpp +@@ -20,9 +20,9 @@ namespace FEXCore { + // We can't use FILE here since we must be robust against forking processes closing our FD from under us. + #ifdef __ANDROID__ + // Android simpleperf looks in /data/local/tmp instead of /tmp +- const auto PerfMap = fextl::fmt::format("/data/local/tmp/perf-{}.map", getpid()); ++ const auto PerfMap = fextl::fmt::format("@TERMUX_PREFIX@/tmp/perf-{}.map", getpid()); + #else +- const auto PerfMap = fextl::fmt::format("/tmp/perf-{}.map", getpid()); ++ const auto PerfMap = fextl::fmt::format("@TERMUX_PREFIX@/tmp/perf-{}.map", getpid()); + #endif + fd = open(PerfMap.c_str(), O_CREAT | O_TRUNC | O_WRONLY | O_APPEND, 0644); + } diff --git a/disabled-packages/fex/FEXCore-include-FEXCore-Utils-AllocatorHooks.patch b/disabled-packages/fex/FEXCore-include-FEXCore-Utils-AllocatorHooks.patch new file mode 100644 index 0000000000..c9d2dd1abb --- /dev/null +++ b/disabled-packages/fex/FEXCore-include-FEXCore-Utils-AllocatorHooks.patch @@ -0,0 +1,42 @@ +diff --git a/FEXCore/include/FEXCore/Utils/AllocatorHooks.h b/FEXCore/include/FEXCore/Utils/AllocatorHooks.h +index 85d2d91..9997d03 100644 +--- a/FEXCore/include/FEXCore/Utils/AllocatorHooks.h ++++ b/FEXCore/include/FEXCore/Utils/AllocatorHooks.h +@@ -117,16 +117,37 @@ namespace FEXCore::Allocator { + inline void *valloc(size_t size) + { + #ifdef __ANDROID__ ++#if __ANDROID_API__ < 28 ++ // https://github.com/llvm/llvm-project/blob/main/libcxx/include/__memory/aligned_alloc.h ++ // https://android.googlesource.com/platform/bionic/+/main/libc/platform/bionic/page.h ++ // alignment = 1 segfault in Android, 4096 is the minimum ++ void* __result = nullptr; ++ (void)::posix_memalign(&__result, 4096, size); ++ return __result; ++#else + return ::aligned_alloc(4096, size); ++#endif + #else + return ::valloc(size); + #endif + } ++#ifdef __ANDROID__ ++ inline int posix_memalign(void** r, size_t a, size_t s) { return ::posix_memalign(r, 4096, s); } ++#else + inline int posix_memalign(void** r, size_t a, size_t s) { return ::posix_memalign(r, a, s); } ++#endif + inline void *realloc(void* ptr, size_t size) { return ::realloc(ptr, size); } + inline void free(void* ptr) { return ::free(ptr); } + inline size_t malloc_usable_size(void *ptr) { return ::malloc_usable_size(ptr); } ++#if defined(__ANDROID__) && __ANDROID_API__ < 28 ++ inline void *aligned_alloc(size_t a, size_t s) { ++ void* __result = nullptr; ++ (void)::posix_memalign(&__result, 4096, s); ++ return __result; ++ } ++#else + inline void *aligned_alloc(size_t a, size_t s) { return ::aligned_alloc(a, s); } ++#endif + inline void aligned_free(void* ptr) { return ::free(ptr); } + #endif + diff --git a/disabled-packages/fex/FEXCore-unittests-APITests-FileLoading.patch b/disabled-packages/fex/FEXCore-unittests-APITests-FileLoading.patch new file mode 100644 index 0000000000..029798b662 --- /dev/null +++ b/disabled-packages/fex/FEXCore-unittests-APITests-FileLoading.patch @@ -0,0 +1,13 @@ +diff --git a/FEXCore/unittests/APITests/FileLoading.cpp b/FEXCore/unittests/APITests/FileLoading.cpp +index e1b7169..2f20314 100644 +--- a/FEXCore/unittests/APITests/FileLoading.cpp ++++ b/FEXCore/unittests/APITests/FileLoading.cpp +@@ -3,7 +3,7 @@ + + TEST_CASE("LoadFile-Doesn'tExist") { + fextl::string MapsFile; +- auto Read = FEXCore::FileLoading::LoadFile(MapsFile, "/tmp/a/b/c/d/e/z"); ++ auto Read = FEXCore::FileLoading::LoadFile(MapsFile, "@TERMUX_PREFIX@/tmp/a/b/c/d/e/z"); + REQUIRE(MapsFile.size() == 0); + REQUIRE(Read == false); + } diff --git a/disabled-packages/fex/Source-Common-Config.patch b/disabled-packages/fex/Source-Common-Config.patch new file mode 100644 index 0000000000..1d1bfef332 --- /dev/null +++ b/disabled-packages/fex/Source-Common-Config.patch @@ -0,0 +1,34 @@ +diff --git a/Source/Common/Config.cpp b/Source/Common/Config.cpp +index 1430479..67ca3e7 100644 +--- a/Source/Common/Config.cpp ++++ b/Source/Common/Config.cpp +@@ -392,6 +392,7 @@ namespace JSON { + FEXCore::Config::Load(); + + auto Args = FEX::ArgLoader::Get(); ++ size_t i = 0; + + if (LoadProgramConfig) { + if (Args.empty()) { +@@ -399,8 +400,19 @@ namespace JSON { + return {}; + } + +- Args[0] = RecoverGuestProgramFilename(std::move(Args[0]), ExecFDInterp, ProgramFDFromEnv); +- fextl::string& Program = Args[0]; ++ // really bad workaround for Termux Proot ++ for (size_t j=0; j + #include + ++#if defined(__ANDROID__) && __ANDROID_API__ < 30 ++#include ++#define memfd_create(name,flags) syscall(SYS_memfd_create,name,flags) ++#endif ++#ifndef MFD_CLOEXEC ++#define MFD_CLOEXEC 0x0001U ++#endif ++ + namespace FEX::EmulatedFile { + /** + * @brief Generates a temporary file using raw FDs diff --git a/disabled-packages/fex/Source-Tools-LinuxEmulation-LinuxSyscalls-SignalDelegator.patch b/disabled-packages/fex/Source-Tools-LinuxEmulation-LinuxSyscalls-SignalDelegator.patch new file mode 100644 index 0000000000..604bcce334 --- /dev/null +++ b/disabled-packages/fex/Source-Tools-LinuxEmulation-LinuxSyscalls-SignalDelegator.patch @@ -0,0 +1,23 @@ +diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp +index 0f5b166..73db0a5 100644 +--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp ++++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp +@@ -41,6 +41,18 @@ $end_info$ + #define SS_AUTODISARM (1U << 31) + #endif + ++/* ++/home/builder/.termux-build/fex/src/Source/Tools/FEXLoader/LinuxSyscalls/SignalDelegator.cpp:931:24: error: expected unqualified-id ++ constexpr uint32_t SA_RESTORER = 0x04000000; ++ ^ ++/home/builder/.termux-build/_cache/android-r26b-api-24-v0/sysroot/usr/include/aarch64-linux-android/asm/signal.h:21:21: note: expanded from macro 'SA_RESTORER' ++#define SA_RESTORER 0x04000000 ++ ^ ++*/ ++#ifdef SA_RESTORER ++#undef SA_RESTORER ++#endif ++ + namespace FEX::HLE { + #ifdef _M_X86_64 + __attribute__((naked)) diff --git a/disabled-packages/fex/Source-Tools-LinuxEmulation-LinuxSyscalls-Utils.patch b/disabled-packages/fex/Source-Tools-LinuxEmulation-LinuxSyscalls-Utils.patch new file mode 100644 index 0000000000..9fe459aa7b --- /dev/null +++ b/disabled-packages/fex/Source-Tools-LinuxEmulation-LinuxSyscalls-Utils.patch @@ -0,0 +1,19 @@ +diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Utils/Threads.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Utils/Threads.cpp +index d49f05c..fb7732f 100644 +--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Utils/Threads.cpp ++++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Utils/Threads.cpp +@@ -31,8 +31,13 @@ namespace FEX::LinuxEmulation::Threads { + // Keep the first item in the stack pool + void *Ptr{}; + +- for (auto it = DeadStackPool.begin(); it != DeadStackPool.end();) { ++ /* ++ /home/builder/.termux-build/fex/src/Source/Tools/LinuxEmulation/LinuxSyscalls/Utils/Threads.cpp: error: no member named 'atomic_ref' in namespace 'std' + auto Ready = std::atomic_ref(it->ReadyToBeReaped); ++ ~~~~~^ ++ */ ++ for (auto it = DeadStackPool.begin(); it != DeadStackPool.end();) { ++ std::atomic Ready(it->ReadyToBeReaped); + bool ReadyToBeReaped = Ready.load(); + if (Ptr == nullptr && ReadyToBeReaped) { + Ptr = it->Ptr; diff --git a/disabled-packages/fex/Source-Tools-LinuxEmulation-LinuxSyscalls-x64.patch b/disabled-packages/fex/Source-Tools-LinuxEmulation-LinuxSyscalls-x64.patch new file mode 100644 index 0000000000..c568c92bdc --- /dev/null +++ b/disabled-packages/fex/Source-Tools-LinuxEmulation-LinuxSyscalls-x64.patch @@ -0,0 +1,28 @@ +diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Memory.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Memory.cpp +index 1dbe51d..bda4bc4 100644 +--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Memory.cpp ++++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Memory.cpp +@@ -103,9 +103,10 @@ namespace FEX::HLE::x64 { + SYSCALL_ERRNO(); + }); + ++ #undef shmat + REGISTER_SYSCALL_IMPL_X64_FLAGS(shmat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + [](FEXCore::Core::CpuStateFrame *Frame, int shmid, const void *shmaddr, int shmflg) -> uint64_t { +- uint64_t Result = reinterpret_cast(shmat(shmid, shmaddr, shmflg)); ++ uint64_t Result = reinterpret_cast(::libandroid_shmat(shmid, shmaddr, shmflg)); + + if (Result != -1) { + FEX::HLE::_SyscallHandler->TrackShmat(Frame->Thread, shmid, Result, shmflg); +@@ -113,9 +114,10 @@ namespace FEX::HLE::x64 { + SYSCALL_ERRNO(); + }); + ++ #undef shmdt + REGISTER_SYSCALL_IMPL_X64_FLAGS(shmdt, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + [](FEXCore::Core::CpuStateFrame *Frame, const void *shmaddr) -> uint64_t { +- uint64_t Result = ::shmdt(shmaddr); ++ uint64_t Result = ::libandroid_shmdt(shmaddr); + + if (Result != -1) { + FEX::HLE::_SyscallHandler->TrackShmdt(Frame->Thread, (uintptr_t)shmaddr); diff --git a/disabled-packages/fex/Source-Tools-LinuxEmulation-VDSO_Emulation.patch b/disabled-packages/fex/Source-Tools-LinuxEmulation-VDSO_Emulation.patch new file mode 100644 index 0000000000..a9982db2e3 --- /dev/null +++ b/disabled-packages/fex/Source-Tools-LinuxEmulation-VDSO_Emulation.patch @@ -0,0 +1,25 @@ +diff --git a/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp b/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp +index 75f05c8..a5b622f 100644 +--- a/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp ++++ b/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp +@@ -18,6 +18,11 @@ + #include + #include + ++// Add macros which are missing in some versions of ++#ifndef ELF32_ST_VISIBILITY ++#define ELF32_ST_VISIBILITY(o) ((o) & 0x3) ++#endif ++ + namespace FEX::VDSO { + FEXCore::Context::VDSOSigReturn VDSOPointers{}; + namespace VDSOHandlers { +@@ -253,7 +258,7 @@ namespace FEX::VDSO { + int rv; + } *args = reinterpret_cast(ArgsRV); + +- int Result = ::getcpu(args->cpu, args->node); ++ int Result = FHU::Syscalls::getcpu(args->cpu, args->node); + args->rv = SyscallRet(Result); + } + } diff --git a/disabled-packages/fex/Source-Tools-pidof-pidof.patch b/disabled-packages/fex/Source-Tools-pidof-pidof.patch new file mode 100644 index 0000000000..d1e888bbb6 --- /dev/null +++ b/disabled-packages/fex/Source-Tools-pidof-pidof.patch @@ -0,0 +1,13 @@ +diff --git a/Source/Tools/pidof/pidof.cpp b/Source/Tools/pidof/pidof.cpp +index 568c84c..86dee1f 100644 +--- a/Source/Tools/pidof/pidof.cpp ++++ b/Source/Tools/pidof/pidof.cpp +@@ -52,7 +52,7 @@ void LoadOptions(int argc, char **argv) { + Separator = Options["d"]; + + for (const auto &Omit: Options.all("o")) { +- std::istringstream ss{Omit}; ++ std::istringstream ss{Omit.c_str()}; + std::string sub; + while (std::getline(ss, sub, ',')) { + int64_t pid; diff --git a/packages/fex/build.sh b/disabled-packages/fex/build.sh similarity index 94% rename from packages/fex/build.sh rename to disabled-packages/fex/build.sh index f3cf7de455..a16253fd99 100644 --- a/packages/fex/build.sh +++ b/disabled-packages/fex/build.sh @@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=https://fex-emu.com/ TERMUX_PKG_DESCRIPTION="Fast x86 emulation frontend" TERMUX_PKG_LICENSE="MIT" TERMUX_PKG_MAINTAINER="@termux" -TERMUX_PKG_VERSION=2312.1 +TERMUX_PKG_VERSION=2404 TERMUX_PKG_SRCURL=git+https://github.com/FEX-Emu/FEX TERMUX_PKG_GIT_BRANCH=FEX-${TERMUX_PKG_VERSION} TERMUX_PKG_DEPENDS="libandroid-shmem, libc++" @@ -11,13 +11,13 @@ TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686, x86_64" TERMUX_PKG_AUTO_UPDATE=true TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" -DBUILD_TESTS=OFF +-DBUILD_FEXCONFIG=OFF -DENABLE_ASSERTIONS=ON -DENABLE_GDB_SYMBOLS=ON -DENABLE_JEMALLOC=OFF -DENABLE_JEMALLOC_GLIBC_ALLOC=OFF -DENABLE_LTO=OFF -DENABLE_OFFLINE_TELEMETRY=OFF --DENABLE_TERMUX_BUILD=ON -DHAS_CLANG_PRESERVE_ALL=OFF -DTUNE_ARCH=armv8-a -DTUNE_CPU=generic @@ -30,6 +30,7 @@ termux_pkg_auto_update() { } termux_step_pre_configure() { + LDFLAGS+=" -landroid-shmem" find "${TERMUX_PKG_SRCDIR}" -name '*.h' -o -name '*.c' -o -name '*.cpp' | \ xargs -P"${TERMUX_MAKE_PROCESSES}" -n1 \ sed \ diff --git a/packages/fex/fex.patch b/packages/fex/fex.patch deleted file mode 100644 index af3030aaa7..0000000000 --- a/packages/fex/fex.patch +++ /dev/null @@ -1,210 +0,0 @@ -diff --git a/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h b/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h -index 97a879a03..436fd16ee 100644 ---- a/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h -+++ b/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h -@@ -9,19 +9,21 @@ - - #include - #include --#ifdef TERMUX_BUILD -+ - #ifdef __has_include - #if __has_include() --#error Termux workaround can be removed --#endif --#endif -+#include -+namespace fex_pmr = std::pmr; -+#else - #include - #include - namespace fex_pmr = std::experimental::pmr; -+#endif - #else - #include - namespace fex_pmr = std::pmr; - #endif -+ - #include - - #include -diff --git a/FEXCore/include/FEXCore/Utils/AllocatorHooks.h b/FEXCore/include/FEXCore/Utils/AllocatorHooks.h -index 85d2d914d..9997d03cb 100644 ---- a/FEXCore/include/FEXCore/Utils/AllocatorHooks.h -+++ b/FEXCore/include/FEXCore/Utils/AllocatorHooks.h -@@ -117,16 +117,37 @@ namespace FEXCore::Allocator { - inline void *valloc(size_t size) - { - #ifdef __ANDROID__ -+#if __ANDROID_API__ < 28 -+ // https://github.com/llvm/llvm-project/blob/main/libcxx/include/__memory/aligned_alloc.h -+ // https://android.googlesource.com/platform/bionic/+/main/libc/platform/bionic/page.h -+ // alignment = 1 segfault in Android, 4096 is the minimum -+ void* __result = nullptr; -+ (void)::posix_memalign(&__result, 4096, size); -+ return __result; -+#else - return ::aligned_alloc(4096, size); -+#endif - #else - return ::valloc(size); - #endif - } -+#ifdef __ANDROID__ -+ inline int posix_memalign(void** r, size_t a, size_t s) { return ::posix_memalign(r, 4096, s); } -+#else - inline int posix_memalign(void** r, size_t a, size_t s) { return ::posix_memalign(r, a, s); } -+#endif - inline void *realloc(void* ptr, size_t size) { return ::realloc(ptr, size); } - inline void free(void* ptr) { return ::free(ptr); } - inline size_t malloc_usable_size(void *ptr) { return ::malloc_usable_size(ptr); } -+#if defined(__ANDROID__) && __ANDROID_API__ < 28 -+ inline void *aligned_alloc(size_t a, size_t s) { -+ void* __result = nullptr; -+ (void)::posix_memalign(&__result, 4096, s); -+ return __result; -+ } -+#else - inline void *aligned_alloc(size_t a, size_t s) { return ::aligned_alloc(a, s); } -+#endif - inline void aligned_free(void* ptr) { return ::free(ptr); } - #endif - -diff --git a/Source/Common/Config.cpp b/Source/Common/Config.cpp -index 5d6cfed33..74918edd1 100644 ---- a/Source/Common/Config.cpp -+++ b/Source/Common/Config.cpp -@@ -371,6 +371,7 @@ namespace JSON { - FEXCore::Config::Load(); - - auto Args = FEX::ArgLoader::Get(); -+ size_t i = 0; - - if (LoadProgramConfig) { - if (Args.empty()) { -@@ -378,8 +379,19 @@ namespace JSON { - return {}; - } - -- Args[0] = RecoverGuestProgramFilename(std::move(Args[0]), ExecFDInterp, ProgramFDFromEnv); -- fextl::string& Program = Args[0]; -+ // really bad workaround for Termux Proot -+ for (size_t j=0; j - #include - -+#if defined(__ANDROID__) && __ANDROID_API__ < 30 -+#include -+#define memfd_create(name,flags) syscall(SYS_memfd_create,name,flags) -+#endif -+#ifndef MFD_CLOEXEC -+#define MFD_CLOEXEC 0x0001U -+#endif -+ - namespace FEX::EmulatedFile { - /** - * @brief Generates a temporary file using raw FDs -diff --git a/Source/Tools/FEXLoader/LinuxSyscalls/SignalDelegator.cpp b/Source/Tools/FEXLoader/LinuxSyscalls/SignalDelegator.cpp -index db49bc7dc..99638dbec 100644 ---- a/Source/Tools/FEXLoader/LinuxSyscalls/SignalDelegator.cpp -+++ b/Source/Tools/FEXLoader/LinuxSyscalls/SignalDelegator.cpp -@@ -40,6 +40,18 @@ $end_info$ - #define SS_AUTODISARM (1U << 31) - #endif - -+/* -+/home/builder/.termux-build/fex/src/Source/Tools/FEXLoader/LinuxSyscalls/SignalDelegator.cpp:931:24: error: expected unqualified-id -+ constexpr uint32_t SA_RESTORER = 0x04000000; -+ ^ -+/home/builder/.termux-build/_cache/android-r26b-api-24-v0/sysroot/usr/include/aarch64-linux-android/asm/signal.h:21:21: note: expanded from macro 'SA_RESTORER' -+#define SA_RESTORER 0x04000000 -+ ^ -+*/ -+#ifdef SA_RESTORER -+#undef SA_RESTORER -+#endif -+ - namespace FEX::HLE { - #ifdef _M_X86_64 - __attribute__((naked)) -diff --git a/Source/Tools/FEXLoader/VDSO_Emulation.cpp b/Source/Tools/FEXLoader/VDSO_Emulation.cpp -index 0572ec148..b8e642267 100644 ---- a/Source/Tools/FEXLoader/VDSO_Emulation.cpp -+++ b/Source/Tools/FEXLoader/VDSO_Emulation.cpp -@@ -18,6 +18,15 @@ - #include - #include - -+// Add macros which are missing in some versions of -+#ifndef ELF32_ST_VISIBILITY -+#define ELF32_ST_VISIBILITY(o) ((o) & 0x3) -+#endif -+ -+#ifndef ELF64_ST_VISIBILITY -+#define ELF64_ST_VISIBILITY(o) ((o) & 0x3) -+#endif -+ - namespace FEX::VDSO { - FEXCore::Context::VDSOSigReturn VDSOPointers{}; - namespace VDSOHandlers { -@@ -253,7 +262,7 @@ namespace FEX::VDSO { - int rv; - } *args = reinterpret_cast(ArgsRV); - -- int Result = ::getcpu(args->cpu, args->node); -+ int Result = FHU::Syscalls::getcpu(args->cpu, args->node); - args->rv = SyscallRet(Result); - } - }