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

2023-08-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158411

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-24 Thread Martin Storsjö via Phabricator via cfe-commits
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);


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);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-24 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 accepted this revision.
mati865 added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158411

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-21 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added a reviewer: MaskRay.
Herald added subscribers: ormris, steven_wu, hiraditya, inglorion.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang.

This matches what is done on other platforms too.

This fixes one part of
https://github.com/mstorsjo/llvm-mingw/issues/349.


Repository:
  rG LLVM Github Monorepo

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);


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);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits