public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/user/dlang:master commit in: eclass/, profiles/, eclass/tests/, dev-lang/ldc2/, dev-libs/ldc2-runtime/
@ 2025-01-02 20:49 Horodniceanu Andrei
  0 siblings, 0 replies; only message in thread
From: Horodniceanu Andrei @ 2025-01-02 20:49 UTC (permalink / raw
  To: gentoo-commits

commit:     ba87a0fd9d9a768d0489a622dc97bdbc25748d10
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Mon Dec 30 03:08:45 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Thu Jan  2 20:45:52 2025 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=ba87a0fd

dev-lang/ldc2: add 1.40.0 and split the package

Split the original package into dev-lang/ldc2 for the compiler and
dev-libs/ldc2-runtime for the stdlib and runtime.

Add the debug USE flag serving two purposes:

1. locking llvm-core/llvm[debug=] as toggling the debug USE flag on
llvm-core/llvm after dev-lang/ldc2 has been built will render the
compiler binary unusable.

2. Passing -DLDC_ENABLE_ASSERTIONS, which was previously always
disabled.

Additionally install versioned symlinks (/usr/bin/ldc2-1.40) for ldc2
and ldmd2, just like for dmd.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu <AT> proton.me>

 dev-lang/ldc2/Manifest                           |   2 +
 dev-lang/ldc2/ldc2-1.40.0.ebuild                 | 174 +++++++++++++++++
 dev-libs/ldc2-runtime/Manifest                   |   2 +
 dev-libs/ldc2-runtime/ldc2-runtime-1.40.0.ebuild | 237 +++++++++++++++++++++++
 dev-libs/ldc2-runtime/metadata.xml               |   9 +
 eclass/dlang-compilers-r1.eclass                 |   1 +
 eclass/dlang-utils.eclass                        |  41 ++--
 eclass/tests/dlang-utils.sh                      |   9 +-
 profiles/use.desc                                |   2 +
 9 files changed, 463 insertions(+), 14 deletions(-)

diff --git a/dev-lang/ldc2/Manifest b/dev-lang/ldc2/Manifest
index 15e8192..4acf346 100644
--- a/dev-lang/ldc2/Manifest
+++ b/dev-lang/ldc2/Manifest
@@ -6,7 +6,9 @@ DIST ldc-1.36.0-src.tar.gz 8551871 BLAKE2B b0f09128ab37e332f2eebab3288cac687f91b
 DIST ldc-1.37.0-src.tar.gz 8555980 BLAKE2B ac93c903f9dbeec5b69e94c7cdf851ae3fa3168752dceccbd1262fbdae5cdda43e53b82bd7c8b24b0bb2dc06fb00f3b1c74a278a851ea68b948dc7e618460227 SHA512 488451dba58262cf533760f471f707f984d66edeb5c7dfff5a512efa0111742cead4ff23ed5ace39ea4d07e9bac290a846d0df3de49fd3fc276241a771aff0ed
 DIST ldc-1.38.0-src.tar.gz 8691096 BLAKE2B 7b25ba96c470a707d9ee7660ac030984c2cfecaf757a00015507dfb7c17075132ebcc546562ae700ab43eb19e117b4d1247cc1b2f62f455328a7cf9dc0ddf5d4 SHA512 1540a1a6f4bad3bc93da0f59bc28cd31dd4aeb58b8b4c744a204faa43692a1fe13d010ae56b3369e870a5e58724103b2aee58db8b40925698e7816f78f0f2de3
 DIST ldc-1.39.0-src.tar.gz 8554301 BLAKE2B cb1dd5f6b4cc7a7344d8575d1e96fddbd1c34fc0e4f05cf96d29179bec725a997d7d8aee7bf0d97e53d0b36fb108f56e1c55eb66aa93e0075d1beb9d737e21e5 SHA512 d5c91043fa7d5faee9fc231fade52b6ac961907a7f6f8920d8337c9ba0b7052a5f98eb5f23ae56ca93510952c502ca78c9eec1d03f408aaa310fa4e4d57d9519
+DIST ldc-1.40.0-src.tar.gz 8672131 BLAKE2B 88d37117ff1ff0ed53a39231dc0165e68fffc4860a8c1c503bfa4cc5bd9fcc277139d9baf1a93366d16e4a211d1dfa0eb6c74aa35484638a7c6c6c37db577896 SHA512 551fcc259fd609c6b9536352052ec3af44528bf41bfa85873597e0b76d97e8df0f5b1e0b3c18733bd64d2a9fb5ef588bba9d1d866d924629d663ae6ddcac67c0
 DIST ldc2-1.36.0-patches-1.tar.gz 2526 BLAKE2B 016186abc61a174a3e880a167742eafc2f40c6579034e6ec733d22eaa8d2ea51cac1c00a4b80cb9fa995d44229b5473198b7b3d839085b9e94c5622726d4f41f SHA512 f7a124671cd3b7474419823f09d474f72f5be9e4b2c9a30f29743df88caf86491c1363ab2a8dbdfdde69e284789ab1918b78febc98dc0767100d26785cb9d6ba
 DIST ldc2-1.37.0-patches-1.tar.gz 2523 BLAKE2B 397d701de640bc04bdf9246b9f981141287f4bd8069cf1233567f9430652da3fb1b89899b0c8c9a19877d239465a3a4c9758df32ca2dc1cd098ffffc0d729368 SHA512 b24318ec1f484d71c19db013893d94492b5a155f1bd2c5f7c993ad941e19635872b3e4dd15826094c6f80982c956240c58240c7e86f33b5f7af8344eb407090f
 DIST ldc2-1.38.0-patches-1.tar.gz 8924 BLAKE2B 332ff175f3ba50b2c1c2a4e225a6c584621628fa7eda01bc26f318d04af03c5b40202ce2748392f2e55ce712ee6d8431026703419f278c8a6f38ee57a1601ce3 SHA512 00a84c4a5e3391ef3724b3e41b98af91186fb76a4a74a449cfea5cde86eb14889d6a0f06fb449903e95bda12be1448c3b16164bdc64ea990c933211b304ca2a2
 DIST ldc2-1.39.0-patches-1.tar.gz 1176 BLAKE2B 7597fb1917f53ee5ee215cba73b92acf1d8347851d0d71223e5c01421da7ee6fd909ed7da217c99b162f3ca1602cdcddaf680ad13094db8957e98c635c72ecd1 SHA512 f78ddf97bb4ef0167328e1f58a3da7a35ec4a879a6c772f002dc161814bc9ac94b0ff543d3faf533375e0f5a9124a80c44b2371415810f0751617c2f13d56659
+DIST ldc2-1.40.0-patches-1.tar.gz 3856 BLAKE2B 10ae16a7da8db875618f6e698414b818774ee8f9e79272592c253da9834cbeb702b797e742a8210b228403f16650c538b0ad0071f5f5037da9892099d2603509 SHA512 1c037a6cef8c466b08e372294e229933cc983c487ec1eba9618ddd05f2174c2ac319c25e6ebaedf35740b227627a8b4c13940b450f1f50dbc0c71b7c2bdbcb24

diff --git a/dev-lang/ldc2/ldc2-1.40.0.ebuild b/dev-lang/ldc2/ldc2-1.40.0.ebuild
new file mode 100644
index 0000000..fc65afe
--- /dev/null
+++ b/dev-lang/ldc2/ldc2-1.40.0.ebuild
@@ -0,0 +1,174 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DLANG_COMPAT=( dmd-2_{106..109} gdc-1{3..4} ldc2-1_{35..40} )
+LLVM_COMPAT=( {15..19} )
+PYTHON_COMPAT=( python3_{10..13} )
+inherit dlang-single llvm-r1 multiprocessing python-any-r1 toolchain-funcs cmake
+
+PATCH_VER=1
+PATCH_TAG_NAME="${PV}-patches-${PATCH_VER}"
+PATCH_URL_BASE="https://github.com/the-horo/ldc-patches/archive/refs/tags"
+
+DESCRIPTION="LLVM D Compiler"
+HOMEPAGE="https://github.com/ldc-developers/ldc"
+MY_PV="${PV//_/-}"
+MY_P="ldc-${MY_PV}-src"
+SRC_URI="
+	https://github.com/ldc-developers/ldc/releases/download/v${MY_PV}/${MY_P}.tar.gz
+	${PATCH_URL_BASE}/${PATCH_TAG_NAME}.tar.gz -> ${P}-patches-${PATCH_VER}.tar.gz
+"
+S=${WORKDIR}/${MY_P}
+LICENSE="BSD"
+# dmd code but without the runtime libs, see dmd-r1.eclass for more details
+LICENSE+=" Boost-1.0 || ( CC0-1.0 Apache-2.0 )"
+# llvm bits
+LICENSE+=" Apache-2.0-with-LLVM-exceptions UoI-NCSA"
+# old gdc + dmd code
+LICENSE+=" GPL-2+ Artistic"
+
+SLOT="$(ver_cut 1-2)"
+KEYWORDS="~amd64 ~x86"
+
+IUSE="debug test"
+RESTRICT="!test? ( test )"
+
+REQUIRED_USE=${DLANG_REQUIRED_USE}
+COMMON_DEPEND="
+	${DLANG_DEPS}
+	$(llvm_gen_dep '
+	  llvm-core/llvm:${LLVM_SLOT}=[debug=]
+	')
+"
+RDEPEND="${COMMON_DEPEND}"
+DEPEND="
+	${COMMON_DEPEND}
+	test? (
+		  dev-libs/ldc2-runtime:${SLOT}
+	)
+"
+BDEPEND="
+	${DLANG_DEPS}
+	test? (
+		  ${PYTHON_DEPS}
+		  $(python_gen_any_dep '
+			dev-python/lit[${PYTHON_USEDEP}]
+		  ')
+	)
+"
+IDEPEND=">=app-eselect/eselect-dlang-20241230"
+PDEPEND="dev-libs/ldc2-runtime:${SLOT}"
+
+INSTALL_PREFIX="${EPREFIX}/usr/lib/ldc2/${SLOT}" # /usr/lib/ldc2/1.40
+
+python_check_deps() {
+	python_has_version "dev-python/lit[${PYTHON_USEDEP}]"
+}
+
+pkg_setup() {
+	dlang_setup
+	llvm-r1_pkg_setup
+	use test && python_setup
+}
+
+src_prepare() {
+	# Disable GDB tests by passing GDB_FLAGS=OFF
+	# Put this here to avoid trigerring reconfigurations later on.
+	sed -i 's/\(GDB_FLAGS=\)\S\+/\1OFF/' "${S}"/tests/dmd/CMakeLists.txt
+
+	# Calls gcc directly
+	sed -i "s/gcc/$(tc-getCC)/" "${S}"/tests/dmd/runnable/importc-test1.sh || die
+
+	apply_patches
+
+	cmake_src_prepare
+}
+
+src_configure() {
+	local mycmakeargs=(
+		-DLDC_ENABLE_ASSERTIONS=$(usex debug ON OFF)
+		-DD_COMPILER="$(dlang_get_dmdw) $(dlang_get_dmdw_dcflags)"
+		-DCOMPILER_RT_BASE_DIR="${EPREFIX}"/usr/lib
+		-DCOMPILER_RT_LIBDIR_OS=linux
+
+		-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}"
+		-DPHOBOS_SYSTEM_ZLIB=ON
+		-DBUILD_RUNTIME=OFF
+		-DLDC_WITH_LLD=OFF
+		-DLDC_BUNDLE_LLVM_TOOLS=OFF
+		-DCOMPILE_D_MODULES_SEPARATELY=ON
+		-DTEST_COMPILER_RT_LIBRARIES=none
+		# Avoid collisions with other slots. We hardcode the path to
+		# make it easier for eselect-dlang to find the right compdir.
+		-DBASH_COMPLETION_COMPLETIONSDIR="${INSTALL_PREFIX}/usr/share/bash-completion/completions"
+	)
+	cmake_src_configure
+}
+
+src_test() {
+	local libdir="${ESYSROOT}/usr/lib/ldc2/${SLOT}/$(get_libdir)"
+	cat >> "${BUILD_DIR}/bin/ldc2.conf" <<-EOF || die
+	"${CHOST}":
+	{
+		lib-dirs = [
+			"${libdir}",
+		];
+		rpath = "${libdir}";
+	};
+	EOF
+
+	# Call the same tests that .github/actions/main.yml does
+	local jobs=$(get_makeopts_jobs)
+
+	# We build it explicitly so that MAKEOPTS is respected
+	cmake_src_compile ldc2-unittest
+	cmake_src_test -R ldc2-unittest
+
+	# Instead of running cmake_src_test -R lit-tests we call lit directly
+	pushd "${BUILD_DIR}"/tests > /dev/null || die
+	"${EPYTHON}" runlit.py -j${jobs} -v . || die 'lit tests failed'
+	popd > /dev/null || die
+
+	# The dmd testsuite comes into debug and release variants. The debug
+	# one does compilable + fail_compilation + runnable, release only
+	# does runnable. Since it's a compiler I think it's fine to allow
+	# the duplicate tests. A few compilable tests fail with -O.
+	#
+	# These tests invoke a runner that runs the tests in parallel so
+	# specify the jobs only to the runner and not cmake. I'm pretty sure
+	# that some of the tests can't be run simultaneously by multiple
+	# runners so keep the cmake jobs to 1.
+	DMD_TESTSUITE_MAKE_ARGS=-j${jobs} cmake_src_test -j 1 -V -R dmd-testsuite
+}
+
+src_install() {
+	cmake_src_install
+
+	# ldc2.conf is installed as part of ldc2-runtime.
+	rm "${ED}/usr/lib/ldc2/${SLOT}/etc/ldc2.conf" || die
+	rmdir "${ED}/usr/lib/ldc2/${SLOT}/etc" || die
+
+	dosym -r "${INSTALL_PREFIX#${EPREFIX}}/bin/ldc2" "/usr/bin/ldc2-${SLOT}"
+	dosym -r "${INSTALL_PREFIX#${EPREFIX}}/bin/ldmd2" "/usr/bin/ldmd2-${SLOT}"
+}
+
+pkg_postinst() {
+	"${EROOT}"/usr/bin/eselect dlang update ldc2
+}
+
+pkg_postrm() {
+	"${EROOT}"/usr/bin/eselect dlang update ldc2
+}
+
+apply_patches() {
+	local patches_dir="${WORKDIR}/ldc-patches-${PATCH_TAG_NAME}/compiler"
+	local patch
+	einfo "Applying patches from: ${patches_dir}"
+	while read -rd '' patch; do
+		eapply "${patch}"
+	done < <(find "${patches_dir}" -mindepth 1 -maxdepth 1 \
+				  -type f -name '*.patch' \
+				  -print0)
+}

diff --git a/dev-libs/ldc2-runtime/Manifest b/dev-libs/ldc2-runtime/Manifest
new file mode 100644
index 0000000..e922f46
--- /dev/null
+++ b/dev-libs/ldc2-runtime/Manifest
@@ -0,0 +1,2 @@
+DIST ldc-1.40.0-src.tar.gz 8672131 BLAKE2B 88d37117ff1ff0ed53a39231dc0165e68fffc4860a8c1c503bfa4cc5bd9fcc277139d9baf1a93366d16e4a211d1dfa0eb6c74aa35484638a7c6c6c37db577896 SHA512 551fcc259fd609c6b9536352052ec3af44528bf41bfa85873597e0b76d97e8df0f5b1e0b3c18733bd64d2a9fb5ef588bba9d1d866d924629d663ae6ddcac67c0
+DIST ldc2-1.40.0-patches-1.tar.gz 3856 BLAKE2B 10ae16a7da8db875618f6e698414b818774ee8f9e79272592c253da9834cbeb702b797e742a8210b228403f16650c538b0ad0071f5f5037da9892099d2603509 SHA512 1c037a6cef8c466b08e372294e229933cc983c487ec1eba9618ddd05f2174c2ac319c25e6ebaedf35740b227627a8b4c13940b450f1f50dbc0c71b7c2bdbcb24

diff --git a/dev-libs/ldc2-runtime/ldc2-runtime-1.40.0.ebuild b/dev-libs/ldc2-runtime/ldc2-runtime-1.40.0.ebuild
new file mode 100644
index 0000000..8bbbb46
--- /dev/null
+++ b/dev-libs/ldc2-runtime/ldc2-runtime-1.40.0.ebuild
@@ -0,0 +1,237 @@
+# Copyright 2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DLANG_COMPAT=( ldc2-1_$(ver_cut 2) )
+inherit dlang-single multilib cmake-multilib
+
+PATCH_VER=1
+PATCH_TAG_NAME="${PV}-patches-${PATCH_VER}"
+PATCH_URL_BASE="https://github.com/the-horo/ldc-patches/archive/refs/tags"
+
+DESCRIPTION="LLVM D Compiler"
+HOMEPAGE="https://github.com/ldc-developers/ldc"
+MY_PV="${PV//_/-}"
+MY_P="ldc-${MY_PV}-src"
+SRC_URI="
+	https://github.com/ldc-developers/ldc/releases/download/v${MY_PV}/${MY_P}.tar.gz
+	${PATCH_URL_BASE}/${PATCH_TAG_NAME}.tar.gz -> ldc2-${PV}-patches-${PATCH_VER}.tar.gz
+"
+S=${WORKDIR}/${MY_P}
+LICENSE="BSD"
+# runtime libs, see dmd-r1.eclass for more details
+LICENSE+=" Boost-1.0 BZIP2 ZLIB curl public-domain"
+
+# Only increase subslot in case of ABI breakage
+SLOT="$(ver_cut 1-2)/0"
+LDC2_SLOT="$(ver_cut 1-2)" # SLOT without subslot
+KEYWORDS="~amd64 ~x86"
+
+IUSE="static-libs test"
+RESTRICT="!test? ( test )"
+
+REQUIRED_USE=${DLANG_REQUIRED_USE}
+RDEPEND="
+	sys-libs/zlib:0/1
+	net-misc/curl[${MULTILIB_USEDEP}]
+"
+# curl is dlopened. The tests do need it though.
+DEPEND="
+	sys-libs/zlib:0/1
+	test? (
+		  net-misc/curl[${MULTILIB_USEDEP}]
+	)
+"
+# We purposefully ignore DLANG_DEPS, we only need the ldc2 compiler and only in BROOT
+BDEPEND="dev-lang/ldc2:${LDC2_SLOT}"
+IDEPEND=">=app-eselect/eselect-dlang-20241230"
+
+INSTALL_PREFIX="${EPREFIX}/usr/lib/ldc2/${LDC2_SLOT}" # /usr/lib/ldc2/1.40
+STRING_IMPORTS_DIR="${T}/views"
+LDC2_CONF_DIR="${WORKDIR}/conf"
+
+src_prepare() {
+	mkdir -p "${STRING_IMPORTS_DIR}" || die
+	local tzpath="${STRING_IMPORTS_DIR}/TZDatabaseDirFile"
+	# std.datetime.timezone default search path, instead of /usr/share/zoneinfo/
+	echo "${EPREFIX}/usr/share/zoneinfo/" > "${tzpath}" || die
+
+	# Create wrappers for ldc2 because the cmake file only supports
+	# passing arguments to the compiler at the end of the command line.
+	# This breaks the -conf= argument that we want to use.
+	cat <<-EOF > "${T}/ldc2" || die
+	#!/bin/sh
+	exec "${DC}" -conf="${LDC2_CONF_DIR}/ldc2.conf" "\${@}"
+	EOF
+	cat <<-EOF > "${T}/ldmd2" || die
+	#!/bin/sh
+	exec "$(dlang_get_dmdw)" -conf="${LDC2_CONF_DIR}/ldc2.conf" "\${@}"
+	EOF
+	chmod +x "${T}/ldc2" "${T}/ldmd2" || die
+
+	apply_patches
+
+	cmake_src_prepare
+}
+
+src_configure() {
+	add_multilib_sections() {
+		multilib_is_native_abi && return
+		add_multilib_section "${S}/ldc2_phobos.conf.in" "${BUILD_DIR}/$(get_libdir)"
+		add_multilib_section "${S}/ldc2_install.conf.in" "${INSTALL_PREFIX}/$(get_libdir)"
+	}
+	multilib_foreach_abi add_multilib_sections
+
+	multilib-minimal_src_configure
+}
+
+multilib_src_configure() {
+	local mycmakeargs=(
+		-DBUILD_SHARED_LIBS=$(usex static-libs BOTH ON)
+		# flags for the runtime, the need to be separated by ;
+		-DD_FLAGS_RELEASE="${DCFLAGS// /;}"
+		# Slight improvements with this
+		-DCOMPILE_ALL_D_FILES_AT_ONCE=OFF
+
+		-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}"
+		-DPHOBOS_SYSTEM_ZLIB=ON
+		-DLDC_EXE_FULL="${T}/ldc2"
+		-DLDMD_EXE_FULL="${T}/ldmd2"
+		# needed for the sake of EPREFIX
+		-DPHOBOS2_EXTRA_FLAGS="-J;${STRING_IMPORTS_DIR};-d-version=TZDatabaseDir"
+		# ${EDC}                   # ldc2-1.40
+		#   .dlang_get_fe_version  # 2.110
+		#   .ver_cut(2)            # 110
+		-DDMDFE_MINOR_VERSION="$(ver_cut 2 $(dlang_get_fe_version ${EDC}))"
+		-DDMDFE_PATCH_VERSION="$(ver_cut 3)"
+	)
+	if ! multilib_is_native_abi; then
+		# configure multilib flags
+		mycmakeargs+=(
+			-DD_EXTRA_FLAGS="$(dlang_get_model_flag)"
+			-DRT_CFLAGS="$(get_abi_CFLAGS)"
+		)
+	else
+		# we save the config file from the native build
+		mycmakeargs+=(-DCONFIG_FILE_OUTPUT_DIR="${LDC2_CONF_DIR}")
+	fi
+
+	CMAKE_USE_DIR="${S}/runtime" cmake_src_configure
+}
+
+multilib_src_test() {
+	# cmake.eclass modifies this internally but doesn't declare it as local making
+	# changes to it carry out across invocations of ${FUNCNAME}
+	local myctestargs
+
+	# We compile the tests first so that $MAKEOPTS is respect, if
+	# compiled during the tests, nproc jobs will be used.
+	cmake_src_compile all-test-runners
+
+	local CMAKE_SKIP_TESTS=(
+		# These require valgrind
+		druntime-test-gc
+		druntime-test-valgrind
+		# Should be fixed by https://github.com/dlang/dmd/pull/16851
+		# Drop the above once the changes are merged into ldc2
+
+		# This one fails due to an uncaught error, probably due to the
+		# sandbox.
+		druntime-test-cycles
+	)
+	if [[ ${ARCH} == arm64 ]]; then
+		# https://github.com/ldc-developers/ldc/issues/4613
+
+		# fails due to "innacuracy"
+		CMAKE_SKIP_TESTS+=( std.internal.math.gammafunction )
+		# Bad code generation with optimizations?
+		CMAKE_SKIP_TESTS+=( std.math.exponential )
+	fi
+
+	# This test requires "${TEMP}/<some-file>" to be less than 108 characters.
+	# We will run it separately and force ${TEMP} to be a shorter path.
+	TMPDIR="." cmake_src_test -R std.socket
+	CMAKE_SKIP_TESTS+=( std.socket )
+
+	# We don't want to run gdb or valgrind tests
+	local -x GDB=gdb-dont-find-me VALGRIND=valgrind-dont-find-me
+	cmake_src_test
+}
+
+multilib_src_compile() {
+	cmake_src_compile
+	symlinks_release_runtime_to_debug "${BUILD_DIR}"
+}
+
+multilib_src_install() {
+	cmake_src_install
+	symlinks_release_runtime_to_debug "${D}/${INSTALL_PREFIX}"
+}
+
+multilib_src_install_all() {
+	local ldc2_etc="${INSTALL_PREFIX#"${EPREFIX}"}/etc"
+	insinto "${ldc2_etc}"
+	newins "${LDC2_CONF_DIR}"/ldc2_install.conf ldc2.conf
+	dosym -r "${ldc2_etc}"/ldc2.conf "/etc/ldc2/${LDC2_SLOT}.conf"
+}
+
+pkg_postinst() {
+	"${EROOT}"/usr/bin/eselect dlang update ldc2
+}
+
+pkg_postrm() {
+	"${EROOT}"/usr/bin/eselect dlang update ldc2
+}
+
+apply_patches() {
+	local patches_dir="${WORKDIR}/ldc-patches-${PATCH_TAG_NAME}/runtime"
+	einfo "Applying patches from: ${patches_dir}"
+	local patch
+	while read -rd '' patch; do
+		eapply "${patch}"
+	done < <(find "${patches_dir}" -mindepth 1 -maxdepth 1 \
+				  -type f -name '*.patch' \
+				  -print0)
+}
+
+# Create symlinks to libdruntime-ldc-shared et al from libdruntime-ldc-debug-shared
+# Usage: <dir>
+# The symlinks are made in <dir>/$(get_libdir)
+symlinks_release_runtime_to_debug() {
+	rename_in_dir() {
+		local file find_cmd=(
+			find "${1}" -mindepth 1 -maxdepth 1
+			# Find files that look like a runtime library
+			-regex ".*/lib\(druntime\|phobos\)[^/]*"
+			# and are not a debug variant
+			-not -name '*debug*'
+			-printf '%f\0'
+		)
+		while read -rd '' file; do
+			# and symlink them:
+			# ${file}                 == libdruntime-ldc-shared
+			# ${file/-ldc/-ldc-debug} == libdruntime-ldc-debug-shared
+			ln -s "${file}" "${1}/${file/-ldc/-ldc-debug}" || die
+		done < <("${find_cmd[@]}")
+	}
+
+	rename_in_dir "${1}/$(get_libdir)"
+}
+
+# USAGE: <ldc2_conf_file> <full_libdir>
+add_multilib_section() {
+	# NOTE: We're missing compiler-rt's libdir
+	local filepath=${1} libdir=${2}
+	local triple_without_vendor=$(sed -e 's/-[^-]*/-.*/' <<<"${CHOST}") # i686-.*-linux-gnu
+	cat >> "${filepath}" <<EOF || die "Could not add multilib section"
+
+"${triple_without_vendor}":
+{
+	lib-dirs = [
+		"${libdir}",
+	];
+	rpath = "${libdir}";
+};
+EOF
+}

diff --git a/dev-libs/ldc2-runtime/metadata.xml b/dev-libs/ldc2-runtime/metadata.xml
new file mode 100644
index 0000000..08f0ba9
--- /dev/null
+++ b/dev-libs/ldc2-runtime/metadata.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+  <upstream>
+    <bugs-to>https://github.com/ldc-developers/ldc/issues</bugs-to>
+    <changelog>https://github.com/ldc-developers/ldc/blob/master/CHANGELOG.md</changelog>
+    <remote-id type="github">ldc-developers/ldc</remote-id>
+  </upstream>
+</pkgmetadata>

diff --git a/eclass/dlang-compilers-r1.eclass b/eclass/dlang-compilers-r1.eclass
index b570a64..59ea1d2 100644
--- a/eclass/dlang-compilers-r1.eclass
+++ b/eclass/dlang-compilers-r1.eclass
@@ -97,6 +97,7 @@ readonly _DLANG_LDC2_FRONTENDS=(
 	"1.37 2.107 ~amd64 ~arm64 ~x86"
 	"1.38 2.108 ~amd64 ~arm64 ~x86"
 	"1.39 2.109 ~amd64 ~x86"
+	"1.40 2.110 ~amd64 ~x86"
 )
 
 # @FUNCTION: _dlang_accumulate_implementations

diff --git a/eclass/dlang-utils.eclass b/eclass/dlang-utils.eclass
index 3c634d6..87b3133 100644
--- a/eclass/dlang-utils.eclass
+++ b/eclass/dlang-utils.eclass
@@ -1,4 +1,4 @@
-# Copyright 2024 Gentoo Authors
+# Copyright 2024-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: dlang-utils.eclass
@@ -821,14 +821,19 @@ _dlang_export() {
 				local libdirname
 				case "${impl::3}" in
 					ldc)
-						# Old dlang.eclass always picked lib<bits> which
-						# isn't always correct. The proper calculation
-						# is found in runtime/CMakeLists.txt which is:
-						# - native abi is always put in lib<LIB_SUFFIX>
-						#   which is set by cmake.eclass to $(get_libdir)
-						# - x86 on amd64 is put in lib<bits>
-						libdirname=$(pick_nomulti_amd64_x86 \
-										 "$(get_libdir)" "$(get_libdir)" "lib32")
+						if ver_test "${impl#ldc2-}" -ge 1.40; then
+							# ldc started using multilib-build for the runtime
+							libdirname="$(get_libdir)"
+						else
+							# Old dlang.eclass always picked lib<bits> which
+							# isn't always correct. The proper calculation
+							# is found in runtime/CMakeLists.txt which is:
+							# - native abi is always put in lib<LIB_SUFFIX>
+							#   which is set by cmake.eclass to $(get_libdir)
+							# - x86 on amd64 is put in lib<bits>
+							libdirname=$(pick_nomulti_amd64_x86 \
+											 "$(get_libdir)" "$(get_libdir)" "lib32")
+						fi
 						;;
 					gdc)
 						# I have no idea how gcc does it but the line
@@ -1085,12 +1090,22 @@ _dlang_export() {
 				#
 				# dmd and ldc2 should have ABI compatible patch releases
 				# but we will use :slot= just in case.
+				#
+				# Since ldc2-1.40.0 the package is split into compiler +
+				# runtime. Since only the runtime provides relevant USE
+				# flags usedep is only applied to it.
+				local dmd_dep="dev-lang/dmd:${impl#dmd-}=${usedep}"
+				local gdc_dep="sys-devel/gcc:${impl#gdc-}${usedep} dev-util/gdmd:${impl#gdc-}"
+				local ldc_ver="${impl#ldc2-}" ldc_dep
+				if [[ ${impl} == ldc2* ]] && ver_test "${ldc_ver}" -ge 1.40; then
+					ldc_dep="dev-lang/ldc2:${ldc_ver} dev-libs/ldc2-runtime:${ldc_ver}=${usedep}"
+				else
+					ldc_dep="dev-lang/ldc2:${ldc_ver}=${usedep}"
+				fi
+
 				export DLANG_PKG_DEP=$(
 					_dlang_echo_implementation_string \
-						"${impl}" \
-						"dev-lang/dmd:${impl#dmd-}=${usedep}" \
-						"sys-devel/gcc:${impl#gdc-}${usedep} dev-util/gdmd:${impl#gdc-}" \
-						"dev-lang/ldc2:${impl#ldc2-}=${usedep}"
+						"${impl}" "${dmd_dep}" "${gdc_dep}" "${ldc_dep}"
 					)
 				debug-print "${FUNCNAME}: DLANG_PKG_DEP = ${DLANG_PKG_DEP}"
 				;;

diff --git a/eclass/tests/dlang-utils.sh b/eclass/tests/dlang-utils.sh
index 28d10d9..0bb4d51 100755
--- a/eclass/tests/dlang-utils.sh
+++ b/eclass/tests/dlang-utils.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 2024 Gentoo Authors
+# Copyright 2024-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 gentooRepo=$(portageq get_repo_path / gentoo)
@@ -8,6 +8,7 @@ readonly gentooRepo
 
 EAPI=8
 source "${gentooRepo}"/eclass/tests/tests-common.sh || exit
+source "${gentooRepo}"/eclass/tests/version-funcs.sh || exit
 TESTS_ECLASS_SEARCH_PATHS=( .. "${gentooRepo}"/eclass )
 
 # Before the inherit so multilib.eclass picks the correct value
@@ -134,6 +135,7 @@ test_var DLANG_SYSTEM_IMPORT_PATHS ldc2-1_32 "${EPREFIX}/usr/lib/ldc2/1.32/inclu
 test_var DLANG_PKG_DEP dmd-2.102 "dev-lang/dmd:2.102="
 test_var DLANG_PKG_DEP gdc-12 "sys-devel/gcc:12[d] dev-util/gdmd:12"
 test_var DLANG_PKG_DEP ldc2-1.36 "dev-lang/ldc2:1.36="
+test_var DLANG_PKG_DEP ldc2-1.40 "dev-lang/ldc2:1.40 dev-libs/ldc2-runtime:1.40="
 
 declare -A DLANG_REQ_USE=(
 	[dmd]="flag1"
@@ -143,6 +145,7 @@ declare -A DLANG_REQ_USE=(
 test_var DLANG_PKG_DEP dmd-2.102 "dev-lang/dmd:2.102=[flag1]"
 test_var DLANG_PKG_DEP gdc-12 "sys-devel/gcc:12[d,flag2] dev-util/gdmd:12"
 test_var DLANG_PKG_DEP ldc2-1.36 "dev-lang/ldc2:1.36=[flag3(-)?]"
+test_var DLANG_PKG_DEP ldc2-1.40 "dev-lang/ldc2:1.40 dev-libs/ldc2-runtime:1.40=[flag3(-)?]"
 
 get_libdir() {
 	local libdir_var="LIBDIR_${ABI}"
@@ -158,11 +161,13 @@ ABI=amd64
 test_var DLANG_LIBDIR dmd-2.102 "lib/dmd/2.102/lib64"
 test_var DLANG_LIBDIR gdc-12 "lib/gcc/${CHOST_default}/12"
 test_var DLANG_LIBDIR ldc2-1.35 "lib/ldc2/1.35/lib64"
+test_var DLANG_LIBDIR ldc2-1.40 "lib/ldc2/1.40/lib64"
 test_var DLANG_MODEL_FLAG ldc2-1.35 '-m64'
 ABI=x86
 test_var DLANG_LIBDIR dmd-2.102 "lib/dmd/2.102/lib32"
 test_var DLANG_LIBDIR gdc-12 "lib/gcc/${CHOST_default}/12/32"
 test_var DLANG_LIBDIR ldc2-1.35 "lib/ldc2/1.35/lib32"
+test_var DLANG_LIBDIR ldc2-1.40 "lib/ldc2/1.40/lib"
 test_var DLANG_MODEL_FLAG ldc2-1.35 '-m32'
 
 # nomultilib
@@ -173,11 +178,13 @@ ABI=amd64
 test_var DLANG_LIBDIR dmd-2.102 "lib/dmd/2.102/lib64"
 test_var DLANG_LIBDIR gdc-12 "lib/gcc/${CHOST_default}/12"
 test_var DLANG_LIBDIR ldc2-1.35 "lib/ldc2/1.35/lib64"
+test_var DLANG_LIBDIR ldc2-1.40 "lib/ldc2/1.40/lib64"
 test_var DLANG_MODEL_FLAG ldc2-1.35 ''
 LIBDIR_amd64=mylib
 test_var DLANG_LIBDIR dmd-2.102 "lib/dmd/2.102/lib64"
 test_var DLANG_LIBDIR gdc-12 "lib/gcc/${CHOST_default}/12"
 test_var DLANG_LIBDIR ldc2-1.35 "lib/ldc2/1.35/mylib"
+test_var DLANG_LIBDIR ldc2-1.40 "lib/ldc2/1.40/mylib"
 
 MULTILIB_ABIS=x86
 DEFAULT_ABI=x86

diff --git a/profiles/use.desc b/profiles/use.desc
index 78b8234..f109784 100644
--- a/profiles/use.desc
+++ b/profiles/use.desc
@@ -20,6 +20,7 @@ dlang_single_target_ldc2-1_36 - Build for ldc2 1.36 only
 dlang_single_target_ldc2-1_37 - Build for ldc2 1.37 only
 dlang_single_target_ldc2-1_38 - Build for ldc2 1.38 only
 dlang_single_target_ldc2-1_39 - Build for ldc2 1.39 only
+dlang_single_target_ldc2-1_40 - Build for ldc2 1.40 only
 
 dlang_targets_dmd-2_101 - Build with DMD 2.101
 dlang_targets_dmd-2_102 - Build with DMD 2.102
@@ -43,6 +44,7 @@ dlang_targets_ldc2-1_36 - Build with ldc2 1.36
 dlang_targets_ldc2-1_37 - Build with ldc2 1.37
 dlang_targets_ldc2-1_38 - Build with ldc2 1.38
 dlang_targets_ldc2-1_39 - Build with ldc2 1.39
+dlang_targets_ldc2-1_40 - Build with ldc2 1.40
 
 
 dmd-2_101 - Build for DMD 2.101


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-01-02 20:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-02 20:49 [gentoo-commits] repo/user/dlang:master commit in: eclass/, profiles/, eclass/tests/, dev-lang/ldc2/, dev-libs/ldc2-runtime/ Horodniceanu Andrei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox