caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Options order for ocamlc/opt/opt.opt
@ 2007-11-23  1:43 Romain Beauxis
  2007-11-23 16:40 ` Romain Beauxis
  0 siblings, 1 reply; 5+ messages in thread
From: Romain Beauxis @ 2007-11-23  1:43 UTC (permalink / raw)
  To: caml-list

	Hi all !

While trying to limit linking to non-needed libraries, I tried to use 
gcc's -Wl,--as-needed option.

Documentation states:
"This option affects ELF DT_NEEDED tags for dynamic libraries mentioned on the 
command line after the --as-needed option. Normally, the linker will add a 
DT_NEEDED tag for each dynamic library mentioned on the command line, 
regardless of whether the library is actually needed. --as-needed causes 
DT_NEEDED tags to only be emitted for libraries that satisfy some symbol 
reference from regular objects which is undefined at the point that the 
library was linked. --no-as-needed restores the default behaviour."

(-Wl means pass the option from gcc to the linker..)

So, as said, this option should be place *before* -l options..

However, when trying to use -cclib with this value, I get:
   '-lthreadsnat' '-lunix' '-lpthread' '-lunix' '-Wl,--as-needed'
which doesn't help...

Also, in order to work, one has also to take care or argument type order in 
gcc call:
'Basically, what the linker does is look for the symbols missing in a given 
file (either an object file, a static archive or a library) only in the files 
coming after it. When using the normal linking, without --as-needed, this is 
not a problem, although there might be some internal drawbacks on the linking 
stage, the files are linked together without considering ordering. But with 
the flag, the libraries that aren't used for resolving symbols are discarded 
and thus not linked.

The fix in this case is to simply fix the linking order so that the libraries 
given to the linker are all after the object files and the static archives."

This is not either the case since I have:
  '-lthreadsnat' '-lunix' '-lpthread' '-lunix' '-Wl,--as-needed' 'float_pcm_c.o' 'oss_io_c.o' '/usr/lib/ocaml/3.10.0/libasmrun.a' -lm  -ldl

This also explains why forcing it on top of the list of arguments via -ccopt 
doesn't help either...

There's a good documentation where the above statement is taken there:
  http://www.gentoo.org/proj/en/qa/asneeded.xml

What do you think ?


Romain


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

end of thread, other threads:[~2007-12-02 21:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-23  1:43 Options order for ocamlc/opt/opt.opt Romain Beauxis
2007-11-23 16:40 ` Romain Beauxis
2007-11-24  3:10   ` [Caml-list] " Julien Moutinho
2007-11-24  3:15     ` Julien Moutinho
2007-12-02 21:39       ` Romain Beauxis

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).