Skip to content

Commit 77fde83

Browse files
committed
app-emulation: Add Wine port
1 parent 491e38b commit 77fde83

2 files changed

Lines changed: 243 additions & 0 deletions

File tree

bootstrap.d/app-emulation.yml

Lines changed: 144 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.7'
12+
version: '9.7'
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,63 @@ 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-xxf86vm'
90+
- '--without-xshm'
91+
- '--without-gnutls'
92+
- '--without-opengl'
93+
- '--without-udev'
94+
environ:
95+
PKG_CONFIG_LIBDIR: '@BUILD_ROOT@/tools/host-freetype/lib/pkgconfig'
96+
compile:
97+
- args: ['make', '-j@PARALLELISM@']
98+
install:
99+
- args: ['make', 'install', '-j@PARALLELISM@']
100+
32101
packages:
33102
- name: qemu
34103
architecture: '@OPTION:arch@'
@@ -77,3 +146,78 @@ packages:
77146
DESTDIR: '@THIS_COLLECT_DIR@'
78147
quiet: true
79148

149+
- name: wine
150+
architecture: '@OPTION:arch@'
151+
metadata:
152+
summary: Free implementation of Windows(tm) on Unix, without external patchsets
153+
description: Free implementation of Windows(tm) on Unix, without external patchsets
154+
spdx: 'LGPL-2.1-or-later BSD-2 IJG MIT OPENLDAP ZLIB gsm libpng2 libtiff'
155+
website: 'https://www.winehq.org'
156+
maintainer: 'Qwinci <qwinci222@gmail.com>'
157+
categories: ['app-emulation']
158+
from_source: wine
159+
tools_required:
160+
- host-pkg-config
161+
- system-gcc
162+
- virtual: pkgconfig-for-target
163+
triple: '@OPTION:arch-triple@'
164+
- host-wine-tools
165+
pkgs_required:
166+
- mlibc
167+
- libxcursor
168+
- libxfixes
169+
- libxi
170+
- libxrandr
171+
- libxrender
172+
- libxxf86vm
173+
- libxshmfence
174+
- libx11
175+
- libxext
176+
- mesa
177+
- fontconfig
178+
- sdl2
179+
- gnutls
180+
- freetype
181+
- glib
182+
- gst-plugins-base
183+
- gstreamer
184+
- eudev
185+
- xorg-proto
186+
configure:
187+
- args:
188+
- '@THIS_SOURCE_DIR@/configure'
189+
- '--host=@OPTION:arch-triple@'
190+
- '--prefix=/usr'
191+
- '--disable-tests'
192+
- '--enable-win64' # We want 64 bit after all
193+
- '--disable-win16' # Don't care about 16 bit
194+
- '--without-alsa'
195+
- '--without-capi'
196+
- '--without-cups'
197+
- '--without-dbus'
198+
- '--without-gettext'
199+
- '--without-gphoto'
200+
- '--without-gssapi'
201+
- '--without-krb5'
202+
- '--without-mingw' # Might want this later, but for now we don't have it
203+
- '--without-netapi'
204+
- '--without-opencl'
205+
- '--without-osmesa'
206+
- '--without-oss'
207+
- '--without-pcap'
208+
- '--without-pulse'
209+
- '--without-sane'
210+
- '--without-unwind'
211+
- '--without-usb'
212+
- '--without-v4l2'
213+
- '--without-vulkan'
214+
- '--without-xcomposite'
215+
- '--without-xinerama'
216+
- '--with-x'
217+
- '--with-wine-tools=@BUILD_ROOT@/tool-builds/host-wine-tools/'
218+
build:
219+
- args: ['make', '-j@PARALLELISM@']
220+
- args: ['make', 'install', '-j@PARALLELISM@']
221+
environ:
222+
DESTDIR: '@THIS_COLLECT_DIR@'
223+
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)