dev-lang/swift: Add option to compile with libcxx

This is useful on llvm profile systems, where the default C++ compiler
is clang with libcxx.

Signed-off-by: Marco Rebhan <me@dblsaiko.net>
This commit is contained in:
Marco Rebhan
2025-02-11 00:44:18 +01:00
parent e725aa5030
commit fbbd4a1e11
3 changed files with 21 additions and 2 deletions

View File

@@ -29,7 +29,7 @@
--- a/swift/utils/build-presets.ini
+++ b/swift/utils/build-presets.ini
@@ -3051,3 +3051,17 @@ skip-test-cmark
@@ -3051,3 +3051,24 @@ skip-test-cmark
llvm-cmake-options=
-DCLANG_DEFAULT_LINKER=gold
@@ -47,3 +47,10 @@
+llvm-targets-to-build=host
+skip-build-curl
+skip-build-zlib
+
+[preset: gentoo,libcxx]
+mixin-preset=gentoo
+libcxx
+llvm-cmake-options=
+ -DCLANG_DEFAULT_LINKER=lld
+ -DCLANG_DEFAULT_CXX_STDLIB=libc++

View File

@@ -8,6 +8,11 @@
<upstream>
<remote-id type="github">swiftlang/swift</remote-id>
</upstream>
<use>
<flag name="libcxx">
Use <pkg>llvm-runtimes/libcxx</pkg> as the default C++ runtime library.
</flag>
</use>
<slots>
<slot name="0">
The original slot for swift-5.10.1; should no longer be used.

View File

@@ -64,6 +64,7 @@ LICENSE="Apache-2.0"
SLOT="6/0"
KEYWORDS="~amd64"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
IUSE="libcxx"
RESTRICT="strip"
@@ -182,10 +183,16 @@ src_compile() {
swift_version="${swift_version#${CATEGORY}/}" # reduce to ${PVR} form
swift_version="${swift_version%-r[[:digit:]]*}" # reduce to ${P} form
local swift_preset='gentoo'
if use libcxx; then
swift_preset='gentoo,libcxx'
fi
local original_path="${PATH}"
export PATH="/usr/lib64/${swift_version}/usr/bin:${original_path}"
"${S}/swift/utils/build-script" \
--preset=gentoo \
--preset="${swift_preset}" \
install_destdir="${S}/${P}" \
installable_package="" \
|| die