[PATCH] D90457: [clang][driver] Set LTO mode based on input files

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 30 05:48:36 PDT 2020


tbaeder created this revision.
tbaeder added reviewers: tstellar, sfantao, tejohnson.
Herald added subscribers: cfe-commits, steven_wu, hiraditya, inglorion, mgorny.
Herald added a project: clang.
tbaeder requested review of this revision.

After setting the LTO mode from the -flto option, look at the input files as well. If any of them is an object file containing LLVM bitcode,
set the LTO mode to either thin or full, depending on the input file.

This makes the following sample work:

  clang test.c -c -flto
  clang test.o

Which also works when using GCC. Currently this makes non-lld linkers print an error, for example when using ld.bfd:

  $ clang test.o
  test.o: file not recognized: file format not recognized
  clang-10: error: linker command failed with exit code 1 (use -v to see invocation)




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90457

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/thinlto_backend.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90457.301867.patch
Type: text/x-patch
Size: 3680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201030/5f67b4f8/attachment.bin>


More information about the cfe-commits mailing list