Compare commits

...

4 Commits

Author SHA1 Message Date
David Abdurachmanov e74d3ded7a
Merge remote-tracking branch 'up/main' into main-riscv64
Signed-off-by: David Abdurachmanov <davidlt@rivosinc.com>
2023-12-07 19:55:00 +02:00
Tulio Magno Quites Machado Filho abea627cd8 Add patches in order to work with Python 3.12 and 3.13 2023-11-30 13:56:04 -03:00
Tulio Magno Quites Machado Filho 6476637d55 Remove unused patches
These patches have been removed from the spec file, but remained in the
repo.
2023-11-30 13:56:04 -03:00
Tulio Magno Quites Machado Filho a4a9a8b957 Update to LLVM 17.0.6 2023-11-29 10:08:51 -03:00
6 changed files with 177 additions and 124 deletions

View File

@ -0,0 +1,74 @@
From ed87035da34be675df7ea78bdf5f7631d81ab2db Mon Sep 17 00:00:00 2001
From: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
Date: Wed, 25 Oct 2023 10:48:53 -0300
Subject: [PATCH] [lldb] Adapt code to Python 3.13
1. Remove usage of PyEval_ThreadsInitialized and PyEval_InitThreads
Both of these functions were removed in Python 3.13 [1] after being
deprecated since Python 3.9.
According to "What's new in Python 3.13" document [1]:
Since Python 3.7, Py_Initialize() always creates the GIL: calling
PyEval_InitThreads() did nothing and PyEval_ThreadsInitialized()
always returned non-zero.
2. Replace _Py_IsFinalizing() with Py_IsFinalizing().
[1] https://docs.python.org/3.13/whatsnew/3.13.html
---
.../ScriptInterpreter/Python/PythonDataObjects.cpp | 4 +++-
.../ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 9 +++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 9ac840a4a102..fe3438c42471 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -71,7 +71,9 @@ Expected<std::string> python::As<std::string>(Expected<PythonObject> &&obj) {
}
static bool python_is_finalizing() {
-#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 13) || (PY_MAJOR_VERSION > 3)
+ return Py_IsFinalizing();
+#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7
return _Py_Finalizing != nullptr;
#else
return _Py_IsFinalizing();
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index a57c8e4984ad..968cc8ca0300 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -179,18 +179,27 @@ private:
return;
#endif
+// `PyEval_ThreadsInitialized` was deprecated in Python 3.9 and removed in
+// Python 3.13. It has been returning `true` always since Python 3.7.
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3)
if (PyEval_ThreadsInitialized()) {
+#endif
Log *log = GetLog(LLDBLog::Script);
m_was_already_initialized = true;
m_gil_state = PyGILState_Ensure();
LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked\n",
m_gil_state == PyGILState_UNLOCKED ? "un" : "");
+
+// `PyEval_InitThreads` was deprecated in Python 3.9 and removed in
+// Python 3.13.
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3)
return;
}
// InitThreads acquires the GIL if it hasn't been called before.
PyEval_InitThreads();
+#endif
}
PyGILState_STATE m_gil_state = PyGILState_UNLOCKED;
--
2.41.0

View File

@ -1,40 +0,0 @@
From 6888de118707e6392b46073fc35738804f9f1d80 Mon Sep 17 00:00:00 2001
From: Alex Langford <alangford@apple.com>
Date: Mon, 31 Jul 2023 16:30:17 -0700
Subject: [PATCH] [lldb] Fix building LLDB standlone without framework
In a809720102fae8d1b5a7073f99f9dae9395c5f41 I refactored some logic to
deal with the clang resource directory in standalone LLDB builds.
However, this logic escaped me because it only runs when you do not
build LLDB.framework.
Differential Revision: https://reviews.llvm.org/D156763
---
lldb/source/API/CMakeLists.txt | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index a55754726c58..39ac451c471c 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -204,13 +204,11 @@ else()
# When building the LLDB framework, this isn't necessary as there we copy everything we need into
# the framework (including the Clang resourece directory).
if(NOT LLDB_BUILD_FRAMEWORK)
- set(LLDB_CLANG_RESOURCE_DIR_PARENT "$<TARGET_FILE_DIR:liblldb>/clang")
- file(MAKE_DIRECTORY "${LLDB_CLANG_RESOURCE_DIR_PARENT}")
+ set(LLDB_CLANG_RESOURCE_DIR "$<TARGET_FILE_DIR:liblldb>/clang")
add_custom_command(TARGET liblldb POST_BUILD
- COMMENT "Linking Clang resource dir into LLDB build directory: ${LLDB_CLANG_RESOURCE_DIR_PARENT}"
- COMMAND ${CMAKE_COMMAND} -E make_directory "${LLDB_CLANG_RESOURCE_DIR_PARENT}"
- COMMAND ${CMAKE_COMMAND} -E create_symlink "${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}"
- "${LLDB_CLANG_RESOURCE_DIR_PARENT}/${LLDB_CLANG_RESOURCE_DIR_NAME}"
+ COMMENT "Linking Clang resource dir into LLDB build directory: ${LLDB_CLANG_RESOURCE_DIR}"
+ COMMAND ${CMAKE_COMMAND} -E create_symlink
+ "${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}" "${LLDB_CLANG_RESOURCE_DIR}"
)
endif()
endif()
--
2.41.0

View File

@ -1,80 +0,0 @@
From a809720102fae8d1b5a7073f99f9dae9395c5f41 Mon Sep 17 00:00:00 2001
From: Alex Langford <alangford@apple.com>
Date: Tue, 25 Jul 2023 15:38:04 -0700
Subject: [PATCH] [lldb][NFCI] Change logic to find clang resource dir in
standalone builds
As of 0beffb854209a41f31beb18f9631258349a99299 there is a CMake
function to actually calculate the relative path to the clang resource
directory. Currently we have some bespoke logic that looks in a few
places, but with this new function we should be able to eliminate some
complexity here.
Also, I moved the functionality from LLDBConfig to LLDBStandalone since
it is only used in standalone builds.
Differential Revision: https://reviews.llvm.org/D156270
---
lldb/cmake/modules/LLDBConfig.cmake | 24 ------------------------
lldb/cmake/modules/LLDBStandalone.cmake | 13 +++++++++++++
2 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 1393342dd5cb..ce90ecabc6a5 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -282,30 +282,6 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
endif()
endif()
-
-# If LLDB is building against a prebuilt Clang, then the Clang resource
-# directory that LLDB is using for its embedded Clang instance needs to point
-# to the resource directory of the used Clang installation.
-if (NOT TARGET clang-resource-headers)
- set(LLDB_CLANG_RESOURCE_DIR_NAME "${LLVM_VERSION_MAJOR}")
- # Iterate over the possible places where the external resource directory
- # could be and pick the first that exists.
- foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}"
- "${LLVM_BUILD_LIBRARY_DIR}"
- "${LLVM_LIBRARY_DIR}")
- # Build the resource directory path by appending 'clang/<version number>'.
- set(CANDIDATE_RESOURCE_DIR "${CANDIDATE}/clang/${LLDB_CLANG_RESOURCE_DIR_NAME}")
- if (IS_DIRECTORY "${CANDIDATE_RESOURCE_DIR}")
- set(LLDB_EXTERNAL_CLANG_RESOURCE_DIR "${CANDIDATE_RESOURCE_DIR}")
- break()
- endif()
- endforeach()
-
- if (NOT LLDB_EXTERNAL_CLANG_RESOURCE_DIR)
- message(FATAL_ERROR "Expected directory for clang-resource headers not found: ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}")
- endif()
-endif()
-
# Find Apple-specific libraries or frameworks that may be needed.
if (APPLE)
if(NOT APPLE_EMBEDDED)
diff --git a/lldb/cmake/modules/LLDBStandalone.cmake b/lldb/cmake/modules/LLDBStandalone.cmake
index e9bcabcb63de..fd16716d7141 100644
--- a/lldb/cmake/modules/LLDBStandalone.cmake
+++ b/lldb/cmake/modules/LLDBStandalone.cmake
@@ -128,3 +128,16 @@ endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
+
+# If LLDB is building against a prebuilt Clang, then the Clang resource
+# directory that LLDB is using for its embedded Clang instance needs to point to
+# the resource directory of the used Clang installation.
+if (NOT TARGET clang-resource-headers)
+ include(GetClangResourceDir)
+ get_clang_resource_dir(LLDB_EXTERNAL_CLANG_RESOURCE_DIR
+ PREFIX "${Clang_DIR}/../../../")
+
+ if (NOT EXISTS ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR})
+ message(FATAL_ERROR "Expected directory for clang-resource-headers not found: ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}")
+ endif()
+endif()
--
2.41.0

View File

@ -0,0 +1,91 @@
From 16fd09f102eff20825847e32f225715960d1c082 Mon Sep 17 00:00:00 2001
From: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
Date: Wed, 25 Oct 2023 10:48:53 -0300
Subject: [PATCH] [lldb] Replace the usage of module imp with module importlib
imp got removed in Python 3.12 [1] and the community recommends using
importlib in newer Python versions.
[1] https://docs.python.org/3.12/whatsnew/3.12.html#imp
---
lldb/scripts/use_lldb_suite.py | 30 ++++++++++++++++++++++--------
lldb/test/API/use_lldb_suite.py | 29 +++++++++++++++++++++--------
2 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/lldb/scripts/use_lldb_suite.py b/lldb/scripts/use_lldb_suite.py
index 6388d87b181c..4cedfa532cf9 100644
--- a/lldb/scripts/use_lldb_suite.py
+++ b/lldb/scripts/use_lldb_suite.py
@@ -17,10 +17,25 @@ def find_lldb_root():
return lldb_root
lldb_root = find_lldb_root()
-import imp
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
- imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
- if fp:
- fp.close()
+
+# Module imp got removed in Python 3.12.
+if (
+ sys.version_info.major == 3 and sys.version_info.minor >= 12
+) or sys.version_info.major > 3:
+ import importlib.machinery
+ import importlib.util
+
+ path = os.path.join(lldb_root, "use_lldb_suite_root.py")
+ loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path)
+ spec = importlib.util.spec_from_loader("use_lldb_suite_root", loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ loader.exec_module(module)
+else:
+ import imp
+
+ fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+ try:
+ imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+ finally:
+ if fp:
+ fp.close()
diff --git a/lldb/test/API/use_lldb_suite.py b/lldb/test/API/use_lldb_suite.py
index e237dd4b8a56..c9332d9921b4 100644
--- a/lldb/test/API/use_lldb_suite.py
+++ b/lldb/test/API/use_lldb_suite.py
@@ -20,11 +20,24 @@ def find_lldb_root():
lldb_root = find_lldb_root()
-import imp
-
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
- imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
- if fp:
- fp.close()
+# Module imp got removed in Python 3.12.
+if (
+ sys.version_info.major == 3 and sys.version_info.minor >= 12
+) or sys.version_info.major > 3:
+ import importlib.machinery
+ import importlib.util
+
+ path = os.path.join(lldb_root, "use_lldb_suite_root.py")
+ loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path)
+ spec = importlib.util.spec_from_loader("use_lldb_suite_root", loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ loader.exec_module(module)
+else:
+ import imp
+
+ fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+ try:
+ imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+ finally:
+ if fp:
+ fp.close()
--
2.41.0

View File

@ -4,7 +4,7 @@
# https://bugzilla.redhat.com/show_bug.cgi?id=2158587
%undefine _include_frame_pointers
%global lldb_version 17.0.4
%global lldb_version 17.0.6
#global rc_ver 4
%global lldb_srcdir %{name}-%{lldb_version}%{?rc_ver:rc%{rc_ver}}.src
@ -19,6 +19,11 @@ Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{lldb_v
Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{lldb_version}%{?rc_ver:-rc%{rc_ver}}/%{lldb_srcdir}.tar.xz.sig
Source2: release-keys.asc
# Backport from https://github.com/llvm/llvm-project/pull/70443
Patch: 0001-lldb-Replace-the-usage-of-module-imp-with-module-imp.patch
# Backport from https://github.com/llvm/llvm-project/pull/70445
Patch: 0001-lldb-Adapt-code-to-Python-3.13.patch
BuildRequires: clang
BuildRequires: cmake
BuildRequires: ninja-build
@ -138,9 +143,12 @@ rm -f %{buildroot}%{python3_sitearch}/six.*
%{python3_sitearch}/lldb
%changelog
* Tue Nov 07 2023 David Abdurachmanov <davidlt@rivosinc.com> - 17.0.4-1.0.riscv64
* Thu Dec 07 2023 David Abdurachmanov <davidlt@rivosinc.com> - 17.0.6-1.0.riscv64
- Disable LTO on riscv64
* Wed Nov 29 2023 Tulio Magno Quites Machado Filho <tuliom@redhat.com> - 17.0.6-1
- Update to LLVM 17.0.6
* Wed Nov 01 2023 Tulio Magno Quites Machado Filho <tuliom@redhat.com> - 17.0.4-1
- Update to LLVM 17.0.4

View File

@ -1,2 +1,2 @@
SHA512 (lldb-17.0.4.src.tar.xz) = fffdfe1884a9fa040d6a4b33324cf598b3604cdc311037d0c1c5163ff932e8991ea5763c351d2867a37092bd895877372ebec650be3f8d600a2e515d77ff0f32
SHA512 (lldb-17.0.4.src.tar.xz.sig) = 481918fddd7f7e17a7a272264be5031c65b3c569f3ef1e0acda2cef822e74bb1f5c340a48b7142127bfd32fd7935abf90418b911ce4e5540e39e0d2799f35eec
SHA512 (lldb-17.0.6.src.tar.xz) = 80b327c89b160b1dcdbea1946a7c69514e797056629c0a7501c77e7557d6bb3a7ae6ecdd0d760d072b1f7c3f5b136838f76c8d75522cd84622a03b1b25ba6e6c
SHA512 (lldb-17.0.6.src.tar.xz.sig) = d6f8edabc7d4d3ec1f7620c6166606abef4632e10f36244a8e5b76d66a94f1218742c86cd6445c7983353fc001d307709659709e9708a82c7a7042495492d9da