r239213 - clang-cl: Implement /GL in terms of -flto.

Nico Weber thakis at chromium.org
Fri Jun 12 18:59:59 PDT 2015


This breaks building with /GL (e.g. in an official chrome build). Clang
will think "hey, I'll emit bitcode" and then link.exe or lib.exe will fall
over. Mapping /GL to -flto guarantees that every build that uses /GL won't
work, which doesn't seem that great. (Linker and static library archiver
are called directly on Windows, not through the driver.)

Maybe -flto should be a core flag so that it can be passed to clang-cl
explicitly, but mapping /GL to -flto seems wrong to me.

On Fri, Jun 5, 2015 at 7:09 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:

> Author: pcc
> Date: Fri Jun  5 21:09:34 2015
> New Revision: 239213
>
> URL: http://llvm.org/viewvc/llvm-project?rev=239213&view=rev
> Log:
> clang-cl: Implement /GL in terms of -flto.
>
> No documentation yet; the linker needs more work.
>
> Differential Revision: http://reviews.llvm.org/D10270
>
> Modified:
>     cfe/trunk/include/clang/Driver/CLCompatOptions.td
>     cfe/trunk/lib/Driver/Driver.cpp
>     cfe/trunk/lib/Driver/Types.cpp
>     cfe/trunk/test/Driver/cl-outputs.c
>
> Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=239213&r1=239212&r2=239213&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
> +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Fri Jun  5 21:09:34
> 2015
> @@ -202,6 +202,7 @@ def _SLASH_Fi : CLCompileJoined<"Fi">,
>  def _SLASH_Fo : CLCompileJoined<"Fo">,
>    HelpText<"Set output object file, or directory (ends in / or \\)">,
>    MetaVarName<"<file or directory>">;
> +def _SLASH_GL : CLFlag<"GL">, Alias<flto>;
>  def _SLASH_LD : CLFlag<"LD">, HelpText<"Create DLL">;
>  def _SLASH_LDd : CLFlag<"LDd">, HelpText<"Create debug DLL">;
>  def _SLASH_link : CLRemainingArgs<"link">,
> @@ -286,7 +287,6 @@ def _SLASH_G2 : CLFlag<"G2">;
>  def _SLASH_Ge : CLFlag<"Ge">;
>  def _SLASH_Gh : CLFlag<"Gh">;
>  def _SLASH_GH : CLFlag<"GH">;
> -def _SLASH_GL : CLFlag<"GL">;
>  def _SLASH_GL_ : CLFlag<"GL-">;
>  def _SLASH_Gm : CLFlag<"Gm">;
>  def _SLASH_Gm_ : CLFlag<"Gm-">;
>
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=239213&r1=239212&r2=239213&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Fri Jun  5 21:09:34 2015
> @@ -1744,7 +1744,7 @@ const char *Driver::GetNamedOutputPath(C
>    // Determine what the derived output name should be.
>    const char *NamedOutput;
>
> -  if (JA.getType() == types::TY_Object &&
> +  if ((JA.getType() == types::TY_Object || JA.getType() ==
> types::TY_LTO_BC) &&
>        C.getArgs().hasArg(options::OPT__SLASH_Fo, options::OPT__SLASH_o)) {
>      // The /Fo or /o flag decides the object filename.
>      StringRef Val = C.getArgs().getLastArg(options::OPT__SLASH_Fo,
>
> Modified: cfe/trunk/lib/Driver/Types.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Types.cpp?rev=239213&r1=239212&r2=239213&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/Types.cpp (original)
> +++ cfe/trunk/lib/Driver/Types.cpp Fri Jun  5 21:09:34 2015
> @@ -45,7 +45,7 @@ types::ID types::getPreprocessedType(ID
>  }
>
>  const char *types::getTypeTempSuffix(ID Id, bool CLMode) {
> -  if (Id == TY_Object && CLMode)
> +  if ((Id == TY_Object || Id == TY_LTO_BC) && CLMode)
>      return "obj";
>    if (Id == TY_Image && CLMode)
>      return "exe";
>
> Modified: cfe/trunk/test/Driver/cl-outputs.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-outputs.c?rev=239213&r1=239212&r2=239213&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Driver/cl-outputs.c (original)
> +++ cfe/trunk/test/Driver/cl-outputs.c Fri Jun  5 21:09:34 2015
> @@ -273,3 +273,9 @@
>  // RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck
> -check-prefix=FioRACE2 %s
>  // FioRACE2: "-E"
>  // FioRACE2: "-o" "bar.x"
> +
> +// RUN: %clang_cl /c /GL -### -- %s 2>&1 | FileCheck
> -check-prefix=LTO-DEFAULT %s
> +// LTO-DEFAULT: "-emit-llvm-bc"{{.*}}"-o" "cl-outputs.obj"
> +
> +// RUN: %clang_cl /c /GL /Fofoo -### -- %s 2>&1 | FileCheck
> -check-prefix=LTO-FO %s
> +// LTO-FO: "-emit-llvm-bc"{{.*}}"-o" "foo.obj"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150612/6635287a/attachment.html>


More information about the cfe-commits mailing list