[llvm] 5b125a4 - [CMake] Add detection for the mold linker in AddLLVM.cmake.

Shivam Gupta via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 28 05:19:39 PDT 2021


Author: Frederic Cambus
Date: 2021-09-28T17:46:52+05:30
New Revision: 5b125a49ba9f52cb6b24767f3c98ce623a2d5207

URL: https://github.com/llvm/llvm-project/commit/5b125a49ba9f52cb6b24767f3c98ce623a2d5207
DIFF: https://github.com/llvm/llvm-project/commit/5b125a49ba9f52cb6b24767f3c98ce623a2d5207.diff

LOG: [CMake] Add detection for the mold linker in AddLLVM.cmake.

mold says it is compatible with GNU ld and gold linkers:

```
$ mold -v
mold 0.9.5 (compatible with GNU ld and GNU gold)
```

And thus it currently gets detected as Gold.

With the following diff, CMake now correctly reports the linker name, and mold keeps being identified as Gold internally for now.

Reviewed By: ldionne, MaskRay

Differential Revision: https://reviews.llvm.org/D110035

Added: 
    

Modified: 
    llvm/cmake/modules/AddLLVM.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index c5a9e0209f13b..6e1f97a8bbc06 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -193,7 +193,10 @@ if (NOT DEFINED LLVM_LINKER_DETECTED)
       OUTPUT_VARIABLE stdout
       ERROR_VARIABLE stderr
       )
-    if("${stdout}" MATCHES "GNU gold")
+    if("${stdout}" MATCHES "^mold")
+      set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
+      message(STATUS "Linker detection: mold")
+    elseif("${stdout}" MATCHES "GNU gold")
       set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
       set(LLVM_LINKER_IS_GOLD YES CACHE INTERNAL "")
       message(STATUS "Linker detection: GNU Gold")


        


More information about the llvm-commits mailing list