[llvm] tblgen: fix dependency for gnu-ld (PR #161951)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 4 02:03:49 PDT 2025


https://github.com/aokblast created https://github.com/llvm/llvm-project/pull/161951

In gnu-ld, all symbols reference to an archive file should be placed before the archive itself. For example, libLLVMTableGen references the symbols in libLLVMSupport, and the libLLVMTableGen should be placed before it. Therefore, we reorder the archive orders.

>From 4eb7f6df67c237dacee1e01edbeb7807e84cb8fd Mon Sep 17 00:00:00 2001
From: ShengYi Hung <aokblast at FreeBSD.org>
Date: Sat, 4 Oct 2025 16:58:20 +0800
Subject: [PATCH] tblgen: fix dependency for gnu-ld

In gnu-ld, all symbols reference to an archive file should be placed
before the archive itself. For example, libLLVMTableGen references
the symbols in libLLVMSupport, and the libLLVMTableGen should be placed
before it. Therefore, we reorder the archive orders.
---
 llvm/cmake/modules/TableGen.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index 9a2e73a1e3718..d50146ef24c9e 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -171,7 +171,7 @@ macro(add_tablegen target project)
   cmake_parse_arguments(ADD_TABLEGEN "" "DESTINATION;EXPORT" "" ${ARGN})
 
   set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
-  set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
+  set(LLVM_LINK_COMPONENTS TableGen ${LLVM_LINK_COMPONENTS})
 
   add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB
     ${ADD_TABLEGEN_UNPARSED_ARGUMENTS})



More information about the llvm-commits mailing list