Skip to content

Commit

Permalink
app-emulation: Add Wine port
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwinci committed Apr 26, 2024
1 parent 491e38b commit 066423a
Show file tree
Hide file tree
Showing 2 changed files with 245 additions and 0 deletions.
146 changes: 146 additions & 0 deletions bootstrap.d/app-emulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ sources:
tag: 'v8.1.4'
version: '8.1.4'

- name: wine
subdir: 'ports'
git: 'https://gitlab.winehq.org/wine/wine.git'
tag: 'wine-9.2'
version: '9.2'
tools_required:
- host-automake-v1.15
regenerate:
- args: ['cp',
'@BUILD_ROOT@/tools/host-automake-v1.15/share/automake-1.15/config.sub',
'@THIS_SOURCE_DIR@/tools/']

tools:
- name: host-qemu
labels: [not-on-xbbs]
Expand All @@ -29,6 +41,64 @@ tools:
install:
- args: ['ninja', 'install']

- name: host-wine-tools
from_source: wine
tools_required:
- host-freetype
- host-pkg-config
- virtual: pkgconfig-for-host
program_name: host-pkg-config
configure:
- args:
- '@THIS_SOURCE_DIR@/configure'
- '--prefix=@PREFIX@'
- '--enable-win64'
- '--disable-tests'
- '--disable-win16'
- '--without-alsa'
- '--without-capi'
- '--without-cups'
- '--without-dbus'
- '--without-gettext'
- '--without-gphoto'
- '--without-gssapi'
- '--without-gstreamer'
- '--without-krb5'
- '--without-mingw'
- '--without-netapi'
- '--without-opencl'
- '--without-osmesa'
- '--without-oss'
- '--without-pcap'
- '--without-pulse'
- '--without-sane'
- '--without-sdl'
- '--without-unwind'
- '--without-usb'
- '--without-v4l2'
- '--without-vulkan'
- '--without-xcomposite'
- '--without-xinerama'
- '--without-xinput2'
- '--without-xshape'
- '--without-xcursor'
- '--without-xinput'
- '--without-xfixes'
- '--without-xrandr'
- '--without-xrender'
- '--without-xshape'
- '--without-xxf86vm'
- '--without-xshm'
- '--without-gnutls'
- '--without-opengl'
- '--without-udev'
environ:
PKG_CONFIG_LIBDIR: '@BUILD_ROOT@/tools/host-freetype/lib/pkgconfig'
compile:
- args: ['make', '-j@PARALLELISM@']
install:
- args: ['make', 'install', '-j@PARALLELISM@']

packages:
- name: qemu
architecture: '@OPTION:arch@'
Expand Down Expand Up @@ -77,3 +147,79 @@ packages:
DESTDIR: '@THIS_COLLECT_DIR@'
quiet: true

- name: wine
architecture: '@OPTION:arch@'
metadata:
summary: Free implementation of Windows(tm) on Unix, without external patchsets
description: Free implementation of Windows(tm) on Unix, without external patchsets
spdx: 'LGPL-2.1-or-later BSD-2 IJG MIT OPENLDAP ZLIB gsm libpng2 libtiff'
website: 'https://www.winehq.org'
maintainer: 'Qwinci <[email protected]>'
categories: ['app-emulation']
from_source: wine
tools_required:
- host-pkg-config
- system-gcc
- virtual: pkgconfig-for-target
triple: '@OPTION:arch-triple@'
- host-wine-tools
pkgs_required:
- mlibc
- libxcursor
- libxfixes
- libxi
- libxrandr
- libxrender
- libxxf86vm
- libxshmfence
- libx11
- libxext
- mesa
- fontconfig
# - sdl2
- gnutls
- freetype
- glib
- gst-plugins-base
- gstreamer
- eudev
- xorg-proto
configure:
- args:
- '@THIS_SOURCE_DIR@/configure'
- '--host=@OPTION:arch-triple@'
- '--prefix=/usr'
- '--disable-tests'
- '--enable-win64' # We want 64 bit after all
- '--disable-win16' # Don't care about 16 bit
- '--without-alsa'
- '--without-capi'
- '--without-cups'
- '--without-dbus'
- '--without-gettext'
- '--without-gphoto'
- '--without-gssapi'
- '--without-krb5'
- '--without-mingw' # Might want this later, but for now we don't have it
- '--without-netapi'
- '--without-opencl'
- '--without-osmesa'
- '--without-oss'
- '--without-pcap'
- '--without-pulse'
- '--without-sane'
- '--without-sdl' # Needs additional patching in wine
- '--without-unwind'
- '--without-usb'
- '--without-v4l2'
- '--without-vulkan'
- '--without-xcomposite'
- '--without-xinerama'
- '--with-x'
- '--with-wine-tools=@BUILD_ROOT@/tool-builds/host-wine-tools/'
build:
- args: ['make', '-j@PARALLELISM@']
- args: ['make', 'install', '-j@PARALLELISM@']
environ:
DESTDIR: '@THIS_COLLECT_DIR@'
quiet: true
99 changes: 99 additions & 0 deletions patches/wine/0001-Add-managarm-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
From f07b3895767beda7b19751042f9595a3891c6c3b Mon Sep 17 00:00:00 2001
From: Qwinci <[email protected]>
Date: Fri, 16 Feb 2024 00:25:36 +0200
Subject: [PATCH] Add managarm support

---
dlls/ntdll/unix/signal_x86_64.c | 39 +++++++++++++++++++++++++++++++++
dlls/ntdll/unix/system.c | 4 ++--
2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c
index ab54490..1e10a9b 100644
--- a/dlls/ntdll/unix/signal_x86_64.c
+++ b/dlls/ntdll/unix/signal_x86_64.c
@@ -75,6 +75,11 @@
#include "unix_private.h"
#include "wine/debug.h"

+#ifdef __managarm__
+#include <hel.h>
+#include <hel-syscalls.h>
+#endif
+
WINE_DEFAULT_DEBUG_CHANNEL(unwind);
WINE_DECLARE_DEBUG_CHANNEL(seh);

@@ -292,6 +297,38 @@ static inline XMM_SAVE_AREA32 *FPU_sig( const ucontext_t *context )

#define XState_sig(context) NULL

+#elif defined(__managarm__)
+
+#ifndef FP_XSTATE_MAGIC1
+#define FP_XSTATE_MAGIC1 0x46505853
+#endif
+
+#define RAX_sig(context) ((context)->uc_mcontext.gregs[REG_RAX])
+#define RBX_sig(context) ((context)->uc_mcontext.gregs[REG_RBX])
+#define RCX_sig(context) ((context)->uc_mcontext.gregs[REG_RCX])
+#define RDX_sig(context) ((context)->uc_mcontext.gregs[REG_RDX])
+#define RSI_sig(context) ((context)->uc_mcontext.gregs[REG_RSI])
+#define RDI_sig(context) ((context)->uc_mcontext.gregs[REG_RDI])
+#define RBP_sig(context) ((context)->uc_mcontext.gregs[REG_RBP])
+#define R8_sig(context) ((context)->uc_mcontext.gregs[REG_R8])
+#define R9_sig(context) ((context)->uc_mcontext.gregs[REG_R9])
+#define R10_sig(context) ((context)->uc_mcontext.gregs[REG_R10])
+#define R11_sig(context) ((context)->uc_mcontext.gregs[REG_R11])
+#define R12_sig(context) ((context)->uc_mcontext.gregs[REG_R12])
+#define R13_sig(context) ((context)->uc_mcontext.gregs[REG_R13])
+#define R14_sig(context) ((context)->uc_mcontext.gregs[REG_R14])
+#define R15_sig(context) ((context)->uc_mcontext.gregs[REG_R15])
+#define CS_sig(context) (*((WORD *)&(context)->uc_mcontext.gregs[REG_CSGSFS] + 0))
+#define GS_sig(context) (*((WORD *)&(context)->uc_mcontext.gregs[REG_CSGSFS] + 1))
+#define FS_sig(context) (*((WORD *)&(context)->uc_mcontext.gregs[REG_CSGSFS] + 2))
+#define RSP_sig(context) ((context)->uc_mcontext.gregs[REG_RSP])
+#define RIP_sig(context) ((context)->uc_mcontext.gregs[REG_RIP])
+#define EFL_sig(context) ((context)->uc_mcontext.gregs[REG_EFL])
+#define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO])
+#define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR])
+#define FPU_sig(context) ((XMM_SAVE_AREA32 *)((context)->uc_mcontext.fpregs))
+#define XState_sig(fpu) (((unsigned int *)fpu->Reserved4)[12] == FP_XSTATE_MAGIC1 ? (XSTATE *)(fpu + 1) : NULL)
+
#else
#error You must define the signal context functions for your platform
#endif
@@ -2496,6 +2533,8 @@ void call_init_thunk( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend, TEB
thread's gsbase. Have each thread record its gsbase pointer into its
TEB so alloc_tls_slot() can find it. */
teb->Instrumentation[0] = thread_data->pthread_teb;
+#elif defined(__managarm__)
+ helWriteGsBase(teb);
#else
# error Please define setting %gs for your architecture
#endif
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
index 879a589..24228ac 100644
--- a/dlls/ntdll/unix/system.c
+++ b/dlls/ntdll/unix/system.c
@@ -1369,7 +1369,7 @@ static NTSTATUS create_cpuset_info(SYSTEM_CPU_SET_INFORMATION *info)
return STATUS_SUCCESS;
}

-#if defined(linux) || defined(__APPLE__)
+#if defined(linux) || defined(__APPLE__) || defined(__managarm__)

static void copy_smbios_string( char **buffer, const char *s, size_t len )
{
@@ -1561,7 +1561,7 @@ static NTSTATUS create_smbios_tables( SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti, U

#endif

-#ifdef linux
+#if defined(linux) || defined(__managarm__)

static size_t get_smbios_string( const char *path, char *str, size_t size )
{
--
2.43.1

0 comments on commit 066423a

Please sign in to comment.