This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Support --exclude-inputs
AbandonedPublic

Authored by melver on Apr 19 2023, 9:37 AM.

Details

Summary

Linking of binaries in large projects often results in processing of
thousands of linker inputs. In such projects, controlling all transitive
dependencies' inputs and libraries to be added to the final linker
command is (unfortunately) often too complex.

In theory the build system should provide a convenient way to simply
exclude a given library, but the reality is that few build systems do.

The simplest possible design, that will work across all build systems,
is therefore to pass an option to the linker to exclude inputs matching
a given pattern. The possible use cases are:

  1. Removing inputs added by dependencies (e.g. via pkg-config) where modification of the build scripts (or build systems such as Bazel) is infeasible.
  2. Replacing inputs added by dependencies where modification of the build scripts is infeasible.
  3. Replacing default inputs with custom implementations.

Introduce --exclude-inputs, which accomplishes just that.

Diff Detail

Event Timeline

melver created this revision.Apr 19 2023, 9:37 AM
Herald added a project: Restricted Project. · View Herald Transcript
melver requested review of this revision.Apr 19 2023, 9:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 9:37 AM
melver added a subscriber: dvyukov.Apr 19 2023, 9:39 AM

I feel that this debugging feature will be useful. Can you please create a post on https://discourse.llvm.org/c/subprojects/lld/7 so that more people can comment? It's possible that some linkers have similar features and we can learn from their experience.

lld/ELF/Driver.cpp
233

no brace for cascading single-line while/for/if

Actually, it may be useful to add a log comment in --verbose mode.

lld/test/ELF/exclude-inputs.s
10

If %t (an absolute path) contains foo, this check may go wrong.

Add # RUN: rm -rf %t && mkdir %t && cd %t in the first line can avoid this issue.

melver updated this revision to Diff 515040.Apr 19 2023, 12:25 PM
melver marked 2 inline comments as done.
  • fix test if 'foo' or 'bar' in absolute path
  • formatting of for-if
  • add log()

I feel that this debugging feature will be useful. Can you please create a post on https://discourse.llvm.org/c/subprojects/lld/7 so that more people can comment? It's possible that some linkers have similar features and we can learn from their experience.

Thanks, posted https://discourse.llvm.org/t/rfc-support-exclude-inputs/70070

melver abandoned this revision.Apr 21 2023, 4:02 AM