Does ld/gold-l always simply add files to the command line

Ian Lance Taylor via binutils binutils@sourceware.org
Wed Jul 26 22:49:00 GMT 2017


On Wed, Jul 26, 2017 at 1:44 PM, Niklas Hambüchen <mail@nh2.me> wrote:
>
> is the -l flag to ld and gold guaranteed to have the same effect as
> passing the found library file (.so or .a) directly on the command line?
>
> In other words, is it just "lookup convenience", or are there cases
> where -l might do something different than passing the relevant file
> directly?
>
> (I'm asking this for the GHC Haskell compiler, specifically for this
> linker related issue: https://ghc.haskell.org/trac/ghc/ticket/14031)

It is mostly just lookup convenience.  If you replace the -l option
with the full path of the library that is found, the result will be
almost identical.  The only differences I know of are error messages
and the soname that will be used for a shared library with no
DT_SONAME dynamic tag.

Ian



More information about the Binutils mailing list