[PATCH] Allow clang-cl to automatically use lld instead of forcing the MSVC linker

Rui Ueyama ruiu at google.com
Mon Dec 1 12:40:00 PST 2014


================
Comment at: lib/Driver/Tools.cpp:7987
@@ +7986,3 @@
+    ld_value = A->getValue();
+    if (StringRef(ld_value).equals_lower("lld"))
+      ld_value = "lld-link";
----------------
zturner wrote:
> ruiu wrote:
> > Why don't you just pass "lld-link" (not "lld") to -fuse-ld option?
> Because there should be a consistent syntax for specifying "link with lld" regardless of which platform you're on.  I don't want it to be -fuse-ld=lld on Linux, and -fuse-ld=lld-link on Windows, for example.
Got it.

================
Comment at: lib/Driver/Tools.cpp:7990
@@ +7989,3 @@
+  } else {
+    ld_value = "link";
+  }
----------------
thakis wrote:
> Somewhat tangential: It would be nice if clang could default to lld-link if link.exe isn't found. If I'm using clang-cl targeting Windows on non-Windows, and lld-link is in the same directory as clang-cl, it'd be great if clang-cl would then transparently use lld-link to link my PE binary instead of telling me "unable to execute command: Executable "link.exe" doesn't exist!"
> 
> (Not sure if this should be part of this change, but it's in the same code at least.)
Besides the issue how to find libraries in the environment where link.exe doesn't exist, lld currently depends on a few external command. rc.exe (resource compiler) and lib.exe (ar command) are needed. In order to make such silent fallback work, we need to eliminate that dependency.

http://reviews.llvm.org/D6428






More information about the cfe-commits mailing list