Order-dependency on the link command line has been common behaviour
in linkers forever as far as I know. This includes the FSF GNU linker,
as well as the system linker shipped with Unix systems.

It is a useful feature, allowing one to insert other objects in
front, e.g. to override 'malloc' with a debugging version.
Some linkers have a -recurse or --recurse switch which causes them
to, once they'e reached the end of the pass, loop until there are
no undefineds or no symbols have been pulled in.

The approach I prefer over multiply listing archives is to
use -u to explicitly pull in the offending reverse dependency.

Quoting from the GNU ld 'info' page:
     The linker will search an archive only once, at the location where
     it is specified on the command line.  If the archive defines a
     symbol which was undefined in some object which appeared before
     the archive on the command line, the linker will include the
     appropriate file(s) from the archive.  However, an undefined
     symbol in an object appearing later on the command line will not
     cause the linker to search the archive again.

     See the `-(' option for a way to force the linker to search
     archives multiple times.

     You may list the same archive multiple times on the command line.

     This type of archive searching is standard for Unix linkers.
     However, if you are using `ld' on AIX, note that it is different
     from the behaviour of the AIX linker.

And:
`-( ARCHIVES -)'
`--start-group ARCHIVES --end-group'
     The ARCHIVES should be a list of archive files.  They may be
     either explicit file names, or `-l' options.

     The specified archives are searched repeatedly until no new
     undefined references are created.  Normally, an archive is
     searched only once in the order that it is specified on the
     command line.  If a symbol in that archive is needed to resolve an
     undefined symbol referred to by an object in an archive that
     appears later on the command line, the linker would not be able to
     resolve that reference.  By grouping the archives, they all be
     searched repeatedly until all possible references are resolved.

     Using this option has a significant performance cost.  It is best
     to use it only when there are unavoidable circular references
     between two or more archives.

Now, I suggest stopping the flame war, or take it somewhere else,
this really doesn't have anything to do with FreeBSD.

--don

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to