[clang] [MinGW] Pass LTO options to the linker

This matches what is done on other platforms too.

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

Differential Revision: https://reviews.llvm.org/D158411
This commit is contained in:
Martin Storsjö 2023-07-19 14:48:50 +03:00
parent 7cabb54f38
commit a23bf1786b
2 changed files with 9 additions and 1 deletions

View File

@ -238,6 +238,12 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
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);

View File

@ -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"