[PATCH] D118070: Make lld-link work in a non-MSVC shell

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 2 06:11:52 PST 2022


aganea added a comment.

In D118070#3289227 <https://reviews.llvm.org/D118070#3289227>, @MaskRay wrote:

> I know that you  want a place to be accessed by both clang driver and lld-link but I am a bit nervous about the clang-driver style MSVC library sitting inside llvm/lib/Support/.
> Is there a better place? @compnerd @aganea

Does it make sense to add a new platform library? LLVMPlatformWindows? LLVMWindows? LLVMWindowsTools? LLVMWindowsABI?

> Makes lld-link work in a non-MSVC shell by autodetecting MSVC toolchain. Also adds support for /winsysroot and a few other switches.

@pkasting Note, this patch makes the outcome non-deterministic when the auto-detection kicks in. We are stamping the command-line the .PDB file, see  https://github.com/llvm/llvm-project/blob/main/lld/COFF/PDB.cpp#L1402 - and some live-code-patching tools rely on that to reproduce the link. It'd be nice if the detected paths are queued to `config->argv`, to ensure that we can emit a self-standing LLD cmd-line, a bit like what `clang -cc1` does.



================
Comment at: lld/COFF/Driver.h:122
   // Library search path. The first element is always "" (current directory).
-  std::vector<StringRef> searchPaths;
+  std::vector<std::string> searchPaths;
 
----------------
You could also use `saver().save(...)` below and keep this member intact. That would save some memory allocations.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118070/new/

https://reviews.llvm.org/D118070



More information about the llvm-commits mailing list