[PATCH] D105223: [lld-macho] Add support for LTO optimization level

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 30 13:34:15 PDT 2021


thakis added inline comments.


================
Comment at: lld/MachO/Config.h:129
   llvm::StringRef thinLTOJobs;
+  uint32_t ltoo = 2;
   bool deadStripDylibs = false;
----------------
int3 wrote:
> lgrey wrote:
> > thakis wrote:
> > > Is this the same default ld64 seems to use?
> > AFAICT, it doesn't optimize.
> > 
> > ```
> > $ cat opt_check.c
> > void foo() {
> >     return;
> > }
> > 
> > int main(int argc, char** argv) {
> >     foo();
> >     return 0;
> > }
> > $ clang -flto=thin opt_check.c && nm -pa a.out
> > 0000000100003f80 t _foo
> > 0000000100000000 T __mh_execute_header
> > 0000000100003f90 T _main
> >                  U dyld_stub_binder
> > ```
> > 
> > Should we change it to 0 for compat?
> ld64 has an undocumented `-flto-codegen-only` flag. I haven't looked into what exactly it does, but it seems relevant...
> Should we change it to 0 for compat?

Yes, I think so.

> -flto-codegen-only

I think that's probably something else. That ends up calling thinlto_codegen_set_codegen_only() in llvm/tools/lto/lto.cpp.

…but lto_file.cpp in ld64 doesn't seem to pass an optimization flag, and OptLevel in lto.cpp defaults to 2. Strange that ld64 doesn't get an opt level of 2 then…


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105223



More information about the llvm-commits mailing list