caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] "Error while building custom runtime system"
@ 2003-10-15  9:36 Richard Jones
  2003-10-15 16:57 ` [Caml-list] Initialization order bug Richard Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Jones @ 2003-10-15  9:36 UTC (permalink / raw)
  To: caml-list

I'm getting very strange behaviour from ocamlc when linking. Here's my
small test program. Note the '-verbose' arg:

$ ocamlc -verbose -I +perl -w s perl4caml.cma perl_init.cmo loadpage.cmo -o loadpage
$

(ie. everything is OK - it doesn't run any external programs such as gcc
or ld).

Now here's the *real* program I want to compile, note also the -verbose
arg:

$ ocamlc -verbose -w s -I +lablgtk2 -I ../lablgtk2-mozembed -I +apache -I +postgres -I +perl -I +pcre unix.cma pcre.cma lablgtk.cma gtkInit.cmo lablgtkmoz.cma postgres.cma dbi.cmo dbi_postgres.cmo perl4caml.cma perl_init.cmo lib.cmo globals.cmo database.cmo google.cmo loadpage.cmo parsepage.cmo gtkError.cmo gtkTied.cmo selection_dialog.cmo browser.cmo mainWindowControls.cmo autoPage.cmo productRankingPage.cmo salesAsmtPage.cmo commitPage.cmo pages.cmo main.cmo -o assessor
+ gcc -Wl,-E -o 'assessor' -I'/usr/lib/ocaml/3.07' -L/usr/local/lib -L/usr/lib/perl/5.8.1/CORE -Wl,-rpath,/usr/local/lib:/usr/lib/perl/5.8.1/CORE -L/usr/lib/mozilla -Wl,-rpath,/usr/lib/mozilla /tmp/camlprim5ffb86.c  '-L/usr/lib/ocaml/3.07/lablgtk2' '-L../lablgtk2-mozembed' '-L/usr/lib/ocaml/3.07/apache' '-L/usr/lib/ocaml/3.07/postgres' '-L/usr/lib/ocaml/3.07/perl' '-L/usr/lib/ocaml/3.07/pcre' '-L/usr/lib/ocaml/3.07' '-lperl4caml' '-lperl' '-ldl' '-lm' '-lpthread' '-lc' '-lcrypt' '-lpq' '-lmlpostgres' '-llablgtkmoz' '-lgtkembedmoz' '-lxpcom' '-lplds4' '-lplc4' '-lnspr4' '-ldl' '-lc' '-lpthread' '-llablgtk2' '-lgtk-x11-2.0' '-lgdk-x11-2.0' '-latk-1.0' '-lgdk_pixbuf-2.0' '-lm' '-lpangoxft-1.0' '-lpangox-1.0' '-lpango-1.0' '-lgobject-2.0' '-lgmodule-2.0' '-ldl' '-lglib-2.0' '-lpcre_stubs' '-lpcre' '-lunix' -lcamlrun -lm  -ldl -lcurses -lpthread
/usr/lib/ocaml/3.07/perl/libperl4caml.a(perl_c.o)(.text+0x1b): In function `xs_init':
: undefined reference to `boot_DynaLoader'
collect2: ld returned 1 exit status
Error while building custom runtime system

I'm not using the -custom option anywhere. Ocamlc seems to react
entirely differently. First it launches gcc. Secondly (and more
importantly) it fails to link in a particular static library which I
specified when I created perl4caml.cma.

The test program also relies on the 'boot_DynaLoader' symbol, so I
don't understand why the test program works, but the real program
fails, and why ocamlc works completely differently in each case.
Something to do with the other libraries I'm using??

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
"I wish more software used text based configuration files!"
 -- A Windows NT user, quoted on Slashdot.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Caml-list] Initialization order bug
  2003-10-15  9:36 [Caml-list] "Error while building custom runtime system" Richard Jones
@ 2003-10-15 16:57 ` Richard Jones
       [not found]   ` <16269.37646.599166.88324@karryall.dnsalias.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Jones @ 2003-10-15 16:57 UTC (permalink / raw)
  To: caml-list

Related to the above issue is another strange bug in initialization order.

I have two libraries called:

	Perl
	  ^
	  |-------\
	  |	  | uses
	  |	Pl_LWP_UserAgent
	  |
	  | uses
	  |
	Test

But in this scenario, Perl is not initialized before Test starts
running (and hence the program crashes).

If I add a false dependency so that Test uses Pl_LWP_UserAgent, then
everything works (Perl is initialized OK before use).

Unfortunately this bug defies creating a minimal example, but if you
download:

http://www.annexia.org/tmp/perl4caml-0.3.2.tar.gz

then look at the top of examples/test.ml. Try running with and
without the fake 'let f = Pl_LWP_UserAgent.may' command at the
top of the file.

Without & it segfaults because Perl is never initialized before
being called.

With & it works OK.

The two other example programs already require one or other of the
Pl_* modules, so they work OK.

This is OCaml 3.07 from Debian/unstable.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
MONOLITH is an advanced framework for writing web applications in C, easier
than using Perl & Java, much faster and smaller, reusable widget-based arch,
database-backed, discussion, chat, calendaring:
http://www.annexia.org/freeware/monolith/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Initialization order bug
       [not found]   ` <16269.37646.599166.88324@karryall.dnsalias.org>
@ 2003-10-16  9:18     ` Richard Jones
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Jones @ 2003-10-16  9:18 UTC (permalink / raw)
  To: caml-list

Olivier Andrieu provided the right answer to this:

> This sort of things happen when :
>  - you have lots of externals in your module (here Perl)
>  - the module runs some initialization-time code that doesn't appear
>    in the interface
>  - the only values referenced by other values are externals
> 
> then the module is in fact not linked in : it's not needed because the
> other modules directly call the external functions. The problem is
> that often these externals do not work without the proper
> initialization.
> 
> Some workarounds are to :
>  - make the initialization code appear in the .mli, through a init
>    function for instance
>  - use `val' instead of `external' in the .mli
>  - use -linkall when linking the program

It works now, but I still think this is a bug.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
MONOLITH is an advanced framework for writing web applications in C, easier
than using Perl & Java, much faster and smaller, reusable widget-based arch,
database-backed, discussion, chat, calendaring:
http://www.annexia.org/freeware/monolith/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-10-16  9:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-15  9:36 [Caml-list] "Error while building custom runtime system" Richard Jones
2003-10-15 16:57 ` [Caml-list] Initialization order bug Richard Jones
     [not found]   ` <16269.37646.599166.88324@karryall.dnsalias.org>
2003-10-16  9:18     ` Richard Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).