[PATCH] D158411: [clang] [MinGW] Pass LTO options to the linker

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 13:16:06 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa23bf1786be7: [clang] [MinGW] Pass LTO options to the linker (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158411

Files:
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/test/Driver/mingw-lto.c


Index: clang/test/Driver/mingw-lto.c
===================================================================
--- clang/test/Driver/mingw-lto.c
+++ clang/test/Driver/mingw-lto.c
@@ -1,4 +1,6 @@
 // The default linker doesn't support LLVM bitcode
 // RUN: not %clang --target=i686-pc-windows-gnu %s -flto -fuse-ld=bfd
 // When using lld, this is allowed though.
-// RUN: %clang --target=i686-pc-windows-gnu -### %s -flto -fuse-ld=lld -B%S/Inputs/lld
+// RUN: %clang --target=i686-pc-windows-gnu -### %s -flto -fuse-ld=lld -B%S/Inputs/lld -femulated-tls 2>&1 | FileCheck %s
+
+// CHECK: "-plugin-opt=-emulated-tls"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===================================================================
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -238,6 +238,12 @@
 
   AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
 
+  if (D.isUsingLTO()) {
+    assert(!Inputs.empty() && "Must have at least one input.");
+    addLTOOptions(TC, Args, CmdArgs, Output, Inputs[0],
+                  D.getLTOMode() == LTOK_Thin);
+  }
+
   if (C.getDriver().IsFlangMode()) {
     addFortranRuntimeLibraryPath(TC, Args, CmdArgs);
     addFortranRuntimeLibs(TC, CmdArgs);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158411.553239.patch
Type: text/x-patch
Size: 1217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230824/435956f9/attachment.bin>


More information about the cfe-commits mailing list