Skip to content

Commit 066423a

Browse files
committed
app-emulation: Add Wine port
1 parent 491e38b commit 066423a

2 files changed

Lines changed: 245 additions & 0 deletions

File tree

bootstrap.d/app-emulation.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ sources:
55
tag: 'v8.1.4'
66
version: '8.1.4'
77

8+
- name: wine
9+
subdir: 'ports'
10+
git: 'https://gitlab.winehq.org/wine/wine.git'
11+
tag: 'wine-9.2'
12+
version: '9.2'
13+
tools_required:
14+
- host-automake-v1.15
15+
regenerate:
16+
- args: ['cp',
17+
'@BUILD_ROOT@/tools/host-automake-v1.15/share/automake-1.15/config.sub',
18+
'@THIS_SOURCE_DIR@/tools/']
19+
820
tools:
921
- name: host-qemu
1022
labels: [not-on-xbbs]
@@ -29,6 +41,64 @@ tools:
2941
install:
3042
- args: ['ninja', 'install']
3143

44+
- name: host-wine-tools
45+
from_source: wine
46+
tools_required:
47+
- host-freetype
48+
- host-pkg-config
49+
- virtual: pkgconfig-for-host
50+
program_name: host-pkg-config
51+
configure:
52+
- args:
53+
- '@THIS_SOURCE_DIR@/configure'
54+
- '--prefix=@PREFIX@'
55+
- '--enable-win64'
56+
- '--disable-tests'
57+
- '--disable-win16'
58+
- '--without-alsa'
59+
- '--without-capi'
60+
- '--without-cups'
61+
- '--without-dbus'
62+
- '--without-gettext'
63+
- '--without-gphoto'
64+
- '--without-gssapi'
65+
- '--without-gstreamer'
66+
- '--without-krb5'
67+
- '--without-mingw'
68+
- '--without-netapi'
69+
- '--without-opencl'
70+
- '--without-osmesa'
71+
- '--without-oss'
72+
- '--without-pcap'
73+
- '--without-pulse'
74+
- '--without-sane'
75+
- '--without-sdl'
76+
- '--without-unwind'
77+
- '--without-usb'
78+
- '--without-v4l2'
79+
- '--without-vulkan'
80+
- '--without-xcomposite'
81+
- '--without-xinerama'
82+
- '--without-xinput2'
83+
- '--without-xshape'
84+
- '--without-xcursor'
85+
- '--without-xinput'
86+
- '--without-xfixes'
87+
- '--without-xrandr'
88+
- '--without-xrender'
89+
- '--without-xshape'
90+
- '--without-xxf86vm'
91+
- '--without-xshm'
92+
- '--without-gnutls'
93+
- '--without-opengl'
94+
- '--without-udev'
95+
environ:
96+
PKG_CONFIG_LIBDIR: '@BUILD_ROOT@/tools/host-freetype/lib/pkgconfig'
97+
compile:
98+
- args: ['make', '-j@PARALLELISM@']
99+
install:
100+
- args: ['make', 'install', '-j@PARALLELISM@']
101+
32102
packages:
33103
- name: qemu
34104
architecture: '@OPTION:arch@'
@@ -77,3 +147,79 @@ packages:
77147
DESTDIR: '@THIS_COLLECT_DIR@'
78148
quiet: true
79149

150+
- name: wine
151+
architecture: '@OPTION:arch@'
152+
metadata:
153+
summary: Free implementation of Windows(tm) on Unix, without external patchsets
154+
description: Free implementation of Windows(tm) on Unix, without external patchsets
155+
spdx: 'LGPL-2.1-or-later BSD-2 IJG MIT OPENLDAP ZLIB gsm libpng2 libtiff'
156+
website: 'https://www.winehq.org'
157+
maintainer: 'Qwinci <qwinci222@gmail.com>'
158+
categories: ['app-emulation']
159+
from_source: wine
160+
tools_required:
161+
- host-pkg-config
162+
- system-gcc
163+
- virtual: pkgconfig-for-target
164+
triple: '@OPTION:arch-triple@'
165+
- host-wine-tools
166+
pkgs_required:
167+
- mlibc
168+
- libxcursor
169+
- libxfixes
170+
- libxi
171+
- libxrandr
172+
- libxrender
173+
- libxxf86vm
174+
- libxshmfence
175+
- libx11
176+
- libxext
177+
- mesa
178+
- fontconfig
179+
# - sdl2
180+
- gnutls
181+
- freetype
182+
- glib
183+
- gst-plugins-base
184+
- gstreamer
185+
- eudev
186+
- xorg-proto
187+
configure:
188+
- args:
189+
- '@THIS_SOURCE_DIR@/configure'
190+
- '--host=@OPTION:arch-triple@'
191+
- '--prefix=/usr'
192+
- '--disable-tests'
193+
- '--enable-win64' # We want 64 bit after all
194+
- '--disable-win16' # Don't care about 16 bit
195+
- '--without-alsa'
196+
- '--without-capi'
197+
- '--without-cups'
198+
- '--without-dbus'
199+
- '--without-gettext'
200+
- '--without-gphoto'
201+
- '--without-gssapi'
202+
- '--without-krb5'
203+
- '--without-mingw' # Might want this later, but for now we don't have it
204+
- '--without-netapi'
205+
- '--without-opencl'
206+
- '--without-osmesa'
207+
- '--without-oss'
208+
- '--without-pcap'
209+
- '--without-pulse'
210+
- '--without-sane'
211+
- '--without-sdl' # Needs additional patching in wine
212+
- '--without-unwind'
213+
- '--without-usb'
214+
- '--without-v4l2'
215+
- '--without-vulkan'
216+
- '--without-xcomposite'
217+
- '--without-xinerama'
218+
- '--with-x'
219+
- '--with-wine-tools=@BUILD_ROOT@/tool-builds/host-wine-tools/'
220+
build:
221+
- args: ['make', '-j@PARALLELISM@']
222+
- args: ['make', 'install', '-j@PARALLELISM@']
223+
environ:
224+
DESTDIR: '@THIS_COLLECT_DIR@'
225+
quiet: true
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
From f07b3895767beda7b19751042f9595a3891c6c3b Mon Sep 17 00:00:00 2001
2+
From: Qwinci <32550582+Qwinci@users.noreply.github.com>
3+
Date: Fri, 16 Feb 2024 00:25:36 +0200
4+
Subject: [PATCH] Add managarm support
5+
6+
---
7+
dlls/ntdll/unix/signal_x86_64.c | 39 +++++++++++++++++++++++++++++++++
8+
dlls/ntdll/unix/system.c | 4 ++--
9+
2 files changed, 41 insertions(+), 2 deletions(-)
10+
11+
diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c
12+
index ab54490..1e10a9b 100644
13+
--- a/dlls/ntdll/unix/signal_x86_64.c
14+
+++ b/dlls/ntdll/unix/signal_x86_64.c
15+
@@ -75,6 +75,11 @@
16+
#include "unix_private.h"
17+
#include "wine/debug.h"
18+
19+
+#ifdef __managarm__
20+
+#include <hel.h>
21+
+#include <hel-syscalls.h>
22+
+#endif
23+
+
24+
WINE_DEFAULT_DEBUG_CHANNEL(unwind);
25+
WINE_DECLARE_DEBUG_CHANNEL(seh);
26+
27+
@@ -292,6 +297,38 @@ static inline XMM_SAVE_AREA32 *FPU_sig( const ucontext_t *context )
28+
29+
#define XState_sig(context) NULL
30+
31+
+#elif defined(__managarm__)
32+
+
33+
+#ifndef FP_XSTATE_MAGIC1
34+
+#define FP_XSTATE_MAGIC1 0x46505853
35+
+#endif
36+
+
37+
+#define RAX_sig(context) ((context)->uc_mcontext.gregs[REG_RAX])
38+
+#define RBX_sig(context) ((context)->uc_mcontext.gregs[REG_RBX])
39+
+#define RCX_sig(context) ((context)->uc_mcontext.gregs[REG_RCX])
40+
+#define RDX_sig(context) ((context)->uc_mcontext.gregs[REG_RDX])
41+
+#define RSI_sig(context) ((context)->uc_mcontext.gregs[REG_RSI])
42+
+#define RDI_sig(context) ((context)->uc_mcontext.gregs[REG_RDI])
43+
+#define RBP_sig(context) ((context)->uc_mcontext.gregs[REG_RBP])
44+
+#define R8_sig(context) ((context)->uc_mcontext.gregs[REG_R8])
45+
+#define R9_sig(context) ((context)->uc_mcontext.gregs[REG_R9])
46+
+#define R10_sig(context) ((context)->uc_mcontext.gregs[REG_R10])
47+
+#define R11_sig(context) ((context)->uc_mcontext.gregs[REG_R11])
48+
+#define R12_sig(context) ((context)->uc_mcontext.gregs[REG_R12])
49+
+#define R13_sig(context) ((context)->uc_mcontext.gregs[REG_R13])
50+
+#define R14_sig(context) ((context)->uc_mcontext.gregs[REG_R14])
51+
+#define R15_sig(context) ((context)->uc_mcontext.gregs[REG_R15])
52+
+#define CS_sig(context) (*((WORD *)&(context)->uc_mcontext.gregs[REG_CSGSFS] + 0))
53+
+#define GS_sig(context) (*((WORD *)&(context)->uc_mcontext.gregs[REG_CSGSFS] + 1))
54+
+#define FS_sig(context) (*((WORD *)&(context)->uc_mcontext.gregs[REG_CSGSFS] + 2))
55+
+#define RSP_sig(context) ((context)->uc_mcontext.gregs[REG_RSP])
56+
+#define RIP_sig(context) ((context)->uc_mcontext.gregs[REG_RIP])
57+
+#define EFL_sig(context) ((context)->uc_mcontext.gregs[REG_EFL])
58+
+#define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO])
59+
+#define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR])
60+
+#define FPU_sig(context) ((XMM_SAVE_AREA32 *)((context)->uc_mcontext.fpregs))
61+
+#define XState_sig(fpu) (((unsigned int *)fpu->Reserved4)[12] == FP_XSTATE_MAGIC1 ? (XSTATE *)(fpu + 1) : NULL)
62+
+
63+
#else
64+
#error You must define the signal context functions for your platform
65+
#endif
66+
@@ -2496,6 +2533,8 @@ void call_init_thunk( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend, TEB
67+
thread's gsbase. Have each thread record its gsbase pointer into its
68+
TEB so alloc_tls_slot() can find it. */
69+
teb->Instrumentation[0] = thread_data->pthread_teb;
70+
+#elif defined(__managarm__)
71+
+ helWriteGsBase(teb);
72+
#else
73+
# error Please define setting %gs for your architecture
74+
#endif
75+
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
76+
index 879a589..24228ac 100644
77+
--- a/dlls/ntdll/unix/system.c
78+
+++ b/dlls/ntdll/unix/system.c
79+
@@ -1369,7 +1369,7 @@ static NTSTATUS create_cpuset_info(SYSTEM_CPU_SET_INFORMATION *info)
80+
return STATUS_SUCCESS;
81+
}
82+
83+
-#if defined(linux) || defined(__APPLE__)
84+
+#if defined(linux) || defined(__APPLE__) || defined(__managarm__)
85+
86+
static void copy_smbios_string( char **buffer, const char *s, size_t len )
87+
{
88+
@@ -1561,7 +1561,7 @@ static NTSTATUS create_smbios_tables( SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti, U
89+
90+
#endif
91+
92+
-#ifdef linux
93+
+#if defined(linux) || defined(__managarm__)
94+
95+
static size_t get_smbios_string( const char *path, char *str, size_t size )
96+
{
97+
--
98+
2.43.1
99+

0 commit comments

Comments
 (0)