Skip to content

Conversation

@andrurogerz
Copy link
Contributor

@andrurogerz andrurogerz commented Jun 24, 2025

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.

@andrurogerz andrurogerz marked this pull request as ready for review June 24, 2025 23:00
@llvmbot llvmbot added the lldb label Jun 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 24, 2025

@llvm/pr-subscribers-lldb

Author: Andrew Rogers (andrurogerz)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/145606.diff

1 Files Affected:

  • (modified) lldb/unittests/Host/CMakeLists.txt (+3-1)
diff --git a/lldb/unittests/Host/CMakeLists.txt b/lldb/unittests/Host/CMakeLists.txt
index 3b20f1d723d18..5591edda38aca 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)

@charles-zablit
Copy link
Contributor

Confirmed that this builds fine with the changes 👍

@charles-zablit
Copy link
Contributor

@andrurogerz do you need us to merge this for you?

@andrurogerz
Copy link
Contributor Author

do you need us to merge this for you?

@charles-zablit yes, I would appreciate it! Thank you!

@charles-zablit charles-zablit merged commit 369cbcc into llvm:main Jun 25, 2025
11 checks passed
anthonyhatran pushed a commit to anthonyhatran/llvm-project that referenced this pull request Jun 26, 2025
## 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.
@andrurogerz andrurogerz deleted the lldb-host-test branch July 23, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants