From 369cbcc1a21ab07ea6ca142a3b87c75d0a1b2014 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Wed, 25 Jun 2025 11:30:50 -0700 Subject: [PATCH] [lldb] include `LLVMTargetParser` in `LINK_COMPONENTS` (#145606) ## Purpose Fix duplicate symbol definition errors when building LLDB `HostTests` against a LLVM Windows DLL. ## Background When building LLDB `HostTests` against LLVM built as a Windows DLL, compilation fails due to multiple duplicate symbol definition errors. This is because symbols are both exported by the LLVM Windows DLL and the `LLVMTargetParser` library. ## Overview The issue is resolved by adding `LLVMTargetParser` (e.g. `TargetParser`) to `LINK_COMPONENTS`, which adds it to `LLVM_LINK_COMPONENTS`, rather than `LINK_LIBS`, which links directly against the library. This change makes it behave correctly when linking against a static or dynamic LLVM. --- lldb/unittests/Host/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lldb/unittests/Host/CMakeLists.txt b/lldb/unittests/Host/CMakeLists.txt index 3b20f1d723d1..5591edda38ac 100644 --- a/lldb/unittests/Host/CMakeLists.txt +++ b/lldb/unittests/Host/CMakeLists.txt @@ -37,7 +37,9 @@ add_lldb_unittest(HostTests lldbUtilityHelpers lldbHostHelpers LLVMTestingSupport - LLVMTargetParser + + LINK_COMPONENTS + TargetParser ) add_subdirectory(common)