From owner-freebsd-current@FreeBSD.ORG Sat Nov 3 21:51:36 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6BEE599C; Sat, 3 Nov 2012 21:51:36 +0000 (UTC) (envelope-from jbeich@tormail.org) Received: from outgoing.tormail.org (outgoing.tormail.org [82.221.96.22]) by mx1.freebsd.org (Postfix) with ESMTP id F01918FC0A; Sat, 3 Nov 2012 21:51:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=internal.tormail.org) by outgoing.tormail.org with esmtp (Exim 4.72) (envelope-from ) id 1TUlcp-0004RL-Md; Sun, 04 Nov 2012 00:51:34 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tormail.org; s=tm; h=Message-Id:X-TorMail-User:Content-Type:MIME-Version:References:Date:In-Reply-To:Subject:Cc:To:From; bh=zPseYUCwQQemHgTGdN4dajz3/GGz8kdAmdcokMqYAdc=; b=OyY4TVL0q4sPMp2ERrzgUO3xu8/UO2IuHDb0JRfLb9NM9+kdN2c+a7oTgxMDHgMkHhIQKTmIyulsoD6d3ocUSOFhk0/wHOq/c/0OXMJ7wzhX9OCE24YsjecwXzL6Bb1YkaHVZY7w5lrSBb4q8bOj14O/g6paX/l499ka4+3z+dM=; Received: from jbeich by internal.tormail.org with local (Exim 4.63) (envelope-from ) id 1TUlad-0008bB-OF; Sat, 03 Nov 2012 21:49:25 +0000 From: Jan Beich To: David Naylor Subject: Re: November 5th is Clang-Day In-Reply-To: <201211030948.43530.naylor.b.david@gmail.com> (David Naylor's message of "Sat, 3 Nov 2012 09:48:40 +0200") Date: Sat, 03 Nov 2012 14:47:54 -0700 References: <20121102032945.GF65074@lor.one-eyed-alien.net> <1TU9lE-000KmO-Cc@internal.tormail.org> <201211030948.43530.naylor.b.david@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-TorMail-User: jbeich Message-Id: <1TUlad-0008bB-OF@internal.tormail.org> Cc: David Chisnall , freebsd-current@freebsd.org, Brooks Davis X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Nov 2012 21:51:36 -0000 --=-=-= Content-Type: text/plain David Naylor writes: > On Friday, 2 November 2012 10:13:30 David Chisnall wrote: > >> On 2 Nov 2012, at 05:24, Jan Beich wrote: >> >> Known Issues >> > >> > emulators/wine doesn't work with lib32 built by clang, probably due to >> > wine bugs. >> >> Is this still the case? There was an issue preventing WINE from working >> because it required stricter stack alignment than clang provided by >> default, but I thought it was fixed. Does WINE work if compiled with the >> flag that forces stack realignment? If not, then it's some other issue... > > There are two issues here: 1) wine compiled with clang, and 2) wine (compiled > with gcc) running on clang compiled base. > > Regarding 1), according to the wiki [1], wine does have stack alignment issues > and some wine programs do not run when compiled with clang [2][3] and other > bugs with clang cause freezing within wine [4][5]. The impression I get is > that, using the work-a-round of stack realignment, wine does work to some > extent when compiled by clang. Took me some time but now I can confirm that clang-built wine-1.5.16 works fine for me with gcc-built lib32 (i.e. ld-elf32.so.1 + /usr/lib32). > Regarding 2) (which I believe Jan was referring to), when I have a gcc built > world and just replace lib32 with clang built libraries I have winecfg and > regedit launching but displaying black screens. Switching back to gcc built > lib32 I get a working winecfg and regedit. This, to me, indicates a clang > error somewhere. My experience varies between clang-built and gcc-built wine. # clang, quick crash $ winecfg err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x622975ab err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x622975ab err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x622975ab Exit 5 # gcc, black rectangle $ winecfg err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x622995ab err:service:service_send_start_message service L"MountMgr" failed to start fixme:service:scmdatabase_autostart_services Auto-start service L"MountMgr" failed to start: 1053 err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x622995ab err:service:service_send_start_message service L"PlugPlay" failed to start fixme:service:scmdatabase_autostart_services Auto-start service L"PlugPlay" failed to start: 1053 err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x622995ab err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x622995ab load: 0.89 cmd: wine 14626 [piperd] 7.49r 0.03u 0.01s 0% 8932k So, why not switch stack alignment in wine (upstream)? This would make /stable/9 wine package continue to work on /head. Here's my wine package built with and without the patch. # sha256: cef5e543a5c534acb7237634224561863122ab3c256df319c6428856266d79fd http://ompldr.org/vZzR0bw/4byte-clang-wine-fbsd64-1.5.16,1.txz # sha256: 68e402bf7cb39ea48b9bef7772422cf476e89b214fd3b98ced37e0068f588c6c http://ompldr.org/vZzR0ZA/16byte-clang-wine-fbsd64-1.5.16,1.txz --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=patch-16byte-stackalign # include, winegcc: Switch to 16-byte aligned stack on FreeBSD. # # We cannot use __clang__ or __FreeBSD_version in order to stay # compatible where a package built for FreeBSD X also works on # FreeBSD X+1. --- include/windef.h~ +++ include/windef.h @@ -53,7 +53,8 @@ extern "C" { #ifndef __stdcall # ifdef __i386__ # ifdef __GNUC__ -# ifdef __APPLE__ /* Mac OS X uses a 16-byte aligned stack and not a 4-byte one */ +/* Mac OS X and FreeBSD 10 use a 16-byte aligned stack and not a 4-byte one */ +# if defined(__APPLE__) || defined(__FreeBSD__) # define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__)) # else # define __stdcall __attribute__((__stdcall__)) --- include/msvcrt/crtdefs.h~ +++ include/msvcrt/crtdefs.h @@ -44,7 +44,8 @@ #ifndef __stdcall # ifdef __i386__ # ifdef __GNUC__ -# ifdef __APPLE__ /* Mac OS X uses a 16-byte aligned stack and not a 4-byte one */ +/* Mac OS X and FreeBSD 10 use a 16-byte aligned stack and not a 4-byte one */ +# if defined(__APPLE__) || defined(__FreeBSD__) # define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__)) # else # define __stdcall __attribute__((__stdcall__)) --- tools/winegcc/utils.h~ +++ tools/winegcc/utils.h @@ -42,7 +42,7 @@ enum target_cpu enum target_platform { - PLATFORM_UNSPECIFIED, PLATFORM_APPLE, PLATFORM_SOLARIS, PLATFORM_WINDOWS, PLATFORM_CYGWIN + PLATFORM_UNSPECIFIED, PLATFORM_APPLE, PLATFORM_FREEBSD, PLATFORM_SOLARIS, PLATFORM_WINDOWS, PLATFORM_CYGWIN }; void error(const char* s, ...) DECLSPEC_NORETURN; --- tools/winegcc/winegcc.c~ +++ tools/winegcc/winegcc.c @@ -171,6 +171,7 @@ static const struct { { "macos", PLATFORM_APPLE }, { "darwin", PLATFORM_APPLE }, + { "freebsd", PLATFORM_FREEBSD }, { "solaris", PLATFORM_SOLARIS }, { "cygwin", PLATFORM_CYGWIN }, { "mingw32", PLATFORM_WINDOWS }, @@ -229,6 +230,8 @@ static const enum target_cpu build_cpu = #ifdef __APPLE__ static enum target_platform build_platform = PLATFORM_APPLE; +#elif defined(__FreeBSD__) +static enum target_platform build_platform = PLATFORM_FREEBSD; #elif defined(__sun) static enum target_platform build_platform = PLATFORM_SOLARIS; #elif defined(__CYGWIN__) @@ -466,9 +469,10 @@ static void compile(struct options* opts strarray_add(comp_args, "-D_fastcall=__attribute__((ms_abi))"); fastcall_done = 1; } - else if (opts->target_platform == PLATFORM_APPLE) + else if ((opts->target_platform == PLATFORM_APPLE) || + (opts->target_platform == PLATFORM_FREEBSD)) { - /* Mac OS X uses a 16-byte aligned stack and not a 4-byte one */ + /* Mac OS X and FreeBSD 10 use a 16-byte aligned stack and not a 4-byte one */ strarray_add(comp_args, "-D__stdcall=__attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))"); strarray_add(comp_args, "-D__cdecl=__attribute__((__cdecl__)) __attribute__((__force_align_arg_pointer__))"); strarray_add(comp_args, "-D_stdcall=__attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))"); --=-=-=--