Author: Charles Zablit
Date: 2026-06-17T16:54:05+01:00
New Revision: d3983310a4a65683d63ab6ab5af1a9bfde737128

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

LOG: [lldb][unittests] Add LLDB_UNITTEST_STRIP_DEBUG_INFO to cut unittest link 
time (#203274)

Add an opt-in cache option (default OFF). When ON, every target declared
via `add_lldb_unittest` links without per-target debug info and
dead-strips:
- **MSVC**: `/DEBUG:NONE + /INCREMENTAL:NO + /OPT:REF + /OPT:ICF`
- **clang/gcc**: `-g0 + LINKER:--strip-debug` (or `LINKER:-S` on macOS).

This drastically speeds up linking the unittests executable when
building with debug info on Windows.

Added: 
    

Modified: 
    lldb/unittests/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index 41e1c29c8093b..f8563a629f3bb 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -10,6 +10,12 @@ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
   add_compile_options("-Wno-suggest-override")
 endif()
 
+if (MSVC)
+  option(LLDB_UNITTEST_STRIP_DEBUG_INFO
+    "Strip debug info from lldb unit-test binaries to cut link time and disk \
+  usage when building with MSVC. Turn OFF when you need to debug a unittest 
binary." OFF)
+endif()
+
 function(add_lldb_unittest test_name)
   cmake_parse_arguments(ARG
     "SBAPITEST"
@@ -41,6 +47,16 @@ function(add_lldb_unittest test_name)
     COMMAND "${CMAKE_COMMAND}" -E make_directory 
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/Inputs)
 
   target_link_libraries(${test_name} PRIVATE ${ARG_LINK_LIBS})
+
+  if (MSVC)
+    if (LLDB_UNITTEST_STRIP_DEBUG_INFO)
+      target_link_options(${test_name} PRIVATE
+        "LINKER:/DEBUG:NONE"
+        "LINKER:/INCREMENTAL:NO"
+        "LINKER:/OPT:REF"
+        "LINKER:/OPT:ICF")
+    endif()
+  endif()
 endfunction()
 
 function(add_unittest_inputs test_name inputs)


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

Reply via email to