[clang] [lldb] Add Static Build option for LLDB Libraries (PR #98827)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 14 11:21:47 PDT 2024
https://github.com/vortex73 created https://github.com/llvm/llvm-project/pull/98827
- [ ] Added Option to statically build lldb
- [ ] Packages lldb for easier package finding in other builds.
>From 8ecf1b30678503f96d41112feb3ac87944c13158 Mon Sep 17 00:00:00 2001
From: Vortex <nsreekumar6 at gmail.com>
Date: Sun, 14 Jul 2024 00:22:43 +0530
Subject: [PATCH 1/2] [clang] [Diagnostic] Clarify -Winfinite-recursion message
---
.../clang/Basic/DiagnosticSemaKinds.td | 2 +-
.../test/SemaCXX/warn-infinite-recursion.cpp | 32 +++++++++----------
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0ea3677355169..53c38bb543409 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -60,7 +60,7 @@ def note_remove_max_call : Note<
"remove call to max function and unsigned zero argument">;
def warn_infinite_recursive_function : Warning<
- "all paths through this function will call itself">,
+ "in order to understand recursion, you must first understand recursion">,
InGroup<InfiniteRecursion>, DefaultIgnore;
def warn_comma_operator : Warning<"possible misuse of comma operator here">,
diff --git a/clang/test/SemaCXX/warn-infinite-recursion.cpp b/clang/test/SemaCXX/warn-infinite-recursion.cpp
index d0f3fe7b164e1..b57b417d13cd2 100644
--- a/clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ b/clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -1,10 +1,10 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -Winfinite-recursion
-void a() { // expected-warning{{call itself}}
+void a() { // expected-warning{{to understand recursion}}
a();
}
-void b(int x) { // expected-warning{{call itself}}
+void b(int x) { // expected-warning{{to understand recursion}}
if (x)
b(x);
else
@@ -16,7 +16,7 @@ void c(int x) {
c(5);
}
-void d(int x) { // expected-warning{{call itself}}
+void d(int x) { // expected-warning{{to understand recursion}}
if (x)
++x;
return d(x);
@@ -29,7 +29,7 @@ void f();
void e() { f(); }
void f() { e(); }
-void g() { // expected-warning{{call itself}}
+void g() { // expected-warning{{to understand recursion}}
while (true)
g();
@@ -42,14 +42,14 @@ void h(int x) {
}
}
-void i(int x) { // expected-warning{{call itself}}
+void i(int x) { // expected-warning{{to understand recursion}}
while (x < 5) {
--x;
}
i(0);
}
-int j() { // expected-warning{{call itself}}
+int j() { // expected-warning{{to understand recursion}}
return 5 + j();
}
@@ -80,11 +80,11 @@ class S {
void b();
};
-void S::a() { // expected-warning{{call itself}}
+void S::a() { // expected-warning{{to understand recursion}}
return a();
}
-void S::b() { // expected-warning{{call itself}}
+void S::b() { // expected-warning{{to understand recursion}}
int i = 0;
do {
++i;
@@ -95,8 +95,8 @@ void S::b() { // expected-warning{{call itself}}
template<class member>
struct T {
member m;
- void a() { return a(); } // expected-warning{{call itself}}
- static void b() { return b(); } // expected-warning{{call itself}}
+ void a() { return a(); } // expected-warning{{to understand recursion}}
+ static void b() { return b(); } // expected-warning{{to understand recursion}}
};
void test_T() {
@@ -107,13 +107,13 @@ void test_T() {
class U {
U* u;
- void Fun() { // expected-warning{{call itself}}
+ void Fun() { // expected-warning{{to understand recursion}}
u->Fun();
}
};
// No warnings on templated functions
-// sum<0>() is instantiated, does recursively call itself, but never runs.
+// sum<0>() is instantiated, does recursively to understand recursion, but never runs.
template <int value>
int sum() {
return value + sum<value/2>();
@@ -157,7 +157,7 @@ struct Wrapper {
return 0;
return Wrapper<x/2>::run();
}
- static int run2() { // expected-warning{{call itself}}
+ static int run2() { // expected-warning{{to understand recursion}}
return run2();
}
};
@@ -194,7 +194,7 @@ struct Q {
};
Q q;
-Q &evaluated_recursive_function(int x) { // expected-warning{{call itself}}
+Q &evaluated_recursive_function(int x) { // expected-warning{{to understand recursion}}
(void)typeid(evaluated_recursive_function(x)); // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}}
return q;
}
@@ -204,11 +204,11 @@ int unevaluated_recursive_function() {
return 0;
}
-void func1(int i) { // expected-warning {{call itself}}
+void func1(int i) { // expected-warning {{to understand recursion}}
if (i || !i)
func1(i);
}
-void func2(int i) { // expected-warning {{call itself}}
+void func2(int i) { // expected-warning {{to understand recursion}}
if (!i && i) {}
else
func2(i);
>From f5b5165d6d73b27329043b3c863cb163a2440dbb Mon Sep 17 00:00:00 2001
From: Vortex <nsreekumar6 at gmail.com>
Date: Sun, 14 Jul 2024 23:41:36 +0530
Subject: [PATCH 2/2] [LLDB] [CMake] added static libraries and LLDB packaging
---
lldb/source/API/CMakeLists.txt | 196 ++++++++++++++++------------
lldb/source/API/LLDBConfig.cmake.in | 7 +
2 files changed, 117 insertions(+), 86 deletions(-)
create mode 100644 lldb/source/API/LLDBConfig.cmake.in
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 6397101609315..4f4c565850edd 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -40,92 +40,100 @@ add_custom_target(lldb-sbapi-dwarf-enums
DEPENDS ${sb_languages_file})
set_target_properties(lldb-sbapi-dwarf-enums PROPERTIES FOLDER "LLDB/Tablegenning")
-add_lldb_library(liblldb SHARED ${option_framework}
- SBAddress.cpp
- SBAddressRange.cpp
- SBAddressRangeList.cpp
- SBAttachInfo.cpp
- SBBlock.cpp
- SBBreakpoint.cpp
- SBBreakpointLocation.cpp
- SBBreakpointName.cpp
- SBBreakpointOptionCommon.cpp
- SBBroadcaster.cpp
- SBCommandInterpreter.cpp
- SBCommandInterpreterRunOptions.cpp
- SBCommandReturnObject.cpp
- SBCommunication.cpp
- SBCompileUnit.cpp
- SBData.cpp
- SBDebugger.cpp
- SBDeclaration.cpp
- SBEnvironment.cpp
- SBError.cpp
- SBEvent.cpp
- SBExecutionContext.cpp
- SBExpressionOptions.cpp
- SBFileSpec.cpp
- SBFile.cpp
- SBFileSpecList.cpp
- SBFormat.cpp
- SBFrame.cpp
- SBFunction.cpp
- SBHostOS.cpp
- SBInstruction.cpp
- SBInstructionList.cpp
- SBLanguageRuntime.cpp
- SBLaunchInfo.cpp
- SBLineEntry.cpp
- SBListener.cpp
- SBMemoryRegionInfo.cpp
- SBMemoryRegionInfoList.cpp
- SBModule.cpp
- SBModuleSpec.cpp
- SBPlatform.cpp
- SBProcess.cpp
- SBProcessInfo.cpp
- SBProcessInfoList.cpp
- SBQueue.cpp
- SBQueueItem.cpp
- SBReproducer.cpp
- SBScriptObject.cpp
- SBSection.cpp
- SBSourceManager.cpp
- SBStatisticsOptions.cpp
- SBStream.cpp
- SBStringList.cpp
- SBStructuredData.cpp
- SBSymbol.cpp
- SBSymbolContext.cpp
- SBSymbolContextList.cpp
- SBTarget.cpp
- SBThread.cpp
- SBThreadCollection.cpp
- SBThreadPlan.cpp
- SBTrace.cpp
- SBTraceCursor.cpp
- SBType.cpp
- SBTypeCategory.cpp
- SBTypeEnumMember.cpp
- SBTypeFilter.cpp
- SBTypeFormat.cpp
- SBTypeNameSpecifier.cpp
- SBTypeSummary.cpp
- SBTypeSynthetic.cpp
- SBValue.cpp
- SBValueList.cpp
- SBVariablesOptions.cpp
- SBWatchpoint.cpp
- SBWatchpointOptions.cpp
- SBUnixSignals.cpp
- SystemInitializerFull.cpp
- ${lldb_python_wrapper}
- ${lldb_lua_wrapper}
-
- DEPENDS
+option(LLDB_BUILD_STATIC "Build LLDB as a Static Library" OFF)
+
+if(LLDB_BUILD_STATIC)
+ set(LLDB_LIBRARY_TYPE STATIC)
+elsE()
+ set(LLDB_LIBRARY_TYPE SHARED)
+endif()
+
+add_lldb_library(liblldb ${LLDB_LIBRARY_TYPE} ${option_framework}
+ SBAddress.cpp
+ SBAddressRange.cpp
+ SBAddressRangeList.cpp
+ SBAttachInfo.cpp
+ SBBlock.cpp
+ SBBreakpoint.cpp
+ SBBreakpointLocation.cpp
+ SBBreakpointName.cpp
+ SBBreakpointOptionCommon.cpp
+ SBBroadcaster.cpp
+ SBCommandInterpreter.cpp
+ SBCommandInterpreterRunOptions.cpp
+ SBCommandReturnObject.cpp
+ SBCommunication.cpp
+ SBCompileUnit.cpp
+ SBData.cpp
+ SBDebugger.cpp
+ SBDeclaration.cpp
+ SBEnvironment.cpp
+ SBError.cpp
+ SBEvent.cpp
+ SBExecutionContext.cpp
+ SBExpressionOptions.cpp
+ SBFileSpec.cpp
+ SBFile.cpp
+ SBFileSpecList.cpp
+ SBFormat.cpp
+ SBFrame.cpp
+ SBFunction.cpp
+ SBHostOS.cpp
+ SBInstruction.cpp
+ SBInstructionList.cpp
+ SBLanguageRuntime.cpp
+ SBLaunchInfo.cpp
+ SBLineEntry.cpp
+ SBListener.cpp
+ SBMemoryRegionInfo.cpp
+ SBMemoryRegionInfoList.cpp
+ SBModule.cpp
+ SBModuleSpec.cpp
+ SBPlatform.cpp
+ SBProcess.cpp
+ SBProcessInfo.cpp
+ SBProcessInfoList.cpp
+ SBQueue.cpp
+ SBQueueItem.cpp
+ SBReproducer.cpp
+ SBScriptObject.cpp
+ SBSection.cpp
+ SBSourceManager.cpp
+ SBStatisticsOptions.cpp
+ SBStream.cpp
+ SBStringList.cpp
+ SBStructuredData.cpp
+ SBSymbol.cpp
+ SBSymbolContext.cpp
+ SBSymbolContextList.cpp
+ SBTarget.cpp
+ SBThread.cpp
+ SBThreadCollection.cpp
+ SBThreadPlan.cpp
+ SBTrace.cpp
+ SBTraceCursor.cpp
+ SBType.cpp
+ SBTypeCategory.cpp
+ SBTypeEnumMember.cpp
+ SBTypeFilter.cpp
+ SBTypeFormat.cpp
+ SBTypeNameSpecifier.cpp
+ SBTypeSummary.cpp
+ SBTypeSynthetic.cpp
+ SBValue.cpp
+ SBValueList.cpp
+ SBVariablesOptions.cpp
+ SBWatchpoint.cpp
+ SBWatchpointOptions.cpp
+ SBUnixSignals.cpp
+ SystemInitializerFull.cpp
+ ${lldb_python_wrapper}
+ ${lldb_lua_wrapper}
+
+ DEPENDS
lldb-sbapi-dwarf-enums
- LINK_LIBS
+ LINK_LIBS
lldbBreakpoint
lldbCore
lldbDataFormatters
@@ -138,10 +146,26 @@ add_lldb_library(liblldb SHARED ${option_framework}
lldbUtility
lldbVersion
${LLDB_ALL_PLUGINS}
- LINK_COMPONENTS
+ LINK_COMPONENTS
Support
- ${option_install_prefix}
+ ${option_install_prefix}
+)
+
+install(TARGETS liblldb EXPORT LLDBTargets
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ RUNTIME DESTINATION bin
+ INCLUDES DESTINATION include
+)
+
+include(CMakePackageConfigHelpers)
+
+set(LLDB_PACKAGE_PATH "/lib/cmake/clang")
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/LLDBConfig.cmake.in"
+ "${CMAKE_BINARY_DIR}${LLDB_PACKAGE_PATH}"
+ INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/lldb"
)
# lib/pythonX.Y/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so,
diff --git a/lldb/source/API/LLDBConfig.cmake.in b/lldb/source/API/LLDBConfig.cmake.in
new file mode 100644
index 0000000000000..beb8625d8d7a9
--- /dev/null
+++ b/lldb/source/API/LLDBConfig.cmake.in
@@ -0,0 +1,7 @@
+ at PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Clang)
+
+include("${CMAKE_CURRENT_LIST_DIR}/LLDBTargets.cmake")
More information about the cfe-commits
mailing list