Author: Martin Storsjö Date: 2023-08-24T23:15:26+03:00 New Revision: a23bf1786be7c0738a4cf999c2957155bb32d5af
URL: https://github.com/llvm/llvm-project/commit/a23bf1786be7c0738a4cf999c2957155bb32d5af DIFF: https://github.com/llvm/llvm-project/commit/a23bf1786be7c0738a4cf999c2957155bb32d5af.diff LOG: [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 Added: Modified: clang/lib/Driver/ToolChains/MinGW.cpp clang/test/Driver/mingw-lto.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index b47041dcca7024..4674e7fa268fa9 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -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); diff --git a/clang/test/Driver/mingw-lto.c b/clang/test/Driver/mingw-lto.c index 6f5652ddfb86bb..c10ad6b821bd73 100644 --- a/clang/test/Driver/mingw-lto.c +++ b/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" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits