Skip to content

Commit a23bf17

Browse files
committed
[clang] [MinGW] Pass LTO options to the linker
This matches what is done on other platforms too. This fixes one part of mstorsjo/llvm-mingw#349. Differential Revision: https://reviews.llvm.org/D158411
1 parent 7cabb54 commit a23bf17

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/Driver/ToolChains/MinGW.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
238238

239239
AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
240240

241+
if (D.isUsingLTO()) {
242+
assert(!Inputs.empty() && "Must have at least one input.");
243+
addLTOOptions(TC, Args, CmdArgs, Output, Inputs[0],
244+
D.getLTOMode() == LTOK_Thin);
245+
}
246+
241247
if (C.getDriver().IsFlangMode()) {
242248
addFortranRuntimeLibraryPath(TC, Args, CmdArgs);
243249
addFortranRuntimeLibs(TC, CmdArgs);

clang/test/Driver/mingw-lto.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// The default linker doesn't support LLVM bitcode
22
// RUN: not %clang --target=i686-pc-windows-gnu %s -flto -fuse-ld=bfd
33
// When using lld, this is allowed though.
4-
// RUN: %clang --target=i686-pc-windows-gnu -### %s -flto -fuse-ld=lld -B%S/Inputs/lld
4+
// RUN: %clang --target=i686-pc-windows-gnu -### %s -flto -fuse-ld=lld -B%S/Inputs/lld -femulated-tls 2>&1 | FileCheck %s
5+
6+
// CHECK: "-plugin-opt=-emulated-tls"

0 commit comments

Comments
 (0)