[lld] Support separate native object file path in --thinlto-prefix-replace
authorIvan Tadeu Ferreira Antunes Filho <antunesi@google.com>
Tue, 4 Apr 2023 16:57:53 +0000 (09:57 -0700)
committerTeresa Johnson <tejohnson@google.com>
Tue, 4 Apr 2023 18:24:51 +0000 (11:24 -0700)
commit73fd9d310fff4d7d2b95e0509aafdf28bd3c713c
tree4e2ca6a50f12c40734fbaeb033514d4c2f2bd664
parenta401e10f12ba555eefc3da607fa5168603caa9c6
[lld] Support separate native object file path in --thinlto-prefix-replace

Currently, the --thinlto-prefix-replace="oldpath;newpath" option is used during
distributed ThinLTO thin links to specify the mapping of the input bitcode object
files' directory tree (oldpath) to the directory tree (newpath) used for both:

1) the output files of the thin link itself (the .thinlto.bc index files and the
optional .imports files)
2) the specified object file paths written to the response file given in the
--thinlto-index-only=${response} option, which is used by the final native
link and must match the paths of the native object files that will be
produced by ThinLTO backend compiles.
This patch expands the --thinlto-prefix-replace option to allow a separate directory
tree mapping to be specified for the object file paths written to the response file
(number 2 above). This is important to support builds and build systems where the
same output directory may not be written by multiple build actions (e.g. the thin link
and the ThinLTO backend compiles).

The new format is: --thinlto-prefix-replace="origpath;outpath[;objpath]"

This replaces the origpath directory tree of the thin link input files with
outpath when writing the thin link index and imports outputs (number 1
above). If objpath is specified it replaces origpath of the input files with
objpath when writing the response file (number 2 above), otherwise it
falls back to the old behavior of using outpath for this as well.

Reviewed By: tejohnson, MaskRay

Differential Revision: https://reviews.llvm.org/D144596
16 files changed:
lld/COFF/Config.h
lld/COFF/Driver.cpp
lld/COFF/LTO.cpp
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/LTO.cpp
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/LTO.cpp
lld/test/COFF/thinlto-index-file-object-prefix-replace.ll [new file with mode: 0644]
lld/test/ELF/lto/thinlto-index-file-object-prefix-replace.ll [new file with mode: 0644]
lld/test/MachO/thinlto-index-file-object-prefix-replace.ll [new file with mode: 0644]
llvm/include/llvm/LTO/LTO.h
llvm/lib/LTO/LTO.cpp
llvm/tools/gold/gold-plugin.cpp
llvm/tools/llvm-lto2/llvm-lto2.cpp