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

Frederic Cambus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 19 06:32:52 PDT 2021


fcambus created this revision.
fcambus added reviewers: ldionne, smeenai, ruiu.
Herald added a subscriber: mgorny.
fcambus requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110035

Files:
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -193,7 +193,11 @@
       OUTPUT_VARIABLE stdout
       ERROR_VARIABLE stderr
       )
-    if("${stdout}" MATCHES "GNU gold")
+    if("${stdout}" MATCHES "^mold")
+      set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
+      set(LLVM_LINKER_IS_GOLD 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")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110035.373455.patch
Type: text/x-patch
Size: 710 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210919/db4187ed/attachment.bin>


More information about the llvm-commits mailing list