From jan@swi.psy.uva.nl Fri May 11 10:21:19 2001
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f4B8LJ300878;
	Fri, 11 May 2001 10:21:19 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f4B8LHg15477;
	Fri, 11 May 2001 10:21:17 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: John.Velman@HSC.com, prolog@swi.psy.uva.nl
Subject: Re: [SWIPL] compile SWI Prolog on cygwin?
Date: Fri, 11 May 2001 10:07:20 +0200
X-Mailer: KMail [version 1.0.29.2]
Content-Type: text/plain
References: <OF023914CE.F34D9DEC-ON88256A48.007D3524@hughes.com>
In-Reply-To: <OF023914CE.F34D9DEC-ON88256A48.007D3524@hughes.com>
MIME-Version: 1.0
Message-Id: <01051110211700.12472@gollem>
Content-Transfer-Encoding: 8bit

On Fri, 11 May 2001, John.Velman@HSC.com wrote:
>I've attempted to compile pl-4.0.4 under cygwin 1.3.1-1
>(the most recent).
>
>Readline gave me a problem, namely, the last part of
>the make output was:
>

>pl-rl.o(.text+0x1c1):pl-rl.c: undefined reference to `rl_event_hook'
>pl-rl.o(.text+0x1ce):pl-rl.c: undefined reference to `rl_event_hook'
>collect2: ld returned 1 exit status
>make: *** [pl] Error 1

This is a hook that allows SWI-Prolog to look for X11 events on behalf
of XPCE.  I don't think that will work.  I've added a test for the
existence of this hook.  See CVS version (get configure, config.h.in and
pl-rl.c)

>ar x `gcc -print-libgcc-file-name` frame.o
>gcc  -o pl -Lrc pl-atom.o pl-wam.o pl-stream.o pl-error.o pl-arith.o pl-bag.o pl
>-comp.o pl-rc.o pl-dwim.o pl-ext.o pl-file.o pl-flag.o pl-fmt.o pl-funct.o pl-gc
>.o pl-glob.o pl-itf.o pl-list.o pl-load.o pl-modul.o pl-op.o pl-os.o pl-prims.o
>pl-pro.o pl-proc.o pl-prof.o pl-read.o pl-rec.o pl-rl.o pl-setup.o pl-sys.o pl-t
>able.o pl-trace.o pl-util.o pl-wic.o pl-write.o pl-term.o pl-buffer.o pl-thread.
>o pl-xterm.o pl-feature.o pl-ctype.o pl-main.o pl-extend.o frame.o -lrc -lncurse
>s -lm
>./pl -O -o pl.prc -b ../boot/init.pl
>[FATAL ERROR:
>        mprotect() failed at 0x502d000 for 16384 bytes: Permission denied
>]

This looks more serious.  Looks a bit the mmap() implementation is a bit
dubious.  You can get away using configure --disable-mapped-stacks, but
that also looses all the benefits of mapped stacks.  If you can call
native Win32 API functions, you could use the Windows stack-management
code.  This requires a little fiddling with preprocessor symbols to get
the right implementation from pl-setup.c.  It contains 3 sets of
functions to manage the stacks.  Default on Unix it wants mmap().  On
Windows it want VirtualAlloc() and if all fails it uses malloc().

P.s.	Do a `make clean' before recompiling after re-running configure.

	--- Jan

