Index: lld/trunk/MinGW/Driver.cpp =================================================================== --- lld/trunk/MinGW/Driver.cpp +++ lld/trunk/MinGW/Driver.cpp @@ -14,6 +14,7 @@ #include "lld/Driver/Driver.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" @@ -124,7 +125,7 @@ std::vector LinkArgs; auto Add = [&](const Twine &S) { LinkArgs.push_back(S.str()); }; - Add(ArgsArr[0]); + Add("lld-link"); if (auto *A = Args.getLastArg(OPT_entry)) Add("-entry:" + StringRef(A->getValue())); @@ -175,6 +176,15 @@ Add(searchLibrary(A->getValue(), SearchPaths, Args.hasArg(OPT_Bstatic))); } + if (Args.hasArg(OPT_verbose)) + Add("-verbose"); + + if (Args.hasArg(OPT_verbose) || Args.hasArg(OPT__HASH_HASH_HASH)) + outs() << llvm::join(LinkArgs, " ") << "\n"; + + if (Args.hasArg(OPT__HASH_HASH_HASH)) + return true; + // Repack vector of strings to vector of const char pointers for coff::link. std::vector Vec; for (const std::string &S : LinkArgs) Index: lld/trunk/MinGW/Options.td =================================================================== --- lld/trunk/MinGW/Options.td +++ lld/trunk/MinGW/Options.td @@ -17,6 +17,11 @@ def subs: Separate<["--"], "subsystem">, HelpText<"Specify subsystem">; def stack: Separate<["--"], "stack">; def outlib: Separate<["--"], "out-implib">, HelpText<"Import library name">; +def verbose: F<"verbose">, HelpText<"Verbose mode">; + +// LLD specific options +def _HASH_HASH_HASH : Flag<["-"], "###">, + HelpText<"Print (but do not run) the commands to run for this compilation">; // Currently stubs to avoid errors def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">; @@ -27,7 +32,6 @@ def full_shutdown: Flag<["--"], "full-shutdown">; def O: Joined<["-"], "O">, HelpText<"Optimize output file size">; def v: Flag<["-"], "v">, HelpText<"Display the version number">; -def verbose: F<"verbose">, HelpText<"Verbose mode">; def version: F<"version">, HelpText<"Display the version number and exit">; // Alias Index: lld/trunk/test/MinGW/driver.s =================================================================== --- lld/trunk/test/MinGW/driver.s +++ lld/trunk/test/MinGW/driver.s @@ -10,6 +10,11 @@ # RUN: llvm-readobj %t.exe | FileCheck %s # CHECK: File: +# RUN: ld.lld -m i386pep -e main %t.obj -o %t.exe -verbose -### | FileCheck %s -check-prefix CHECK-VERBOSE +# CHECK-VERBOSE: lld-link -entry:main +# CHECK-VERBOSE-SAME: -machine:x64 -alternatename:__image_base__=__ImageBase +# CHECK-VERBOSE-SAME: -verbose + # RUN: ld.lld -m i386pep --entry main %t.obj -o %t.exe --subsystem console # RUN: llvm-readobj -file-headers %t.exe | FileCheck %s -check-prefix CHECK-CONSOLE # CHECK-CONSOLE: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)