[llvm] [llvm] update a few llvm unit tests to link statically (PR #145448)

Andrew Rogers via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 24 08:56:37 PDT 2025


https://github.com/andrurogerz updated https://github.com/llvm/llvm-project/pull/145448

>From b8b3fb8348c84261e372935d61f75ae8fbc734fb Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 17:43:33 -0700
Subject: [PATCH 1/6] [llvm] add a version of LLVMTestingSupport which links
 against static libs

---
 llvm/lib/Testing/Support/CMakeLists.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/llvm/lib/Testing/Support/CMakeLists.txt b/llvm/lib/Testing/Support/CMakeLists.txt
index 6955271239ca6..425427b433f14 100644
--- a/llvm/lib/Testing/Support/CMakeLists.txt
+++ b/llvm/lib/Testing/Support/CMakeLists.txt
@@ -20,6 +20,23 @@ add_llvm_library(LLVMTestingSupport
 
 target_link_libraries(LLVMTestingSupport PRIVATE llvm_gtest)
 
+add_llvm_library(LLVMTestingSupportStatic
+  Error.cpp
+  SupportHelpers.cpp
+
+  ${BUILDTREE_ONLY}
+
+  ADDITIONAL_HEADER_DIRS
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/Testing/Support
+
+  LINK_COMPONENTS
+  Support
+
+  DISABLE_LLVM_LINK_LLVM_DYLIB
+  )
+
+target_link_libraries(LLVMTestingSupportStatic PRIVATE llvm_gtest)
+
 # This is to avoid the error in gtest-death-test-internal.h
 # (150,16): error: 'Create' overrides a member function but
 # is not marked 'override' [-Werror,-Wsuggest-override]

>From 9d2576cb01573c2bfd4efc42d54eea84d8e04859 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 17:45:01 -0700
Subject: [PATCH 2/6] [llvm] make CodeGentests link against static libs

---
 llvm/unittests/CodeGen/CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/unittests/CodeGen/CMakeLists.txt b/llvm/unittests/CodeGen/CMakeLists.txt
index 8b025219c46cf..9d3b8fc837a61 100644
--- a/llvm/unittests/CodeGen/CMakeLists.txt
+++ b/llvm/unittests/CodeGen/CMakeLists.txt
@@ -48,8 +48,10 @@ add_llvm_unittest(CodeGenTests
   TestAsmPrinter.cpp
   MLRegAllocDevelopmentFeatures.cpp
   X86MCInstLowerTest.cpp
+
+  DISABLE_LLVM_LINK_LLVM_DYLIB
   )
 
 add_subdirectory(GlobalISel)
 
-target_link_libraries(CodeGenTests PRIVATE LLVMTestingSupport)
+target_link_libraries(CodeGenTests PRIVATE LLVMTestingSupportStatic)

>From 15264b104e98b8aedf635a59b9b4fe2348e9aa66 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 17:45:52 -0700
Subject: [PATCH 3/6] [llvm] make DebugInfoLogicalViewTests and
 DebugInfoDWARFTests link against static libs

---
 llvm/unittests/DebugInfo/DWARF/CMakeLists.txt       | 4 +++-
 llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt b/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
index 0c5b3f28ca3d5..a8b3c7cf6a012 100644
--- a/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
+++ b/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
@@ -28,6 +28,8 @@ add_llvm_unittest(DebugInfoDWARFTests
   DWARFFormValueTest.cpp
   DWARFListTableTest.cpp
   DWARFLocationExpressionTest.cpp
+
+  DISABLE_LLVM_LINK_LLVM_DYLIB
   )
 
-target_link_libraries(DebugInfoDWARFTests PRIVATE LLVMTestingSupport)
+target_link_libraries(DebugInfoDWARFTests PRIVATE LLVMTestingSupportStatic)
diff --git a/llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt b/llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt
index 42a4b72229483..0d7d8c1d52254 100644
--- a/llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt
+++ b/llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt
@@ -22,6 +22,8 @@ add_llvm_unittest_with_input_files(DebugInfoLogicalViewTests
   LogicalElementsTest.cpp
   StringPoolTest.cpp
   WarningInternalTest.cpp
+
+  DISABLE_LLVM_LINK_LLVM_DYLIB
   )
 
-target_link_libraries(DebugInfoLogicalViewTests PRIVATE LLVMTestingSupport)
+target_link_libraries(DebugInfoLogicalViewTests PRIVATE LLVMTestingSupportStatic)

>From 439d77af695caf1c48ae39205022ddd6aa1338ae Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 17:46:32 -0700
Subject: [PATCH 4/6] [llvm] make FileCheckTests link against static libs

---
 llvm/unittests/FileCheck/CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/unittests/FileCheck/CMakeLists.txt b/llvm/unittests/FileCheck/CMakeLists.txt
index 7fe4f0c009d02..10de51cbe1d43 100644
--- a/llvm/unittests/FileCheck/CMakeLists.txt
+++ b/llvm/unittests/FileCheck/CMakeLists.txt
@@ -5,6 +5,8 @@ set(LLVM_LINK_COMPONENTS
 
 add_llvm_unittest(FileCheckTests
   FileCheckTest.cpp
+
+  DISABLE_LLVM_LINK_LLVM_DYLIB
 )
 
-target_link_libraries(FileCheckTests PRIVATE LLVMTestingSupport)
+target_link_libraries(FileCheckTests PRIVATE LLVMTestingSupportStatic)

>From 9d4bf0bf0c07b32f92075faabcf1498fde472d28 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 18:32:26 -0700
Subject: [PATCH 5/6] [llvm] make TableGenTests link against static libs

---
 llvm/unittests/TableGen/CMakeLists.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/unittests/TableGen/CMakeLists.txt b/llvm/unittests/TableGen/CMakeLists.txt
index 57b237306b19c..854f6c0f9b162 100644
--- a/llvm/unittests/TableGen/CMakeLists.txt
+++ b/llvm/unittests/TableGen/CMakeLists.txt
@@ -13,6 +13,8 @@ add_llvm_unittest(TableGenTests
   AutomataTest.cpp
   CodeExpanderTest.cpp
   ParserEntryPointTest.cpp
+
+  DISABLE_LLVM_LINK_LLVM_DYLIB
   )
 
 target_link_libraries(TableGenTests PRIVATE LLVMTableGenCommon LLVMTableGen)

>From ccb5288c73a9a0d80d338c5f53904ee13d12701e Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 18:33:01 -0700
Subject: [PATCH 6/6] [llvm] make VectorizeTests link against static libs

---
 llvm/unittests/Transforms/Vectorize/CMakeLists.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/unittests/Transforms/Vectorize/CMakeLists.txt b/llvm/unittests/Transforms/Vectorize/CMakeLists.txt
index 53eeff28c185f..4bed42e46cc2d 100644
--- a/llvm/unittests/Transforms/Vectorize/CMakeLists.txt
+++ b/llvm/unittests/Transforms/Vectorize/CMakeLists.txt
@@ -15,4 +15,6 @@ add_llvm_unittest(VectorizeTests
   VPlanPatternMatchTest.cpp
   VPlanSlpTest.cpp
   VPlanVerifierTest.cpp
+
+  DISABLE_LLVM_LINK_LLVM_DYLIB
   )



More information about the llvm-commits mailing list