[PATCH] [ldd] Support --[no-]as-needed options.

Rui Ueyama ruiu at google.com
Mon Apr 22 21:29:21 PDT 2013


Hi Bigcheese,

By default, GNU ld links all the dynamic libraries specified by -l option,
even if no symbols in the libraries are actually used by the resulting object
file. You can make the linker to link only the libraries containig symbols
actually used by specifying --as-needed command line option.

--no-as-needed restores the default behavior. You can mix these two options, so
the following command links "libfoo" and "libzzz" only when they are used, while
"libbar" is always linked.

  lld ... --as-needed -lfoo --no-as-needed -lbar --as-needed -lzzz

Darwin's ld does not recognize these options, and looks like it behaves as if
--as-needed is specified.

http://llvm-reviews.chandlerc.com/D708

Files:
  include/lld/Core/TargetInfo.h
  include/lld/Driver/LinkerInput.h
  include/lld/ReaderWriter/ELFTargetInfo.h
  include/lld/ReaderWriter/Writer.h
  lib/Core/TargetInfo.cpp
  lib/Driver/Driver.cpp
  lib/Driver/GnuLdDriver.cpp
  lib/Driver/LDOptions.td
  lib/ReaderWriter/ELF/ELFTargetInfo.cpp
  lib/ReaderWriter/ELF/OutputELFWriter.h
  test/elf/Inputs/libempty-x86-64.so
  test/elf/as-needed.test
  test/elf/no-as-needed.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D708.1.patch
Type: text/x-patch
Size: 11775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130422/cd1ab771/attachment.bin>


More information about the llvm-commits mailing list