users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Prolog not fully initialized


From: Daniel Diaz
Subject: Re: Prolog not fully initialized
Date: Wed, 29 Sep 2010 00:54:34 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4

 Le 28/09/2010 22:42, "Michał Bieliński" a écrit :
Greetings!

I recently managed to interface GNU Prolog with Free Pascal albeit not
fully. Both Prolog and Pascal units compile and link.

Pl_Start_Prolog executes and returns. Manual states this function will
collect all objects and initialize them. Probably this somehow fails
because many standard atoms are not found by Pl_Find_Atom function. It
seems linking through gcc allows Prolog to find all objects but using
another compiler does not.

Another thing I tried was to stop fpc just before linking and fed
resulting link.res file to "gcc -nostdlib". Did not help.

I would be very grateful for pointers how to deal with this problem.

Below is some information you might find useful:
uname -mosrv:
Linux 2.6.35-ARCH #1 SMP PREEMPT Fri Aug 27 16:22:18 UTC 2010 i686 GNU/Linux

Pascal source: http://pastie.org/1187257
Prolog source is new_main.pl from GNU Prolog examples.
Program output: http://pastie.org/1187266

Hello,

gprolog uses the underlying gcc mechanism to collect and initialize linked objects : constructors functions. Each Prolog source give rise to a constructor function to register it (and later to initialize it). The asm code is similar to what is generated by gcc when compiling a function declared as follows (see also src/EnginePl/obj_chain.h and .c) :

/* file x.c */
static void __attribute__((constructor)) foo(void) {
   ...
}

use gcc -S -O2 x.c
to see x.s

I suppose you have to succeed in doing the same as gcc to initialize correctly the objects.

Please let me know your progress.

Daniel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]