Skip to content

Commit c9dfaf5

Browse files
committed
dev-lang/swift: set LLDB to respect PYTHON_SINGLE_TARGET
Closes: https://bugs.gentoo.org/939685 Signed-off-by: Itai Ferber <[email protected]>
1 parent bf4e720 commit c9dfaf5

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# The LLDB Python bindings rely on CMake to find Python, and by default, CMake
2+
# tries to use the newest Python version found on disk. To get CMake to respect
3+
# the version of Python set up by `python_setup`, we to set
4+
# `-DPython3_FIND_UNVERSIONED_NAMES=FIRST`, which is only available from CMake
5+
# 3.20. (Even if the `cmake` executable is a newer version, it still relies on
6+
# `cmake_minimum_required` for feature testing.)
7+
8+
--- a/llvm-project/lldb/CMakeLists.txt
9+
+++ b/llvm-project/lldb/CMakeLists.txt
10+
@@ -1,4 +1,4 @@
11+
-cmake_minimum_required(VERSION 3.13.4)
12+
+cmake_minimum_required(VERSION 3.20)
13+
14+
# Add path for custom modules.
15+
set(CMAKE_MODULE_PATH

dev-lang/swift/swift-5.10.1.ebuild

+15-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ SRC_URI="
5151
PATCHES=(
5252
"${FILESDIR}/${P}-link-with-lld.patch"
5353
"${FILESDIR}/${P}-llbuild-link-ncurses-tinfo-gentoo.patch"
54+
"${FILESDIR}/${P}-lldb-cmake-minimum-version.patch"
5455
)
5556

5657
S="${WORKDIR}"
@@ -119,7 +120,8 @@ src_unpack() {
119120
src_configure() {
120121
default
121122

122-
# Necessary to respect PYTHON_SINGLE_TARGET, if defined.
123+
# Sets `${EPYTHON}` according to `PYTHON_SINGLE_TARGET`, sets up
124+
# `${T}/${EPYTHON}` with that version, and adds it to the `PATH`.
123125
python_setup
124126
}
125127

@@ -159,7 +161,18 @@ src_compile() {
159161
# The Clang `compiler-rt` library builds the LLVM ORC JIT component by
160162
# default, which we don't need; the component builds with an executable
161163
# stack, which we'd like to avoid.
162-
'-DCOMPILER_RT_BUILD_ORC:BOOL=NO'
164+
'-DCOMPILER_RT_BUILD_ORC:BOOL=NO',
165+
166+
# LLDB ships with Python bindings, and uses CMake to search for Python.
167+
# By default, CMake tries to find the latest version of Python available
168+
# on disk (currently `python3.13`, then `python3.12`, then...). This
169+
# might not be the version of Python the rest of the system uses, or
170+
# which is specified by `PYTHON_SINGLE_TARGET`.
171+
#
172+
# Since `python_setup` already places `${EPYTHON}` in the `PATH`, we can
173+
# tell CMake to use the unversioned `python` rather than a versioned
174+
# one to end up respecting `PYTHON_SINGLE_TARGET`.
175+
'-DPython3_FIND_UNVERSIONED_NAMES=FIRST'
163176
)
164177
local extra_cmake_options="$(IFS=,; echo "${_extra_cmake_options[*]}")"
165178

0 commit comments

Comments
 (0)