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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 23 13:24:41 PST 2023


MaskRay added a comment.

In D144596#4148451 <https://reviews.llvm.org/D144596#4148451>, @itf wrote:

>> 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.

Can Bazel rewrite `a.rsp` with content `xxx/a.o` to `xxx/random_hash/a.o`? It will create a new file but I don't think that's a bottleneck.

> 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




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

https://reviews.llvm.org/D144596



More information about the llvm-commits mailing list