[patch] Use ld.lld2 as a argv[0] alias

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 15:36:11 PDT 2015


The reason for the name is so that we can run

./build/bin/clang -fuse-ld=lld2 test.o -o t


Cheers,
Rafael
-------------- next part --------------
diff --git a/lib/Driver/UniversalDriver.cpp b/lib/Driver/UniversalDriver.cpp
index 45bcbc8..056f138 100644
--- a/lib/Driver/UniversalDriver.cpp
+++ b/lib/Driver/UniversalDriver.cpp
@@ -86,6 +86,7 @@ static Flavor strToFlavor(StringRef str) {
   return llvm::StringSwitch<Flavor>(str)
       .Case("gnu", Flavor::gnu_ld)
       .Case("gnu2", Flavor::gnu_ld2)
+      .Case("ld.lld2", Flavor::gnu_ld2)
       .Case("link", Flavor::win_link)
       .Case("lld-link", Flavor::win_link)
       .Case("darwin", Flavor::darwin_ld)
@@ -156,7 +157,9 @@ static Flavor getFlavor(llvm::MutableArrayRef<const char *> &args,
   }
 #endif
 
-  StringRef name = llvm::sys::path::stem(args[0]);
+  StringRef name = llvm::sys::path::filename(args[0]);
+  if (llvm::sys::path::extension(name) == ".exe")
+    name = llvm::sys::path::stem(name);
   return strToFlavor(parseProgramName(name)._flavor);
 }
 
diff --git a/test/elf2/basic.s b/test/elf2/basic.s
index dca96f8..30e79c8 100644
--- a/test/elf2/basic.s
+++ b/test/elf2/basic.s
@@ -1,7 +1,7 @@
 # REQUIRES: x86
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: lld -flavor gnu2 %t -o %t2
+# RUN: ld.lld2  %t -o %t2
 # RUN: llvm-readobj -file-headers -sections -program-headers -symbols %t2 \
 # RUN:   | FileCheck %s
 
diff --git a/tools/lld/CMakeLists.txt b/tools/lld/CMakeLists.txt
index 2b6d9c2..6cf7291 100644
--- a/tools/lld/CMakeLists.txt
+++ b/tools/lld/CMakeLists.txt
@@ -12,7 +12,7 @@ install(TARGETS lld
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld2)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})


More information about the llvm-commits mailing list