[PATCH] D79818: [lld] Support size levels with (Thin)LTO

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 15:51:35 PDT 2020


phosek added a comment.

In D79818#2035232 <https://reviews.llvm.org/D79818#2035232>, @MaskRay wrote:

> @mehdi_amini @pcc @tejohnson
>
> I just saw another issue saying that `clang -Os -flto=thin a.c` does not work https://bugs.llvm.org/show_bug.cgi?id=45913 (+ @manojgupta)
>  I marked it as yet another duplicate of PR42445
>
> For -Os, clang driver passes -plugin-opt=Os (https://github.com/llvm/llvm-project/blob/master/clang/lib/Driver/ToolChains/CommonArgs.cpp#L402) but neither LLVMgold.so nor LLD recognizes `-plugin-opt=Os`. 
>  -Oz is similar. What is the concrete suggestion here? For quick reference, the `-plugin-opt=O` logic was added by rL256146 <https://reviews.llvm.org/rL256146>.


The issue form my perspective is the inconsistency. Today, lld accepts `-plugin-opt=O<number>` but it doesn't accept `-plugin-opt=O<letter>`, but Clang automatically translates `-O<anything>` to `-plugin-opt=O<anything>` which results in a failure when your try to use `-Os`, `-Oz` or `-Og` with (Thin)LTO.

If the official stance of LTO maintainers is that we should be relying on function attributes and avoid overriding the optimization level via flags, then I'd argue that we should remove `-plugin-opt=O<number>` from lld altogether. The partial support just leads to confusion as demonstrated by some of the issues others have already referenced. In fact this change was motivated by several internal bugs from developers who tried to use ThinLTO with `-Oz` and hit the error even though `-O2` worked fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79818





More information about the llvm-commits mailing list