Skip to content

Conversation

dpalermo
Copy link
Contributor

@dpalermo dpalermo commented Apr 2, 2025

Reverts #133545

This change is breaking several buildbots as well as developer's builds. Reverting to allow people to make progress.

@dpalermo dpalermo requested a review from cyndyishida as a code owner April 2, 2025 03:17
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang-format clang:modules C++20 modules and Clang Header Modules clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html labels Apr 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 2, 2025

@llvm/pr-subscribers-clang-modules
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-format

Author: None (dpalermo)

Changes

Reverts llvm/llvm-project#133545

This change is breaking several buildbots as well as developer's builds. Reverting to allow people to make progress.


Patch is 21.94 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/134022.diff

28 Files Affected:

  • (modified) clang/unittests/AST/ByteCode/CMakeLists.txt (+9-3)
  • (modified) clang/unittests/AST/CMakeLists.txt (+16-7)
  • (modified) clang/unittests/ASTMatchers/CMakeLists.txt (+15-7)
  • (modified) clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt (+13-5)
  • (modified) clang/unittests/Analysis/CMakeLists.txt (+13-5)
  • (modified) clang/unittests/Analysis/FlowSensitive/CMakeLists.txt (+13-5)
  • (modified) clang/unittests/Basic/CMakeLists.txt (+13-5)
  • (modified) clang/unittests/CMakeLists.txt (+4-28)
  • (modified) clang/unittests/CodeGen/CMakeLists.txt (+10-5)
  • (modified) clang/unittests/CrossTU/CMakeLists.txt (+9-3)
  • (modified) clang/unittests/DirectoryWatcher/CMakeLists.txt (+8-3)
  • (modified) clang/unittests/Driver/CMakeLists.txt (+12-7)
  • (modified) clang/unittests/Format/CMakeLists.txt (+8-3)
  • (modified) clang/unittests/Frontend/CMakeLists.txt (+8-4)
  • (modified) clang/unittests/Index/CMakeLists.txt (+9-4)
  • (modified) clang/unittests/InstallAPI/CMakeLists.txt (+6-3)
  • (modified) clang/unittests/Interpreter/CMakeLists.txt (+13-12)
  • (modified) clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt (+11-9)
  • (modified) clang/unittests/Lex/CMakeLists.txt (+12-4)
  • (modified) clang/unittests/Rewrite/CMakeLists.txt (+7-3)
  • (modified) clang/unittests/Sema/CMakeLists.txt (+13-5)
  • (modified) clang/unittests/Serialization/CMakeLists.txt (+11-6)
  • (modified) clang/unittests/StaticAnalyzer/CMakeLists.txt (+13-5)
  • (modified) clang/unittests/Support/CMakeLists.txt (+8-3)
  • (modified) clang/unittests/Tooling/CMakeLists.txt (+17-11)
  • (modified) clang/unittests/Tooling/Syntax/CMakeLists.txt (+10-5)
  • (modified) clang/unittests/libclang/CMakeLists.txt (+4-1)
  • (modified) clang/unittests/libclang/CrashTests/CMakeLists.txt (+4-1)
diff --git a/clang/unittests/AST/ByteCode/CMakeLists.txt b/clang/unittests/AST/ByteCode/CMakeLists.txt
index 7ccadda2eeb26..b862fb4834fbd 100644
--- a/clang/unittests/AST/ByteCode/CMakeLists.txt
+++ b/clang/unittests/AST/ByteCode/CMakeLists.txt
@@ -2,13 +2,19 @@ add_clang_unittest(InterpTests
   BitcastBuffer.cpp
   Descriptor.cpp
   toAPValue.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(InterpTests
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangFrontend
   clangSerialization
   clangTooling
-  LINK_LIBS
-  clangTesting
   )
+
+  target_link_libraries(InterpTests
+  PRIVATE
+  clangTesting
+)
diff --git a/clang/unittests/AST/CMakeLists.txt b/clang/unittests/AST/CMakeLists.txt
index f27d34e8a0719..bfa6082a6ffa4 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -1,3 +1,10 @@
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support
+  TargetParser
+  )
+
+
 add_subdirectory(ByteCode)
 
 add_clang_unittest(ASTTests
@@ -36,7 +43,10 @@ add_clang_unittest(ASTTests
   TemplateNameTest.cpp
   TypePrinterTest.cpp
   UnresolvedSetTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(ASTTests
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
@@ -44,12 +54,11 @@ add_clang_unittest(ASTTests
   clangLex
   clangSerialization
   clangTooling
-  LINK_LIBS
+  )
+
+target_link_libraries(ASTTests
+  PRIVATE
   clangTesting
   LLVMTestingAnnotations
   LLVMTestingSupport
-  LLVM_COMPONENTS
-  FrontendOpenMP
-  Support
-  TargetParser
-  )
+)
diff --git a/clang/unittests/ASTMatchers/CMakeLists.txt b/clang/unittests/ASTMatchers/CMakeLists.txt
index 47bd5c108bb5a..6a1e629d81b65 100644
--- a/clang/unittests/ASTMatchers/CMakeLists.txt
+++ b/clang/unittests/ASTMatchers/CMakeLists.txt
@@ -1,23 +1,31 @@
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support
+  TargetParser
+  )
+
 add_clang_unittest(ASTMatchersTests
   ASTMatchersInternalTest.cpp
   ASTMatchersNodeTest.cpp
   ASTMatchersNarrowingTest.cpp
   ASTMatchersTraversalTest.cpp
   GtestMatchersTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(ASTMatchersTests
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
   clangFrontend
   clangSerialization
   clangTooling
-  LINK_LIBS
+  )
+
+target_link_libraries(ASTMatchersTests
+  PRIVATE
   clangTesting
   LLVMTestingSupport
-  LLVM_COMPONENTS
-  FrontendOpenMP
-  Support
-  TargetParser
-  )
+)
 
 add_subdirectory(Dynamic)
diff --git a/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt b/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
index b6db7ce62afe7..6d0e12bcb0759 100644
--- a/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
+++ b/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
@@ -1,8 +1,16 @@
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support
+  )
+
 add_clang_unittest(DynamicASTMatchersTests
   VariantValueTest.cpp
   ParserTest.cpp
   RegistryTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(DynamicASTMatchersTests
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
@@ -10,9 +18,9 @@ add_clang_unittest(DynamicASTMatchersTests
   clangFrontend
   clangSerialization
   clangTooling
-  LINK_LIBS
+  )
+
+target_link_libraries(DynamicASTMatchersTests
+  PRIVATE
   clangTesting
-  LLVM_COMPONENTS
-  FrontendOpenMP
-  Support
   )
diff --git a/clang/unittests/Analysis/CMakeLists.txt b/clang/unittests/Analysis/CMakeLists.txt
index 059a74843155c..cfea57f53f033 100644
--- a/clang/unittests/Analysis/CMakeLists.txt
+++ b/clang/unittests/Analysis/CMakeLists.txt
@@ -1,3 +1,8 @@
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support
+  )
+
 add_clang_unittest(ClangAnalysisTests
   CFGDominatorTree.cpp
   CFGTest.cpp
@@ -6,7 +11,10 @@ add_clang_unittest(ClangAnalysisTests
   IntervalPartitionTest.cpp
   MacroExpansionContextTest.cpp
   UnsafeBufferUsageTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(ClangAnalysisTests
+  PRIVATE
   clangAST
   clangASTMatchers
   clangAnalysis
@@ -15,12 +23,12 @@ add_clang_unittest(ClangAnalysisTests
   clangLex
   clangSerialization
   clangTooling
-  LINK_LIBS
+  )
+
+target_link_libraries(ClangAnalysisTests
+  PRIVATE
   clangTesting
   LLVMTestingSupport
-  LLVM_COMPONENTS
-  FrontendOpenMP
-  Support
   )
 
 add_subdirectory(FlowSensitive)
diff --git a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
index 4ac563143cd68..6c01ae8fc2e54 100644
--- a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
+++ b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
@@ -1,3 +1,8 @@
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support
+  )
+
 add_clang_unittest(ClangAnalysisFlowSensitiveTests
   ArenaTest.cpp
   ASTOpsTest.cpp
@@ -25,7 +30,10 @@ add_clang_unittest(ClangAnalysisFlowSensitiveTests
   UncheckedOptionalAccessModelTest.cpp
   ValueTest.cpp
   WatchedLiteralsSolverTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(ClangAnalysisFlowSensitiveTests
+  PRIVATE
   clangAST
   clangASTMatchers
   clangAnalysis
@@ -36,11 +44,11 @@ add_clang_unittest(ClangAnalysisFlowSensitiveTests
   clangLex
   clangSerialization
   clangTooling
-  LINK_LIBS
+  )
+
+target_link_libraries(ClangAnalysisFlowSensitiveTests
+  PRIVATE
   clangTesting
   LLVMTestingAnnotations
   LLVMTestingSupport
-  LLVM_COMPONENTS
-  FrontendOpenMP
-  Support
   )
diff --git a/clang/unittests/Basic/CMakeLists.txt b/clang/unittests/Basic/CMakeLists.txt
index e818bd3e2c372..3844ba49add8d 100644
--- a/clang/unittests/Basic/CMakeLists.txt
+++ b/clang/unittests/Basic/CMakeLists.txt
@@ -1,3 +1,7 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
 add_clang_unittest(BasicTests
   CharInfoTest.cpp
   DarwinSDKInfoTest.cpp
@@ -8,11 +12,15 @@ add_clang_unittest(BasicTests
   SanitizersTest.cpp
   SarifTest.cpp
   SourceManagerTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(BasicTests
+  PRIVATE
   clangBasic
   clangLex
-  LINK_LIBS
-  LLVMTestingSupport
-  LLVM_COMPONENTS
-  Support
   )
+
+target_link_libraries(BasicTests
+  PRIVATE
+  LLVMTestingSupport
+)
diff --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index f3823ba309420..9b3ce8aa7de73 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -15,36 +15,12 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
-# add_clang_unittest(test_name file1.cpp file2.cpp)
+# add_clang_unittest(test_dirname file1.cpp file2.cpp)
 #
 # Will compile the list of files together and link against the clang
-# Produces a binary named 'basename(test_name)'.
-function(add_clang_unittest test_name)
-  cmake_parse_arguments(ARG
-    ""
-    ""
-    "CLANG_LIBS;LINK_LIBS;LLVM_COMPONENTS"
-    ${ARGN})
-
-  if (NOT ${test_name} MATCHES "Tests$")
-    message(FATAL_ERROR "Unit test name must end with 'Tests' for lit to find it.")
-  endif()
-
-  # LLVM_COMPONENTS is for LLVM_LINK_COMPONENTS deps, and must be before
-  # add_unittest.
-  list(APPEND LLVM_LINK_COMPONENTS ${ARG_LLVM_COMPONENTS})
-
-  add_unittest(ClangUnitTests ${test_name} ${ARG_UNPARSED_ARGUMENTS})
-
-  # Clang libs either come from the entire dylib, or individual libraries.
-  if (CLANG_LINK_CLANG_DYLIB)
-    list(APPEND ARG_LINK_LIBS clang-cpp)
-  else()
-    list(APPEND ARG_LINK_LIBS ${ARG_CLANG_LIBS})
-  endif()
-
-  # LINK_LIBS is for normal library dependencies.
-  target_link_libraries(${test_name} PRIVATE ${ARG_LINK_LIBS})
+# Produces a binary named 'basename(test_dirname)'.
+function(add_clang_unittest test_dirname)
+  add_unittest(ClangUnitTests ${test_dirname} ${ARGN})
 endfunction()
 
 add_subdirectory(Basic)
diff --git a/clang/unittests/CodeGen/CMakeLists.txt b/clang/unittests/CodeGen/CMakeLists.txt
index f5bcecb0b08a3..a437f441568f2 100644
--- a/clang/unittests/CodeGen/CMakeLists.txt
+++ b/clang/unittests/CodeGen/CMakeLists.txt
@@ -1,9 +1,18 @@
+set(LLVM_LINK_COMPONENTS
+  Core
+  Support
+  TargetParser
+  )
+
 add_clang_unittest(ClangCodeGenTests
   BufferSourceTest.cpp
   CodeGenExternalTest.cpp
   TBAAMetadataTest.cpp
   CheckTargetFeaturesTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(ClangCodeGenTests
+  PRIVATE
   clangAST
   clangBasic
   clangCodeGen
@@ -11,8 +20,4 @@ add_clang_unittest(ClangCodeGenTests
   clangLex
   clangParse
   clangSerialization
-  LLVM_COMPONENTS
-  Core
-  Support
-  TargetParser
   )
diff --git a/clang/unittests/CrossTU/CMakeLists.txt b/clang/unittests/CrossTU/CMakeLists.txt
index ee81c57ca1dce..222b7e83dc38c 100644
--- a/clang/unittests/CrossTU/CMakeLists.txt
+++ b/clang/unittests/CrossTU/CMakeLists.txt
@@ -1,12 +1,18 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Support
+  )
+
 add_clang_unittest(CrossTUTests
   CrossTranslationUnitTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(CrossTUTests
+  PRIVATE
   clangAST
   clangBasic
   clangCrossTU
   clangFrontend
   clangSerialization
   clangTooling
-  LLVM_COMPONENTS
-  Support
   )
diff --git a/clang/unittests/DirectoryWatcher/CMakeLists.txt b/clang/unittests/DirectoryWatcher/CMakeLists.txt
index 58e0aee2d1076..38882c9ec2162 100644
--- a/clang/unittests/DirectoryWatcher/CMakeLists.txt
+++ b/clang/unittests/DirectoryWatcher/CMakeLists.txt
@@ -1,12 +1,17 @@
 if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME STREQUAL Windows)
 
+  set(LLVM_LINK_COMPONENTS
+    Support
+    )
+
   add_clang_unittest(DirectoryWatcherTests
     DirectoryWatcherTest.cpp
-    LINK_LIBS
+    )
+
+  target_link_libraries(DirectoryWatcherTests
+    PRIVATE
     LLVMTestingSupport
     clangDirectoryWatcher
-    LLVM_COMPONENTS
-    Support
     )
 
 endif()
diff --git a/clang/unittests/Driver/CMakeLists.txt b/clang/unittests/Driver/CMakeLists.txt
index fa0e87c3318df..efdd07ea23889 100644
--- a/clang/unittests/Driver/CMakeLists.txt
+++ b/clang/unittests/Driver/CMakeLists.txt
@@ -1,3 +1,11 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  MC
+  Option
+  Support
+  TargetParser
+  )
+
 add_clang_unittest(ClangDriverTests
   DistroTest.cpp
   DXCModeTest.cpp
@@ -7,15 +15,12 @@ add_clang_unittest(ClangDriverTests
   MultilibBuilderTest.cpp
   MultilibTest.cpp
   SanitizerArgsTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(ClangDriverTests
+  PRIVATE
   clangDriver
   clangBasic
   clangFrontend # For TextDiagnosticPrinter.
   clangSerialization
-  LLVM_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
-  MC
-  Option
-  Support
-  TargetParser
   )
diff --git a/clang/unittests/Format/CMakeLists.txt b/clang/unittests/Format/CMakeLists.txt
index 5bd6a17182d29..71f5886d946c8 100644
--- a/clang/unittests/Format/CMakeLists.txt
+++ b/clang/unittests/Format/CMakeLists.txt
@@ -1,3 +1,7 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
 add_clang_unittest(FormatTests
   BracesInserterTest.cpp
   BracesRemoverTest.cpp
@@ -32,11 +36,12 @@ add_clang_unittest(FormatTests
   SortIncludesTest.cpp
   UsingDeclarationsSorterTest.cpp
   TokenAnnotatorTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(FormatTests
+  PRIVATE
   clangBasic
   clangFormat
   clangRewrite
   clangToolingCore
-  LLVM_COMPONENTS
-  Support
   )
diff --git a/clang/unittests/Frontend/CMakeLists.txt b/clang/unittests/Frontend/CMakeLists.txt
index bbf0396014fa9..3c94846243870 100644
--- a/clang/unittests/Frontend/CMakeLists.txt
+++ b/clang/unittests/Frontend/CMakeLists.txt
@@ -1,3 +1,8 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  TargetParser
+  )
+
 add_clang_unittest(FrontendTests
   ASTUnitTest.cpp
   CompilerInvocationTest.cpp
@@ -12,7 +17,9 @@ add_clang_unittest(FrontendTests
   OutputStreamTest.cpp
   TextDiagnosticTest.cpp
   UtilsTest.cpp
-  CLANG_LIBS
+  )
+clang_target_link_libraries(FrontendTests
+  PRIVATE
   clangAST
   clangBasic
   clangFrontend
@@ -22,7 +29,4 @@ add_clang_unittest(FrontendTests
   clangFrontendTool
   clangSerialization
   clangTooling
-  LLVM_COMPONENTS
-  Support
-  TargetParser
   )
diff --git a/clang/unittests/Index/CMakeLists.txt b/clang/unittests/Index/CMakeLists.txt
index 15e9ba0643eaf..ea940e9d7a9ef 100644
--- a/clang/unittests/Index/CMakeLists.txt
+++ b/clang/unittests/Index/CMakeLists.txt
@@ -1,6 +1,14 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Support
+  )
+
 add_clang_unittest(IndexTests
   IndexTests.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(IndexTests
+  PRIVATE
   clangAST
   clangBasic
   clangFrontend
@@ -8,7 +16,4 @@ add_clang_unittest(IndexTests
   clangLex
   clangSerialization
   clangTooling
-  LLVM_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
-  Support
   )
diff --git a/clang/unittests/InstallAPI/CMakeLists.txt b/clang/unittests/InstallAPI/CMakeLists.txt
index c174fa3f87161..4255001ff51f1 100644
--- a/clang/unittests/InstallAPI/CMakeLists.txt
+++ b/clang/unittests/InstallAPI/CMakeLists.txt
@@ -1,8 +1,11 @@
 add_clang_unittest(InstallAPITests
   HeaderFileTest.cpp
   FileListTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(InstallAPITests
+  PRIVATE
   clangInstallAPI 
-  LINK_LIBS
-  LLVMTestingSupport
   )
+
+target_link_libraries(InstallAPITests PRIVATE LLVMTestingSupport)
diff --git a/clang/unittests/Interpreter/CMakeLists.txt b/clang/unittests/Interpreter/CMakeLists.txt
index 9df1a4b03da47..95378f9cfe737 100644
--- a/clang/unittests/Interpreter/CMakeLists.txt
+++ b/clang/unittests/Interpreter/CMakeLists.txt
@@ -1,3 +1,12 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Core
+  MC
+  OrcJIT
+  Support
+  TargetParser
+  )
+
 add_clang_unittest(ClangReplInterpreterTests
   IncrementalCompilerBuilderTest.cpp
   IncrementalProcessingTest.cpp
@@ -6,24 +15,16 @@ add_clang_unittest(ClangReplInterpreterTests
   CodeCompletionTest.cpp
 
   EXPORT_SYMBOLS
+  )
+  
+target_link_libraries(ClangReplInterpreterTests PUBLIC LLVMTestingSupport)
 
-  CLANG_LIBS
+clang_target_link_libraries(ClangReplInterpreterTests PRIVATE
   clangAST
   clangBasic
   clangInterpreter
   clangFrontend
   clangSema
-
-  LINK_LIBS
-  LLVMTestingSupport
-
-  LLVM_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
-  Core
-  MC
-  OrcJIT
-  Support
-  TargetParser
   )
 
 # Exceptions on Windows are not yet supported.
diff --git a/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt b/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
index eb366a860661c..24ae9cd78b5ca 100644
--- a/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
+++ b/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
@@ -3,22 +3,24 @@
 set(LLVM_REQUIRES_EH ON)
 set(LLVM_REQUIRES_RTTI ON)
 
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Core
+  OrcJIT
+  Support
+  )
+
 add_clang_unittest(ClangReplInterpreterExceptionTests
   InterpreterExceptionTest.cpp
+
   EXPORT_SYMBOLS
+  )
 
-  CLANG_LIBS
+llvm_update_compile_flags(ClangReplInterpreterExceptionTests)
+target_link_libraries(ClangReplInterpreterExceptionTests PUBLIC
   clangAST
   clangBasic
   clangInterpreter
   clangFrontend
-
-  LLVM_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
-  Core
-  OrcJIT
-  Support
   )
-
-llvm_update_compile_flags(ClangReplInterpreterExceptionTests)
 add_dependencies(ClangReplInterpreterExceptionTests clang-resource-headers)
diff --git a/clang/unittests/Lex/CMakeLists.txt b/clang/unittests/Lex/CMakeLists.txt
index 96ca6dda9cd85..5ec93946594b7 100644
--- a/clang/unittests/Lex/CMakeLists.txt
+++ b/clang/unittests/Lex/CMakeLists.txt
@@ -1,3 +1,7 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
 add_clang_unittest(LexTests
   DependencyDirectivesScannerTest.cpp
   HeaderMapTest.cpp
@@ -9,15 +13,19 @@ add_clang_unittest(LexTests
   PPConditionalDirectiveRecordTest.cpp
   PPDependencyDirectivesTest.cpp
   PPMemoryAllocationsTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(LexTests
+  PRIVATE
   clangAST
   clangBasic
   clangLex
   clangParse
   clangSema
-  LINK_LIBS
+  )
+
+target_link_libraries(LexTests
+  PRIVATE
   LLVMTestingAnnotations
   LLVMTestingSupport
-  LLVM_COMPONENTS
-  Support
   )
diff --git a/clang/unittests/Rewrite/CMakeLists.txt b/clang/unittests/Rewrite/CMakeLists.txt
index 498613254e72b..3c5e2f8e5354b 100644
--- a/clang/unittests/Rewrite/CMakeLists.txt
+++ b/clang/unittests/Rewrite/CMakeLists.txt
@@ -1,10 +1,14 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
 add_clang_unittest(RewriteTests
   RewriterTest.cpp
-  CLANG_LIBS
+  )
+clang_target_link_libraries(RewriteTests
+  PRIVATE
   clangFrontend
   clangRewrite
   clangSerialization
   clangTooling
-  LLVM_COMPONENTS
-  Support
   )
diff --git a/clang/unittests/Sema/CMakeLists.txt b/clang/unittests/Sema/CMakeLists.txt
index acc76c932afeb..17d39408000a4 100644
--- a/clang/unittests/Sema/CMakeLists.txt
+++ b/clang/unittests/Sema/CMakeLists.txt
@@ -1,3 +1,8 @@
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support
+  )
+
 add_clang_unittest(SemaTests
   ExternalSemaSourceTest.cpp
   CodeCompleteTest.cpp
@@ -5,7 +10,10 @@ add_clang_unittest(SemaTests
   GslOwnerPointerInference.cpp
   SemaLookupTest.cpp
   SemaNoloadLookupTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(SemaTests
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
@@ -14,11 +22,11 @@ add_clang_unittest(SemaTests
   clangSema
   clangSerialization
   clangTooling
-  LINK_LIBS
+  )
+
+target_link_libraries(SemaTests
+  PRIVATE
   LLVMTestingAnnotations
   LLVMTestingSupport
   clangTesting
-  LLVM_COMPONENTS
-  FrontendOpenMP
-  Support
   )
diff --git a/clang/unittests/Serialization/CMakeLists.txt b/clang/unittests/Serialization/CMakeLists.txt
index 6782e6b4d7330..e7005b5d511eb 100644
--- a/clang/unittests/Serialization/CMakeLists.txt
+++ b/clang/unittests/Serialization/CMakeLists.txt
@@ -1,3 +1,10 @@
+set(LLVM_LINK_COMPONENTS
+  BitReader
+  BitstreamReader
+  FrontendOpenMP
+  Support
+  )
+
 add_clang_unittest(SerializationTests
   ForceCheckFileInputTest.cpp
   InMemoryModuleCacheTest.cpp
@@ -7,7 +14,10 @@ add_clang_unittest(SerializationTests
   LoadSpecLazilyTest.cpp
   SourceLocationEncodingTest.cpp
   VarDeclConstantInitTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(SerializationTests
+  PRIVATE
   clangAST
   clangBasic
   clangFrontend
@@ -16,9 +26,4 @@ add_clang_unittest(SerializationTests
   clangSerialization
   clangTooling
   clangASTMatchers
-  LLVM_COMPONENTS
-  BitReader
-  BitstreamReader
-  FrontendOpenMP
-  Support
   )
diff --git a/clang/unittests/StaticAnalyzer/CMakeLists.txt b/clang/unittests/StaticAnalyzer/CMakeLists.txt
index 143b7eedbfe05..3b01a4e9e5327 100644
--- a/clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ b/clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -1,3 +1,8 @@
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support
+  )
+
 add_clang_unittest(StaticAnalysisTests
   AnalyzerOptionsTest.cpp
   APSIntTypeTest.cpp
@@ -20,7 +25,10 @@ add_clang_unittest(StaticAnalysisTests
   SValTest.cpp
   TestReturnValueUnderConstruction.cpp
   Z3CrosscheckOracleTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(StaticAnalysisTests
+  PRIVATE
   clangBasic
   clangAnalysis
   clangAST
@@ -31,9 +39,9 @@ add_clang_unittest(StaticAnalysisTests
   clangStaticAnalyzerCore
   clangStaticAnalyzerFrontend
   clangTooling
-  LINK_LIBS
+  )
+
+target_link_libraries(StaticAnalysisTests
+  PRIVATE
   clangTesting
-  LLVM_COMPONENTS
-  FrontendOpenMP
-  Support
   )
diff --git a/clang/unittests/Support/CMakeLists.txt b/clang/unittests/Support/CMakeLists.txt
index d0ce4f6d10617..22be5ed18cc7a 100644
--- a/clang/unittests/Support/CMakeLists.txt
+++ b/clang/unittests/Support/CMakeLists.txt
@@ -1,10 +1,15 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
 add_clang_unittest(ClangSupportTests
   TimeProfilerTest.cpp
-  CLANG_LIBS
+  )
+
+clang_target_link_libraries(ClangSupportTests
+  PRIVATE
   clangAST
   clangBasic
   clangFrontend
   clangSerialization
-  LLVM_COMPONENTS
-  Support
   )
diff --git a/clang/unittests/Tooling/CMakeLists.txt b/clang/unittests/Tooling/CMakeLists.txt
index 106c6b9dc38bd..401978c31863c 100644
--- a/clang/unittests/Tooling/CMakeLists.txt
+++ b/clang/unittests/Tooling/CMakeLists.txt
@@ -1,3 +1,13 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  MC
+  Option
+  FrontendOpenMP
+  Support
+  TargetParser
+  )
+
+
 add_clang_unittest(ToolingTests
   ASTSelectionTest.cpp
   CastExprTest.cpp
@@ -59,8 +69,10 @@ add_clang_unittest(ToolingTests
   StencilTest.cpp
   ToolingTest.cpp
   TransformerTest.cpp
+  )
 
-  CLANG_LIBS
+clang_target_link_libraries(ToolingTests
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic
@@ -77,19 +89,13 @@ add_clang_unittest(ToolingTests
   clangToolingInclusionsStdlib
   clangToolingRefactoring
   clangTrans...
[truncated]

@dpalermo dpalermo merged commit 03a791f into main Apr 2, 2025
12 of 17 checks passed
@dpalermo dpalermo deleted the revert-133545-cmake-clang-unittests branch April 2, 2025 03:19
@dpalermo dpalermo requested review from rnk and cyndyishida and removed request for cyndyishida April 2, 2025 03:20
@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 2, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve-vls-2stage running on linaro-g3-02 while building clang at step 12 "ninja check 2".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/4/builds/5986

Here is the relevant piece of the build log for the reference
Step 12 (ninja check 2) failure: stage 2 checked (failure)
...
PASS: Flang :: Driver/print-effective-triple.f90 (25186 of 97574)
PASS: Flang :: Driver/print-resource-dir.F90 (25187 of 97574)
PASS: Flang :: Driver/parse-error.ll (25188 of 97574)
PASS: Clangd Unit Tests :: ./ClangdTests/79/81 (25189 of 97574)
PASS: Flang :: Driver/predefined-macros-compiler-version.F90 (25190 of 97574)
PASS: Clangd Unit Tests :: ./ClangdTests/75/81 (25191 of 97574)
PASS: Flang :: Driver/bbc-openmp-version-macro.f90 (25192 of 97574)
PASS: Flang :: Driver/override-triple.ll (25193 of 97574)
PASS: Flang :: Driver/print-pipeline-passes.f90 (25194 of 97574)
UNRESOLVED: Flang :: Driver/slp-vectorize.ll (25195 of 97574)
******************** TEST 'Flang :: Driver/slp-vectorize.ll' FAILED ********************
Test has no 'RUN:' line
********************
PASS: Flang :: Driver/include-header.f90 (25196 of 97574)
PASS: Flang :: Driver/parse-fir-error.ll (25197 of 97574)
PASS: Flang :: Driver/fd-lines-as.f90 (25198 of 97574)
PASS: DataFlowSanitizer-aarch64 :: origin_ldst.c (25199 of 97574)
PASS: Flang :: Driver/macro-def-undef.F90 (25200 of 97574)
PASS: Flang :: Driver/phases.f90 (25201 of 97574)
PASS: Flang :: Driver/pthread.f90 (25202 of 97574)
PASS: Flang :: Driver/parse-ir-error.f95 (25203 of 97574)
PASS: Flang :: Driver/mlink-builtin-bc.f90 (25204 of 97574)
PASS: Flang :: Driver/std2018-wrong.f90 (25205 of 97574)
PASS: Flang :: Driver/scanning-error.f95 (25206 of 97574)
PASS: Flang :: Driver/print-target-triple.f90 (25207 of 97574)
PASS: Flang :: Driver/supported-suffices/f08-suffix.f08 (25208 of 97574)
PASS: Flang :: Driver/supported-suffices/f03-suffix.f03 (25209 of 97574)
PASS: Flang :: Driver/pp-fixed-form.f90 (25210 of 97574)
PASS: Flang :: Driver/linker-flags.f90 (25211 of 97574)
PASS: Flang :: Driver/target-gpu-features.f90 (25212 of 97574)
PASS: Flang :: Driver/tco-code-gen-llvm.fir (25213 of 97574)
PASS: Flang :: Driver/lto-bc.f90 (25214 of 97574)
PASS: Flang :: Driver/pass-plugin-not-found.f90 (25215 of 97574)
PASS: Flang :: Driver/q-unused-arguments.f90 (25216 of 97574)
PASS: Flang :: Driver/target.f90 (25217 of 97574)
PASS: Flang :: Driver/fdefault.f90 (25218 of 97574)
PASS: Flang :: Driver/fixed-line-length.f90 (25219 of 97574)
PASS: Flang :: Driver/mlir-pass-pipeline.f90 (25220 of 97574)
PASS: Flang :: Driver/unsupported-vscale-max-min.f90 (25221 of 97574)
PASS: Flang :: Driver/unparse-with-modules.f90 (25222 of 97574)
PASS: Flang :: Driver/target-machine-error.f90 (25223 of 97574)
PASS: Flang :: Driver/unparse-use-analyzed.f95 (25224 of 97574)
PASS: Flang :: Driver/multiple-input-files.f90 (25225 of 97574)
PASS: Flang :: Driver/no-duplicate-main.f90 (25226 of 97574)
PASS: Flang :: Driver/std2018.f90 (25227 of 97574)
PASS: Flang :: Driver/missing-arg.f90 (25228 of 97574)
PASS: Flang :: Driver/save-temps-use-module.f90 (25229 of 97574)
PASS: Flang :: Driver/input-from-stdin/input-from-stdin.f90 (25230 of 97574)
PASS: Flang :: Driver/save-temps.f90 (25231 of 97574)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 2, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-android running on sanitizer-buildbot-android while building clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/7851

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
[       OK ] AddressSanitizer.AtoiAndFriendsOOBTest (2259 ms)
[ RUN      ] AddressSanitizer.HasFeatureAddressSanitizerTest
[       OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms)
[ RUN      ] AddressSanitizer.CallocReturnsZeroMem
[       OK ] AddressSanitizer.CallocReturnsZeroMem (9 ms)
[ DISABLED ] AddressSanitizer.DISABLED_TSDTest
[ RUN      ] AddressSanitizer.IgnoreTest
[       OK ] AddressSanitizer.IgnoreTest (0 ms)
[ RUN      ] AddressSanitizer.SignalTest
[       OK ] AddressSanitizer.SignalTest (177 ms)
[ RUN      ] AddressSanitizer.ReallocTest
[       OK ] AddressSanitizer.ReallocTest (45 ms)
[ RUN      ] AddressSanitizer.WrongFreeTest
[       OK ] AddressSanitizer.WrongFreeTest (144 ms)
[ RUN      ] AddressSanitizer.LongJmpTest
[       OK ] AddressSanitizer.LongJmpTest (0 ms)
[ RUN      ] AddressSanitizer.ThreadStackReuseTest
[       OK ] AddressSanitizer.ThreadStackReuseTest (11 ms)
[ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest
[ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest
[ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest
[ RUN      ] AddressSanitizer.UseThenFreeThenUseTest
[       OK ] AddressSanitizer.UseThenFreeThenUseTest (113 ms)
[ RUN      ] AddressSanitizer.FileNameInGlobalReportTest
[       OK ] AddressSanitizer.FileNameInGlobalReportTest (131 ms)
[ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest
[ RUN      ] AddressSanitizer.MlockTest
[       OK ] AddressSanitizer.MlockTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFHigh
[ DISABLED ] AddressSanitizer.DISABLED_DemoOOM
[ DISABLED ] AddressSanitizer.DISABLED_DemoDoubleFreeTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoNullDerefTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoFunctionStaticTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoTooMuchMemoryTest
[ RUN      ] AddressSanitizer.LongDoubleNegativeTest
[       OK ] AddressSanitizer.LongDoubleNegativeTest (0 ms)
[----------] 19 tests from AddressSanitizer (28039 ms total)

[----------] Global test environment tear-down
[==========] 22 tests from 2 test suites ran. (28055 ms total)
[  PASSED  ] 22 tests.

  YOU HAVE 1 DISABLED TEST

Step 34 (run instrumented asan tests [aarch64/bluejay-userdebug/TQ3A.230805.001]) failure: run instrumented asan tests [aarch64/bluejay-userdebug/TQ3A.230805.001] (failure)
...
[ RUN      ] AddressSanitizer.HasFeatureAddressSanitizerTest
[       OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms)
[ RUN      ] AddressSanitizer.CallocReturnsZeroMem
[       OK ] AddressSanitizer.CallocReturnsZeroMem (9 ms)
[ DISABLED ] AddressSanitizer.DISABLED_TSDTest
[ RUN      ] AddressSanitizer.IgnoreTest
[       OK ] AddressSanitizer.IgnoreTest (0 ms)
[ RUN      ] AddressSanitizer.SignalTest
[       OK ] AddressSanitizer.SignalTest (177 ms)
[ RUN      ] AddressSanitizer.ReallocTest
[       OK ] AddressSanitizer.ReallocTest (45 ms)
[ RUN      ] AddressSanitizer.WrongFreeTest
[       OK ] AddressSanitizer.WrongFreeTest (144 ms)
[ RUN      ] AddressSanitizer.LongJmpTest
[       OK ] AddressSanitizer.LongJmpTest (0 ms)
[ RUN      ] AddressSanitizer.ThreadStackReuseTest
[       OK ] AddressSanitizer.ThreadStackReuseTest (11 ms)
[ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest
[ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest
[ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest
[ RUN      ] AddressSanitizer.UseThenFreeThenUseTest
[       OK ] AddressSanitizer.UseThenFreeThenUseTest (113 ms)
[ RUN      ] AddressSanitizer.FileNameInGlobalReportTest
[       OK ] AddressSanitizer.FileNameInGlobalReportTest (131 ms)
[ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest
[ RUN      ] AddressSanitizer.MlockTest
[       OK ] AddressSanitizer.MlockTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFHigh
[ DISABLED ] AddressSanitizer.DISABLED_DemoOOM
[ DISABLED ] AddressSanitizer.DISABLED_DemoDoubleFreeTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoNullDerefTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoFunctionStaticTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoTooMuchMemoryTest
[ RUN      ] AddressSanitizer.LongDoubleNegativeTest
[       OK ] AddressSanitizer.LongDoubleNegativeTest (0 ms)
[----------] 19 tests from AddressSanitizer (28039 ms total)

[----------] Global test environment tear-down
[==========] 22 tests from 2 test suites ran. (28055 ms total)
[  PASSED  ] 22 tests.

  YOU HAVE 1 DISABLED TEST
program finished with exit code 0
elapsedTime=2302.575955

@rnk
Copy link
Collaborator

rnk commented Apr 2, 2025

Thanks, I got the notifications late yesterday in the workday, and had to rush off. Sorry for the noise.

rnk added a commit to rnk/llvm-project that referenced this pull request Apr 2, 2025
This reverts commit 03a791f /
llvm#134022

The BUILD_SHARED_LIBS=ON build was fixed by adding missing LLVM
dependencies to the InterpTests binary in
unittests/AST/ByteCode/CMakeLists.txt .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category clang-format
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants