[all-commits] [llvm/llvm-project] 2c1903: [lld/mac] Implement removal of unused dylibs

Nico Weber via All-commits all-commits at lists.llvm.org
Tue Jun 1 13:12:10 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2c1903412b0a73ed65e9feb272af9c07f32970d0
      https://github.com/llvm/llvm-project/commit/2c1903412b0a73ed65e9feb272af9c07f32970d0
  Author: Nico Weber <thakis at chromium.org>
  Date:   2021-06-01 (Tue, 01 Jun 2021)

  Changed paths:
    M lld/MachO/Config.h
    M lld/MachO/Driver.cpp
    M lld/MachO/InputFiles.cpp
    M lld/MachO/InputFiles.h
    M lld/MachO/Options.td
    M lld/MachO/SymbolTable.cpp
    M lld/MachO/Symbols.h
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/Writer.cpp
    A lld/test/MachO/dead-strip-dylibs.s
    M lld/test/MachO/implicit-dylibs.s
    M lld/test/MachO/lc-linker-option.ll

  Log Message:
  -----------
  [lld/mac] Implement removal of unused dylibs

This omits load commands for unreferenced dylibs if:
- the dylib was loaded implicitly,
- it is marked MH_DEAD_STRIPPABLE_DYLIB
- or -dead_strip_dylibs is passed

This matches ld64.

Currently, the "is dylib referenced" state is computed before dead code
stripping and is not updated after dead code stripping. This too matches ld64.
We should do better here.

With this, clang-format linked with lld (like with ld64) no longer has
libobjc.A.dylib in `otool -L` output. (It was implicitly loaded as a reexport
of CoreFoundation.framework, but it's not needed.)

Differential Revision: https://reviews.llvm.org/D103430




More information about the All-commits mailing list