From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 41347158046 for ; Sun, 13 Oct 2024 14:51:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 56541E08C4; Sun, 13 Oct 2024 14:51:37 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3EE34E08B1 for ; Sun, 13 Oct 2024 14:51:37 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7B022343267 for ; Sun, 13 Oct 2024 14:51:36 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 572111FBE for ; Sun, 13 Oct 2024 14:51:33 +0000 (UTC) From: "David Roman" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "David Roman" Message-ID: <1728783085.ca27db7e8b92982c2e87912b5651296278309204.davidroman@gentoo> Subject: [gentoo-commits] repo/proj/guru:master commit in: dev-lang/swift/ X-VCS-Repository: repo/proj/guru X-VCS-Files: dev-lang/swift/swift-5.10.1-r1.ebuild X-VCS-Directories: dev-lang/swift/ X-VCS-Committer: davidroman X-VCS-Committer-Name: David Roman X-VCS-Revision: ca27db7e8b92982c2e87912b5651296278309204 X-VCS-Branch: master Date: Sun, 13 Oct 2024 14:51:33 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 508a330e-4c7e-45ed-b34b-6bdfb6125f64 X-Archives-Hash: 69377e181ffa6450b7208ba7c234415f commit: ca27db7e8b92982c2e87912b5651296278309204 Author: Itai Ferber itaiferber net> AuthorDate: Sun Oct 13 01:25:19 2024 +0000 Commit: David Roman gmail com> CommitDate: Sun Oct 13 01:31:25 2024 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=ca27db7e dev-lang/swift: use llvm-r1 to set LLVM toolchain Signed-off-by: Itai Ferber itaiferber.net> dev-lang/swift/swift-5.10.1-r1.ebuild | 62 ++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/dev-lang/swift/swift-5.10.1-r1.ebuild b/dev-lang/swift/swift-5.10.1-r1.ebuild index f855522a2..145becb3f 100644 --- a/dev-lang/swift/swift-5.10.1-r1.ebuild +++ b/dev-lang/swift/swift-5.10.1-r1.ebuild @@ -3,8 +3,9 @@ EAPI=8 +LLVM_COMPAT=( {15..18} ) PYTHON_COMPAT=( python3_{10..13} ) -inherit python-single-r1 +inherit llvm-r1 python-single-r1 DESCRIPTION="A high-level, general-purpose, multi-paradigm, compiled programming language" HOMEPAGE="https://www.swift.org" @@ -70,10 +71,10 @@ RDEPEND=" >=dev-libs/libedit-20221030 >=dev-libs/libxml2-2.11.5 >=net-misc/curl-8.4 - >=sys-devel/lld-15 >=sys-libs/ncurses-6 >=sys-libs/zlib-1.3 dev-lang/python + $(llvm_gen_dep 'sys-devel/lld:${LLVM_SLOT}=') " BDEPEND=" @@ -86,16 +87,61 @@ BDEPEND=" >=dev-libs/libxml2-2.11.5 >=dev-vcs/git-2.39 >=sys-apps/coreutils-9 - >=sys-devel/clang-15 - >=sys-devel/lld-15 >=sys-libs/ncurses-6 >=sys-libs/zlib-1.3 + $(llvm_gen_dep ' + sys-devel/clang:${LLVM_SLOT}= + sys-devel/lld:${LLVM_SLOT}= + ') dev-lang/python $(python_gen_cond_dep ' dev-python/setuptools[${PYTHON_USEDEP}] ' python3_{12..13}) " +# Adapted from `flag-o-matic.eclass`'s `raw-ldflags`: turns GCC-style flags +# (`-Wl,-foo`) into Clang-style flags (`-Xlinker -foo`). +clang-ldflags() { + local flag input="$@" + [[ -z ${input} ]] && input=${LDFLAGS} + set -- + for flag in ${input//,/ } ; do + case ${flag} in + -Wl) ;; + *) set -- "$@" "-Xlinker ${flag}" ;; + esac + done + echo "$@" +} + +pkg_setup() { + # Sets `${EPYTHON}` according to `PYTHON_SINGLE_TARGET`, sets up + # `${T}/${EPYTHON}` with that version, and adds it to the `PATH`. + python_setup + + # Sets up `PATH` to point to the appropriate LLVM toolchain. + llvm-r1_pkg_setup + + # `llvm-r1_pkg_setup` sets these tools to their absolute paths, but we need + # to still pick them up dynamically based on `PATH` for stage1 and stage2 + # builds below (to keep all parts of the Swift toolchain compiling with the + # same internal tools). + export CC="clang" + export CXX="clang++" + export LD="ld.lld" + + # Swift builds with CMake, which picks up `LDFLAGS` from the environment and + # populates `CMAKE_EXE_LINKER_FLAGS` with them. `LDFLAGS` are typically + # given as GCC-style flags (), which Clang understands; + # unfortunately, CMake passes these flags to all compilers under the + # assumption they support the same syntax, but `swiftc` _only_ understands + # Clang-style flags (`-Xlinker -foo`). In order to pass `LDFLAGS` in, we + # have to turn them into a format that `swiftc` will understand. + # + # We can do this because we know we're compiling with Clang specifically. + export LDFLAGS="$(clang-ldflags)" +} + src_unpack() { default @@ -117,14 +163,6 @@ src_unpack() { || die } -src_configure() { - default - - # Sets `${EPYTHON}` according to `PYTHON_SINGLE_TARGET`, sets up - # `${T}/${EPYTHON}` with that version, and adds it to the `PATH`. - python_setup -} - src_compile() { # The Swift 5.10 compiler is partially written in Swift itself (the new # `swift-driver` + macro support via `swift-syntax`), which requires