Subject: Re: Patch for building Wine on NetBSD
To: Frederick Bruckman <fb@enteract.com>
From: Bang Jun-Young <bjy@mogua.org>
List: port-i386
Date: 05/09/2001 11:58:14
On Mon, May 07, 2001 at 12:00:53PM -0500, Frederick Bruckman wrote:
> On Tue, 1 May 2001, Bang Jun-Young wrote:
> 
> > Now I get the following error when trying to run a Windows binary:
> >
> > $ wineserver (this is required)
> > $ wine sol.exe
> > No built-in EXE module loaded!  Did you create a .spec file?
> 
> OK. Now I've gotten that far, too. I reworked your configure.in patch
> to work with the latest cvs checkout, and went with adding "-lc" to
> LIBS instead of hacking configure (neat trick, adding -lc, but weird).
> I also included "errno.h" everywhere that "sys/errno.h" was included,
> on principle. I needed a few other patches to build all in "programs.
> The patch also includes a gratuitious change to the default config,
> and to "wineinstall" to use gmake, because otherwise the "install"
> target was deleting the installed shared libraries and replacing them
> with dangling symlinks to themselves (or so it seemed).
> 
> Here's the entire patch I have so far:
> 
> ftp://ftp.enteract.com/users/fb/NetBSD/wine-on-netbsd/wine.patch
> 
> One more thing... on NetBSD-1.5_BETA, it detected curses but failed to
> build against it. It builds after
> 
> 	autoconf; LIBS=-lc ./configure --without-curses
> 
> Thinking that maybe it needed a console, I built it against ncurses in
> /usr/pkg, too -- there's a file "configure.wine" in the same directory
> as above that sets the right environment settings for that. (Didn't
> make a difference, though.)
> 
> I've tried to run an old DOS game and some of the wine-built programs
> with the no windows install. Do you think it might work better with
> Windows 98? For what it's worth, "winelaunch" actually runs, but it
> fails because it can't exec '/wine'.

Thanks to Eric Pouech, I have found some of the reason. Let's have a 
look at the following code:

extern void init(void) __attribute__((section(".init")));
extern void fini(void) __attribute__((section(".fini")));

main()
{
	printf("%s\n", __FUNCTION__);
}

asm("\n.section\t.init, \"ax\"\n"
    "\tcall init\n"
    "\t.previous\n");

asm("\n.section\t.fini, \"ax\"\n"
    "\tcall fini\n"
    "\t.previous\n");

void init(void)
{
	printf("%s\n", __FUNCTION__);
}

void fini(void)
{
	printf("%s\n", __FUNCTION__);
}

On FreeBSD, the output is like as follows:

init
init
main
fini
fini

Functions in the .init and .fini sections are automatically
executed at the init and exit time, respectively. 

On the other hand, on NetBSD they are just ignored (without compile
error) and never called. For details, see

  http://www.winehq.com/hypermail/wine-devel/2001/05/0021.html

For now I suspect that it's a bug of ld(1) or ld.elf_so(1).

Jun-Young

-- 
Bang Jun-Young <bjy@mogua.org>