Author: bala-bhargav
Date: 2026-01-28T21:23:29-10:00
New Revision: 507d1856ccef4193ed48edabc010fe4661c9216c

URL: 
https://github.com/llvm/llvm-project/commit/507d1856ccef4193ed48edabc010fe4661c9216c
DIFF: 
https://github.com/llvm/llvm-project/commit/507d1856ccef4193ed48edabc010fe4661c9216c.diff

LOG: [clang][unittests] Fix linker error for DirectoryWatcherTest with 
CLANG_LINK_CLANG_DYLIB (#178455)

Move clangDirectoryWatcher from LINK_LIBS to CLANG_LIBS so it gets
replaced by clang-cpp when building with CLANG_LINK_CLANG_DYLIB=ON.

When using both CLANG_LINK_CLANG_DYLIB=ON and LLVM_ENABLE_LTO=Thin, the
test would fail with:
ld.lld: error: undefined symbol:
clang::DirectoryWatcher::create(llvm::StringRef, std::function<void
(llvm::ArrayRef

This happens because clangDirectoryWatcher was being linked as a
separate library alongside clang-cpp (which already contains
clangDirectoryWatcher), causing duplicate symbol issues with LTO.

The fix correctly categorizes:
- clangDirectoryWatcher → CLANG_LIBS (Clang library, bundled in
clang-cpp)
- LLVMTestingSupport → LINK_LIBS (LLVM library, always linked directly)

#178302

Added: 
    

Modified: 
    clang/unittests/DirectoryWatcher/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang/unittests/DirectoryWatcher/CMakeLists.txt 
b/clang/unittests/DirectoryWatcher/CMakeLists.txt
index 58e0aee2d1076..28fc6cb21010c 100644
--- a/clang/unittests/DirectoryWatcher/CMakeLists.txt
+++ b/clang/unittests/DirectoryWatcher/CMakeLists.txt
@@ -2,9 +2,10 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Linux" OR 
CMAKE_SYSTEM_NAME STREQUAL Wind
 
   add_clang_unittest(DirectoryWatcherTests
     DirectoryWatcherTest.cpp
+    CLANG_LIBS
+    clangDirectoryWatcher
     LINK_LIBS
     LLVMTestingSupport
-    clangDirectoryWatcher
     LLVM_COMPONENTS
     Support
     )


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to