Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new package: hangover-libqemu, hangover-libfexcore #755

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tur-multilib/hangover-libfexcore/0001-aligned_alloc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- a/FEXCore/include/FEXCore/Utils/AllocatorHooks.h
+++ b/FEXCore/include/FEXCore/Utils/AllocatorHooks.h
@@ -34,6 +34,15 @@
FEX_DEFAULT_VISIBILITY JEMALLOC_NOTHROW extern void *je_aligned_alloc(size_t a, size_t s);
#undef JEMALLOC_NOTHROW
#endif
+
+#if defined(__ANDROID__) && __ANDROID_API__ < 26
+static void *aligned_alloc(size_t align, size_t size)
+{
+ void *result = NULL;
+ posix_memalign(&result, align, size);
+ return result;
+}
+#endif
}

namespace FEXCore::Allocator {
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h
+++ b/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h
@@ -9,7 +9,7 @@

#include <bitset>
#include <cstddef>
-#ifdef TERMUX_BUILD
+#if 0
#ifdef __has_include
#if __has_include(<memory_resource>)
#error Termux <experimental/memory_resource> workaround can be removed
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
https://github.com/llvm/llvm-project/issues/58145

--- a/FEXCore/CMakeLists.txt
+++ b/FEXCore/CMakeLists.txt
@@ -26,6 +26,7 @@
include(CheckIncludeFileCXX)
include(CheckCXXSourceCompiles)

+if(NOT ENABLE_TERMUX_BUILD)
set(CMAKE_REQUIRED_FLAGS "-std=c++11 -Wattributes -Werror=attributes")
check_cxx_source_compiles(
"
@@ -40,6 +41,7 @@
if (HAS_CLANG_PRESERVE_ALL)
message(STATUS "Has clang::preserve_all")
endif ()
+endif()

if (EXISTS ${CMAKE_CURRENT_DIR}/External/vixl/)
# Useful to have for freestanding libFEXCore
14 changes: 14 additions & 0 deletions tur-multilib/hangover-libfexcore/0004-getrandom.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/Source/Tools/FEXLoader/ELFCodeLoader.h
+++ b/Source/Tools/FEXLoader/ELFCodeLoader.h
@@ -37,6 +37,11 @@
#include <sys/personality.h>
#include <sys/random.h>

+#if defined __ANDROID__ && __ANDROID_API__ < 28
+#include <syscall.h>
+#define getrandom(buf,buflen,flags) syscall(SYS_getrandom,buf,buflen,flags)
+#endif
+
#define PAGE_START(x) ((x) & ~(uintptr_t)(4095))
#define PAGE_OFFSET(x) ((x) & 4095)
#define PAGE_ALIGN(x) (((x) + 4095) & ~(uintptr_t)(4095))
14 changes: 14 additions & 0 deletions tur-multilib/hangover-libfexcore/0005-getcpu.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/Source/Tools/FEXLoader/VDSO_Emulation.cpp
+++ b/Source/Tools/FEXLoader/VDSO_Emulation.cpp
@@ -253,7 +253,11 @@
int rv;
} *args = reinterpret_cast<ArgsRV_t*>(ArgsRV);

+#ifndef __ANDROID__
int Result = ::getcpu(args->cpu, args->node);
+#else
+ int Result = ::syscall(SYS_getcpu, args->cpu, args->node, nullptr);
+#endif
args->rv = SyscallRet(Result);
}
}
13 changes: 13 additions & 0 deletions tur-multilib/hangover-libfexcore/0006-elf-macros.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/Source/Tools/FEXLoader/VDSO_Emulation.cpp
+++ b/Source/Tools/FEXLoader/VDSO_Emulation.cpp
@@ -18,6 +18,10 @@
#include <sys/time.h>
#include <unistd.h>

+#ifndef ELF32_ST_VISIBILITY
+#define ELF32_ST_VISIBILITY(o) ((o) & 0x3)
+#endif
+
namespace FEX::VDSO {
FEXCore::Context::VDSOSigReturn VDSOPointers{};
namespace VDSOHandlers {
22 changes: 22 additions & 0 deletions tur-multilib/hangover-libfexcore/0007-unqualified-id.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/Source/Tools/FEXLoader/LinuxSyscalls/SignalDelegator.cpp
+++ b/Source/Tools/FEXLoader/LinuxSyscalls/SignalDelegator.cpp
@@ -896,7 +896,9 @@

// 32-bit Guest can provide its own restorer or we need to provide our own.
// On a real host this restorer will live in VDSO.
+#ifndef SA_RESTORER
constexpr uint32_t SA_RESTORER = 0x04000000;
+#endif
const bool HasRestorer = (GuestAction->sa_flags & SA_RESTORER) == SA_RESTORER;
if (HasRestorer) {
guest_uctx->pretcode = (uint32_t)(uint64_t)GuestAction->restorer;
@@ -1109,7 +1111,9 @@

// 32-bit Guest can provide its own restorer or we need to provide our own.
// On a real host this restorer will live in VDSO.
+#ifndef SA_RESTORER
constexpr uint32_t SA_RESTORER = 0x04000000;
+#endif
const bool HasRestorer = (GuestAction->sa_flags & SA_RESTORER) == SA_RESTORER;
if (HasRestorer) {
guest_uctx->pretcode = (uint32_t)(uint64_t)GuestAction->restorer;
86 changes: 86 additions & 0 deletions tur-multilib/hangover-libfexcore/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
TERMUX_PKG_HOMEPAGE=https://github.com/AndreRH/FEX
TERMUX_PKG_DESCRIPTION="x86 and x86-64 Linux emulator library for Hangover"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux-user-repository"
TERMUX_PKG_VERSION=8.17
TERMUX_PKG_SRCURL=git+https://github.com/AndreRH/FEX
TERMUX_PKG_GIT_BRANCH="hangover-8.17"
TERMUX_PKG_DEPENDS="libandroid-shmem, libc++"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DBUILD_TESTS=OFF
-DENABLE_LTO=OFF
-DENABLE_JEMALLOC=OFF
-DENABLE_JEMALLOC_GLIBC_ALLOC=OFF
-DENABLE_OFFLINE_TELEMETRY=OFF
-DENABLE_TERMUX_BUILD=True
-DTUNE_CPU=generic
-DTUNE_ARCH=armv8-a
"
TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686, x86_64"

TERMUX_PKG_HOSTBUILD=true

termux_step_post_get_source() {
# Remove this marker all the time
rm -rf $TERMUX_HOSTBUILD_MARKER
}

_setup_llvm_mingw_toolchain() {
# LLVM-mingw's version number must not be the same as the NDK's.
local _llvm_mingw_version=16
local _version="20230614"
local _url="https://github.com/mstorsjo/llvm-mingw/releases/download/$_version/llvm-mingw-$_version-ucrt-ubuntu-20.04-x86_64.tar.xz"
local _path="$TERMUX_PKG_CACHEDIR/$(basename $_url)"
local _sha256sum=9ae925f9b205a92318010a396170e69f74be179ff549200e8122d3845ca243b8
termux_download $_url $_path $_sha256sum
local _extract_path="$TERMUX_PKG_CACHEDIR/llvm-mingw-toolchain-$_llvm_mingw_version"
if [ ! -d "$_extract_path" ]; then
mkdir -p "$_extract_path"-tmp
tar -C "$_extract_path"-tmp --strip-component=1 -xf "$_path"
mv "$_extract_path"-tmp "$_extract_path"
fi
export PATH="$PATH:$_extract_path/bin"
}

termux_step_host_build() {
termux_setup_cmake

# Setup llvm-mingw toolchain
_setup_llvm_mingw_toolchain

# Make fex wow64 dlls
cmake -DCMAKE_TOOLCHAIN_FILE=$TERMUX_PKG_SRCDIR/toolchain_mingw.cmake \
-DENABLE_JEMALLOC=0 -DENABLE_JEMALLOC_GLIBC_ALLOC=0 \
-DMINGW_TRIPLE=aarch64-w64-mingw32 \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_TESTS=False \
-DENABLE_ASSERTIONS=False \
$TERMUX_PKG_SRCDIR

make -j $TERMUX_MAKE_PROCESSES -k wow64fex || bash
}

termux_step_pre_configure() {
find $TERMUX_PKG_SRCDIR -name '*.h' -o -name '*.c' -o -name '*.cpp' | \
xargs -n 1 sed -i -e 's:"/tmp:"'$TERMUX_PREFIX'/tmp:g'
}

termux_step_make() {
ninja -j $TERMUX_MAKE_PROCESSES -k 0 FEXCore_shared || bash
}

termux_step_make_install() {
# Install libfexcore
cp $TERMUX_PKG_BUILDDIR/FEXCore/Source/libFEXCore.so $TERMUX_PREFIX/lib/

# Install WOW64Fex
mkdir -p $TERMUX_PREFIX/lib/wine/aarch64-windows
cp $TERMUX_PKG_HOSTBUILD_DIR/Bin/libwow64fex.dll $TERMUX_PREFIX/lib/wine/aarch64-windows/
# Patch dll to be picked up by wineboot
# https://github.com/termux-user-repository/tur/issues/749#issuecomment-1871500069
echo -n "Wine builtin DLL" > /tmp/builtin.template.1
dd if=/dev/zero of=/tmp/builtin.template.2 bs=16 count=1
cat /tmp/builtin.template.1 /tmp/builtin.template.2 > /tmp/builtin.template
dd if=/tmp/builtin.template of=$TERMUX_PREFIX/lib/wine/aarch64-windows/libwow64fex.dll bs=32 count=1 seek=2 conv=notrunc
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TERMUX_SUBPKG_INCLUDE="lib/wine/aarch64-windows/libwow64fex.dll"
TERMUX_SUBPKG_DESCRIPTION="x86 and x86-64 Linux emulator library for Hangover"
TERMUX_SUBPKG_DEPEND_ON_PARENT=no
53 changes: 53 additions & 0 deletions tur-multilib/hangover-libqemu/0000-android-config-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
diff -uNr qemu-5.2.0/configure qemu-5.2.0.mod/configure
--- qemu-5.2.0/configure 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/configure 2020-12-09 16:24:26.073781672 +0200
@@ -2931,6 +2931,8 @@
fi

has_libgcrypt() {
+ return 0
+
if ! has "libgcrypt-config"
then
return 1
@@ -3000,10 +3002,7 @@
# Debian has removed -lgpg-error from libgcrypt-config
# as it "spreads unnecessary dependencies" which in
# turn breaks static builds...
- if test "$static" = "yes"
- then
- gcrypt_libs="$gcrypt_libs -lgpg-error"
- fi
+ gcrypt_libs="$gcrypt_libs -lgpg-error"

# Link test to make sure the given libraries work (e.g for static).
write_c_skeleton
@@ -4097,6 +4096,7 @@
if compile_prog "" "" ; then
signalfd=yes
fi
+signalfd=no

# check if optreset global is declared by <getopt.h>
optreset="no"
@@ -5973,6 +5973,7 @@
if test "$darwin" = "yes" ; then
echo "CONFIG_DARWIN=y" >> $config_host_mak
fi
+ivshmem=no

if test "$solaris" = "yes" ; then
echo "CONFIG_SOLARIS=y" >> $config_host_mak
@@ -6088,9 +6089,9 @@
if test "$posix_fallocate" = "yes" ; then
echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
fi
-if test "$sync_file_range" = "yes" ; then
- echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
-fi
+#if test "$sync_file_range" = "yes" ; then
+# echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
+#fi
if test "$fiemap" = "yes" ; then
echo "CONFIG_FIEMAP=y" >> $config_host_mak
fi
Loading