Re: Prolog not fully initialized

Daniel Diaz <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
  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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.