commit:     623eab3fa38910ce605108380d23617bf9a0183b
Author:     Michal Rostecki <vadorovsky <AT> protonmail <DOT> com>
AuthorDate: Wed Aug 27 03:39:24 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Sep  2 13:17:43 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=623eab3f

llvm-runtimes/clang-stdlib-config: New package

Provide a new package which creates a partial clang config file
`/etc/clang/${LLVM_VERSION}/gentoo-stdlib.cfg`, used to control the
default C++ standard library used by clang.

Signed-off-by: Michal Rostecki <vadorovsky <AT> protonmail.com>
Closes: https://bugs.gentoo.org/951445
Part-of: https://github.com/gentoo/gentoo/pull/42663
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Part-of: https://github.com/gentoo/gentoo/pull/42663
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../clang-stdlib-config-20.ebuild                  | 28 ++++++++++++++++++++++
 .../clang-stdlib-config-21.ebuild                  | 28 ++++++++++++++++++++++
 .../clang-stdlib-config-22.ebuild                  | 27 +++++++++++++++++++++
 llvm-runtimes/clang-stdlib-config/metadata.xml     | 17 +++++++++++++
 metadata/stabilization-groups/llvm.group           |  1 +
 5 files changed, 101 insertions(+)

diff --git a/llvm-runtimes/clang-stdlib-config/clang-stdlib-config-20.ebuild 
b/llvm-runtimes/clang-stdlib-config/clang-stdlib-config-20.ebuild
new file mode 100644
index 000000000000..5b6630587a07
--- /dev/null
+++ b/llvm-runtimes/clang-stdlib-config/clang-stdlib-config-20.ebuild
@@ -0,0 +1,28 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Default C++ library configuration for clang"
+HOMEPAGE="https://clang.llvm.org/";
+S=${WORKDIR}
+
+LICENSE="public-domain"
+SLOT="${PV}"
+KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 
~amd64-linux ~arm64-macos ~ppc-macos ~x64-macos"
+IUSE="default-libcxx"
+
+RDEPEND="
+       default-libcxx? ( >=llvm-runtimes/libcxx-${PV}[static-libs] )
+       !default-libcxx? ( sys-devel/gcc )
+"
+
+src_install() {
+       insinto "/etc/clang/${SLOT}"
+       newins - gentoo-stdlib.cfg <<-EOF
+               # This file is initially generated by ${CATEGORY}/${PN}.
+               # It is used to control the default C++ standard library used 
by clang.
+
+               --stdlib=$(usex default-libcxx libc++ libstdc++)
+       EOF
+}

diff --git a/llvm-runtimes/clang-stdlib-config/clang-stdlib-config-21.ebuild 
b/llvm-runtimes/clang-stdlib-config/clang-stdlib-config-21.ebuild
new file mode 100644
index 000000000000..5b6630587a07
--- /dev/null
+++ b/llvm-runtimes/clang-stdlib-config/clang-stdlib-config-21.ebuild
@@ -0,0 +1,28 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Default C++ library configuration for clang"
+HOMEPAGE="https://clang.llvm.org/";
+S=${WORKDIR}
+
+LICENSE="public-domain"
+SLOT="${PV}"
+KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 
~amd64-linux ~arm64-macos ~ppc-macos ~x64-macos"
+IUSE="default-libcxx"
+
+RDEPEND="
+       default-libcxx? ( >=llvm-runtimes/libcxx-${PV}[static-libs] )
+       !default-libcxx? ( sys-devel/gcc )
+"
+
+src_install() {
+       insinto "/etc/clang/${SLOT}"
+       newins - gentoo-stdlib.cfg <<-EOF
+               # This file is initially generated by ${CATEGORY}/${PN}.
+               # It is used to control the default C++ standard library used 
by clang.
+
+               --stdlib=$(usex default-libcxx libc++ libstdc++)
+       EOF
+}

diff --git a/llvm-runtimes/clang-stdlib-config/clang-stdlib-config-22.ebuild 
b/llvm-runtimes/clang-stdlib-config/clang-stdlib-config-22.ebuild
new file mode 100644
index 000000000000..e3092321b6e0
--- /dev/null
+++ b/llvm-runtimes/clang-stdlib-config/clang-stdlib-config-22.ebuild
@@ -0,0 +1,27 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Default C++ library configuration for clang"
+HOMEPAGE="https://clang.llvm.org/";
+S=${WORKDIR}
+
+LICENSE="public-domain"
+SLOT="${PV}"
+IUSE="default-libcxx"
+
+RDEPEND="
+       default-libcxx? ( >=llvm-runtimes/libcxx-${PV}[static-libs] )
+       !default-libcxx? ( sys-devel/gcc )
+"
+
+src_install() {
+       insinto "/etc/clang/${SLOT}"
+       newins - gentoo-stdlib.cfg <<-EOF
+               # This file is initially generated by ${CATEGORY}/${PN}.
+               # It is used to control the default C++ standard library used 
by clang.
+
+               --stdlib=$(usex default-libcxx libc++ libstdc++)
+       EOF
+}

diff --git a/llvm-runtimes/clang-stdlib-config/metadata.xml 
b/llvm-runtimes/clang-stdlib-config/metadata.xml
new file mode 100644
index 000000000000..66f2a121f173
--- /dev/null
+++ b/llvm-runtimes/clang-stdlib-config/metadata.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <maintainer type="person">
+               <email>[email protected]</email>
+               <name>Michal Rostecki</name>
+       </maintainer>
+       <maintainer type="project">
+               <email>[email protected]</email>
+       </maintainer>
+       <use>
+               <flag name="default-libcxx">Use libc++ instead of libstdc++ as 
the default stdlib for clang</flag>
+       </use>
+       <upstream>
+               <remote-id type="github">llvm/llvm-project</remote-id>
+       </upstream>
+</pkgmetadata>

diff --git a/metadata/stabilization-groups/llvm.group 
b/metadata/stabilization-groups/llvm.group
index 0346dcc1e558..3c3d40690f73 100644
--- a/metadata/stabilization-groups/llvm.group
+++ b/metadata/stabilization-groups/llvm.group
@@ -27,6 +27,7 @@ llvm-runtimes/offload
 llvm-core/clang-linker-config
 llvm-runtimes/clang-rtlib-config
 llvm-runtimes/clang-unwindlib-config
+llvm-runtimes/clang-stdlib-config
 llvm-core/clang-runtime
 llvm-core/libclc
 llvm-runtimes/libatomic-stub

Reply via email to