[PATCH] D69173: [clang][ThinLTO][Legacy] Don't add -fsplit-lto-unit for legacy thin LTO builds

Eugene Leviant via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 08:47:53 PDT 2019


evgeny777 created this revision.
evgeny777 added reviewers: tejohnson, steven_wu.
Herald added subscribers: dexonsmith, hiraditya, inglorion, mehdi_amini.

This is an addition to D68950 <https://reviews.llvm.org/D68950> which has been recently landed. It prevents adding `-fsplit-lto-unit` for Mac and PS4 thin LTO builds, because legacy LTO library is not capable of unit splitting.


https://reviews.llvm.org/D69173

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/split-lto-unit.c


Index: test/Driver/split-lto-unit.c
===================================================================
--- test/Driver/split-lto-unit.c
+++ test/Driver/split-lto-unit.c
@@ -3,6 +3,10 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-split-lto-unit 2>&1 | FileCheck --check-prefix=NOUNIT %s
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-split-lto-unit -fwhole-program-vtables 2>&1 | FileCheck --check-prefix=ERROR1 %s
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-split-lto-unit -fsanitize=cfi 2>&1 | FileCheck --check-prefix=ERROR2 %s
+// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -fwhole-program-vtables -flto=full 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -fwhole-program-vtables -flto=thin 2>&1 | FileCheck --check-prefix=NOUNIT %s
+// RUN: %clang -target x86_64-scei-ps4 -### %s -fwhole-program-vtables -flto=full 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang -target x86_64-scei-ps4 -### %s -fwhole-program-vtables -flto=thin 2>&1 | FileCheck --check-prefix=NOUNIT %s
 
 // UNIT: "-fsplit-lto-unit"
 // NOUNIT-NOT: "-fsplit-lto-unit"
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5395,7 +5395,12 @@
     CmdArgs.push_back("-fwhole-program-vtables");
   }
 
-  bool DefaultsSplitLTOUnit = WholeProgramVTables || Sanitize.needsLTO();
+  // The Darwin and PS4 linkers currently use the legacy LTO API, which
+  // does not support LTO unit splitting.
+  bool SplitLTOUnitSupported = D.getLTOMode() == LTOK_Full ||
+                               !(RawTriple.isOSDarwin() || RawTriple.isPS4());
+  bool DefaultsSplitLTOUnit =
+      (WholeProgramVTables || Sanitize.needsLTO()) && SplitLTOUnitSupported;
   bool SplitLTOUnit =
       Args.hasFlag(options::OPT_fsplit_lto_unit,
                    options::OPT_fno_split_lto_unit, DefaultsSplitLTOUnit);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69173.225638.patch
Type: text/x-patch
Size: 2038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191018/06f07085/attachment.bin>


More information about the llvm-commits mailing list