Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Romain Beauxis <toots@rastageeks.org>
To: caml-list@yquem.inria.fr
Subject: Options order for ocamlc/opt/opt.opt
Date: Fri, 23 Nov 2007 02:43:34 +0100	[thread overview]
Message-ID: <200711230243.34108.toots@rastageeks.org> (raw)

	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


             reply	other threads:[~2007-11-23  1:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-23  1:43 Romain Beauxis [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200711230243.34108.toots@rastageeks.org \
    --to=toots@rastageeks.org \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox