[PATCH] D144596: Add extra parameter to thinlto-prefix-replace

Ivan Tadeu Ferreira Antunes Filho via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 23 13:15:10 PST 2023


itf marked an inline comment as done.
itf added a comment.

> IIUC the proposed third component of `;` just changes the `--thinlto-index-only=a.rsp` specified response file (not anything else on the disk), then I am unsure how it is going to help Bazel...
> Bazel can preprocess the `a.rsp` content itself, instead of requiring more from the linker.

Depending on the contents of `a.rsp` to stay constant (i.e. exactly one file per line, no extra information such as "start-lib" "end-lib",etc) in order to parse and modify it as a text file from Bazel seemed to be very fragile.

Given that the initial reason for --thinlto-prefix-replace was rLLD365807 <https://reviews.llvm.org/rLLD365807>  
`This can be used to ensure index files and native object files are stored in unique directories, `,

It seemed more appropriate to add an extra parameter to `--thinlto-prefix-replace` since it seemed in line with the original design. .

> Could you give an example in the summary how an end user is going to use the proposed feature?

Modifying your example:

  echo 'int bb(); int main() { return bb(); }' > a.c
  echo 'int elf0(); int bb() { return elf0(); }' > b.c
  echo 'int cc() { return 0; }' > c.c
  echo 'int elf0() { return 0; }' > elf0.c && clang -c elf0.c
  echo '' > elf1.c && clang -c elf1.c
  
  clang -c -O2 -flto=thin a.c b.c c.c
  clang -flto=thin -fuse-ld=lld -Wl,--thinlto-index-only=a.rsp -Wl,--thinlto-prefix-replace=';lto/;ltoobj/' elf0.o a.o -Wl,--start-lib b.o c.o -Wl,--end-lib elf1.o
  clang -c -O2 -fthinlto-index=lto/a.o.thinlto.bc a.o -o ltoobj/a.o
  clang -c -O2 -fthinlto-index=lto/b.o.thinlto.bc b.o -o ltoobj/b.o
  clang -c -O2 -fthinlto-index=lto/c.o.thinlto.bc c.o -o ltoobj/c.o
  clang -fuse-ld=lld @a.rsp elf0.o elf1.o  # a.rsp contains ltoobj/a.o and ltoobj/b.o



================
Comment at: lld/test/MachO/thinlto-index-file-object-prefix-replace.ll:3
+; RUN: rm -rf %t ; split-file %s %t && cd %t
+; RUN: mkdir -p oldpath oldpath/prefix_replace
+
----------------
oontvoo wrote:
> This needs to go under `%t` (otherwise the tests may fail in our integrates because only stuff under `%t` is writeable)
is `cd %t` in the previous line not enough to keep the following commands under `%t` ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144596/new/

https://reviews.llvm.org/D144596



More information about the llvm-commits mailing list