Contents
Porting Wine to FreeBSD
Wine is an open source implementation of a Windows application environment, which allows running Windows programs on other operating systems.
It is a complex piece of software, that relies on various parts of the underlying operating system. This page is meant to collect various bits of information about Wine on FreeBSD to assist in porting.
Status
On FreeBSD 7.0 and later versions, Wine should work for most user applications. Games tend to be more problematic, but it's worth trying.
For FreeBSD 6.3 and later a kernel patch is available below.
Sound output is often garbled. If that happens to you, in winecfg, at the bottom of the sound tab, try to set hardware acceleration to emulation instead of full.
If you run into bugs, feel free to file a bug report in the Wine bugzilla and mention the version of FreeBSD you're using.
Open Tasks
port iphlpapi.dll: The test results seem to indicate that the current implementation depends on the Linux /proc file system, so somebody needs to add an #elif defined(__FreeBSD__) case that uses sysctl.
freebsd-amd64: Some Windows apps use the segment registers (%ds, %es, %fs, %gs), but these registers aren't preserved during context switches. (see also this email)
- Wine allocates LDT entries statically. This could possibly be done dynamically to get rid of (harmless, but annoying) warning messages like:
Warning: pid 65758 used static ldt allocation. See the i386_set_ldt man page for more info
- DOS support (vm86)
- add kqueue(?) support to server/change.c
- port missing bits in dlls/ntdll/cdrom.c
- copy protection support (securom, safedisc, etc.)
sound support, specifically with hardware acceleration set to full in winecfg (see wine/9599)
More Wine Bug Reports
Work In Progress
Wine Loader mmap Problem
An executable loaded in memory basically consists of a read-only (code) segment and a writable data segment. The address after the data segment is called the break and you can change it (allocating/deallocating) with brk(2) and sbrk(2). There's a limit on the size of the data segment (which can be set system-wide with kern.maxdsiz in /boot/loader.conf). The default value is 512M. Mmap on freebsd preserves this space and looks for free space after datasegment+maxdsiz. This works quite well for every normal unix program. The wine executable however is linked with:
-Wl,--section-start,.interp=0x7bf00400
This basically means the executable is located at 0x7bf00000. So, if maxdsiz is 512M, wine can't mmap the shared heap at 0x80000000 for instance (unless it would use MAP_FIXED, but that's too risky, because if maxdsiz is something smaller, libs can be mmap'ed there).
Until a better solution is found, the current workaround is reduce the data segment size to 32M.
Related bug reports: wine/5732, kern/94413
See also: http://www.winehq.org/pipermail/wine-devel/2007-September/059426.html
Ptrace race
There's a race in the FreeBSD ptrace(2) implementation that causes Wine to hang sometimes. A typical example is winedbg hanging.
More info: http://lists.freebsd.org/pipermail/freebsd-hackers/2007-August/021430.html
Patches
Patching FreeBSD 6.3-RELEASE and 6-STABLE: attachment:patch-fbsd-6
cd /usr/src patch < /path/to/patch-fbsd-6 cd /usr/src/sys/compat/freebsd32 make sysent cd /usr/src/sys/kern make sysent cd /usr/src make buildworld buildkernel ...install kernel+world as described in the handbook... cd /usr/ports/emulators/wine make deinstall clean install
Patching Wine (optional): attachment:patch-kthread
This patch enables wine-kthread. After applying it and rebuilding Wine, you can run programs with: wine-kthread program.exe
cd /usr/ports/emulators/wine cp /path/to/patch-kthread files/ make deinstall clean install
Mailing Lists
You can use one of the following mailing lists:
freebsd-emulation@freebsd.org: Wine topics specifically related to FreeBSD.
wine-devel@winehq.org: General Wine developers mailing list.
wine-users@winehq.org: General Wine users mailing list.