ld: Add --remap-inputs-file= to remap input files
Fangrui Song
i@maskray.me
Fri Apr 21 00:11:25 GMT 2023
Hello! I'm considering an option in ld.lld to replace or remove input
files with glob patterns.
I just filed a feature request
https://sourceware.org/bugzilla/show_bug.cgi?id=30374 , but thought
that I should send the message here to possibly get more attention.
(I originally named the option --remapping-file=, but Marco Elver's
--remap-inputs-file= suggestion looks better.)
--remap-inputs-file= can be specified multiple times, each naming a
remap file that contains from-glob<tab>to-file lines or #-led comments, e.g.
aa.o a.o
b?.[b]c b.o
cc.a c.a
d*.so d.so
## Use /dev/null to indicate an input file which should be ignored.
/dev/null is treated as an empty linker script.
empty /dev/null
This option can be used to:
* replace an input file. E.g. "*/libz.so\texp/libz.so" can replace a
resolved -lz without updating the input file list or (if used) a
response file. When debugging an application where a bug is isolated
to one single input file, this option gives a convenient way to test
fixes.
* remove an input file with /dev/null (changed to NUL on Windows),
e.g. "a.o\t/dev/null". A build system may add unneeded dependencies.
This option gives a convenient way to test the result by removing some
inputs.
bash/zsh process substitution is handy for specifying a pattern
without using a remap file, e.g. --remap-inputs-file=<(printf
'a.o\taa.o').
Therefore, I think an option providing an inline pattern
(--remap-inputs=a.o=aa.o) may not be too useful.
More information about the Binutils
mailing list