[PATCH] D63976: Allow clang -Os and -Oz to work with -flto and lld

Mehdi AMINI via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 6 13:03:29 PDT 2019


mehdi_amini added a comment.

> with a funny command line like `clang -Oz -flto -o foo a.o b.c`, where one (or all) of the input arguments is a source file? Would it invoke the bitcode compile of the source files with the requested `-Oz` and then invoke the LTO linker plugin with `-O2`/`-O3`?

What you're invoking is the clang driver, it will drive the process and spawn multiple subprocess for each phase (this contributes to the UI challenge). Your "funny" command line will detect that it needs to spawn a clang instance for the compile phase of b.c to get an object file before invoking the linker on the temporary b.o and the a.o you provide on the input. To add some complexity, the exact behavior depends on the platform (Linux vs MacOS) and possible which linker is in use (-fuse-ld=lld).

But yes this patch changes the driver so that only the invocation of the linker is changed. Your previous "funny" command line would still yield Oz when compiling b.c to b.o before invoking the linker on b.o and a.o with O3 <https://reviews.llvm.org/owners/package/3/>.

(I don't know if this change is the best solution, I just provide my understanding of the situation :))


Repository:
  rC Clang

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

https://reviews.llvm.org/D63976





More information about the cfe-commits mailing list