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 (or replace) 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 or replace
inputs matching a given pattern. The possible use cases are:
- Removing inputs added by dependencies (e.g. via pkg-config) where modification of the build scripts (or build systems such as Bazel) is infeasible.
- Replacing inputs added by dependencies where modification of the build scripts is infeasible.
- Replacing default inputs with custom implementations.
Introduce --remap-inputs and --remap-inputs-file, which accomplish just
that. See added man page documentation for more details.
This version is the unified feature first proposed in
https://reviews.llvm.org/D130229 and https://reviews.llvm.org/D148726.
Link: https://discourse.llvm.org/t/rfc-support-exclude-inputs
Co-developed-by: Fangrui Song <i@maskray.me>