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