public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/user/dlang:master commit in: dev-lang/ldc2/, dev-lang/ldc2/files/
@ 2024-04-13 23:04 Horodniceanu Andrei
  0 siblings, 0 replies; 2+ messages in thread
From: Horodniceanu Andrei @ 2024-04-13 23:04 UTC (permalink / raw
  To: gentoo-commits

commit:     79bb15a181cd764a02097382d13c5461eb0ef4e1
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Fri Mar 22 06:53:22 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sat Apr 13 23:00:58 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=79bb15a1

dev-lang/ldc2: add tests

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

 ...36.0-disable-compiler-rt-sanitizers-tests.patch |  56 +++++++++
 ....36.0-fix-phobos-OS-dependent-test-string.patch |  26 ++++
 .../files/ldc2-1.36.0-lit-cfg-disable-gdb.patch    |  13 ++
 ...ldc2-1.36.0-tests-dshell-remove--m-switch.patch |  13 ++
 .../ldc2-remove-dmd-common-int128-unittest.patch   |  17 +++
 dev-lang/ldc2/ldc2-1.36.0-r2.ebuild                | 138 +++++++++++++++++++--
 6 files changed, 255 insertions(+), 8 deletions(-)

diff --git a/dev-lang/ldc2/files/ldc2-1.36.0-disable-compiler-rt-sanitizers-tests.patch b/dev-lang/ldc2/files/ldc2-1.36.0-disable-compiler-rt-sanitizers-tests.patch
new file mode 100644
index 0000000..e086e2d
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-1.36.0-disable-compiler-rt-sanitizers-tests.patch
@@ -0,0 +1,56 @@
+diff --git a/tests/PGO/lit.local.cfg b/tests/PGO/lit.local.cfg
+index 9638e26..4578f1a 100644
+--- a/tests/PGO/lit.local.cfg
++++ b/tests/PGO/lit.local.cfg
+@@ -1,2 +1,2 @@
+ # Add "PGO_RT" feature, assuming the `profile` compiler-rt library is available
+-config.available_features.add('PGO_RT')
++#config.available_features.add('PGO_RT')
+diff --git a/tests/instrument/lit.local.cfg b/tests/instrument/lit.local.cfg
+index 9366e7b..5030a1e 100644
+--- a/tests/instrument/lit.local.cfg
++++ b/tests/instrument/lit.local.cfg
+@@ -2,4 +2,5 @@ import platform
+ 
+ # Add "XRay_RT" feature on non-Windows, assuming the compiler-rt libraries are available
+ if (platform.system() != 'Windows'):
+-    config.available_features.add('XRay_RT')
++    #config.available_features.add('XRay_RT')
++    pass
+diff --git a/tests/sanitizers/lit.local.cfg b/tests/sanitizers/lit.local.cfg
+index ce12558..6bd5021 100644
+--- a/tests/sanitizers/lit.local.cfg
++++ b/tests/sanitizers/lit.local.cfg
+@@ -4,24 +4,27 @@ import platform
+ sys = platform.system()
+ 
+ # Add "LSan" feature, assuming the compiler-rt library is available
+-config.available_features.add('LSan')
++#config.available_features.add('LSan')
+ 
+ # FreeBSD TSan doesn't seem to work,
+ # Linux TSan currently only works with static druntime,
+ # and there's no Windows TSan (yet?).
+ if (sys != 'FreeBSD') and (sys != 'Windows') and not (sys == 'Linux' and config.shared_rt_libs_only):
+-    config.available_features.add('TSan')
++    #config.available_features.add('TSan')
++    pass
+ 
+ # FreeBSD ASan and MSan don't cope well with ASLR (might do with FreeBSD 14 according to https://github.com/llvm/llvm-project/pull/73439)
+ if sys != 'FreeBSD':
+-    config.available_features.add('ASan')
++    #config.available_features.add('ASan')
++    pass
+ 
+ # MSan is supported on Linux, FreeBSD (modulo ASLR issue), and OpenBSD: https://clang.llvm.org/docs/MemorySanitizer.html#supported-platforms
+ if (sys == 'Linux') or (sys == 'OpenBSD'):
+-    config.available_features.add('MSan')
++    #config.available_features.add('MSan')
++    pass
+ 
+ # Add "Fuzzer" feature, assuming the compiler-rt library is available
+-config.available_features.add('Fuzzer')
++#config.available_features.add('Fuzzer')
+ 
+ if 'ASan' in config.available_features:
+     # On Darwin, ASan defaults to `abort_on_error=1`, which would make tests run

diff --git a/dev-lang/ldc2/files/ldc2-1.36.0-fix-phobos-OS-dependent-test-string.patch b/dev-lang/ldc2/files/ldc2-1.36.0-fix-phobos-OS-dependent-test-string.patch
new file mode 100644
index 0000000..5b67c5d
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-1.36.0-fix-phobos-OS-dependent-test-string.patch
@@ -0,0 +1,26 @@
+diff --git a/runtime/phobos/std/file.d b/runtime/phobos/std/file.d
+index 5b8925d..f1b19b3 100644
+--- a/runtime/phobos/std/file.d
++++ b/runtime/phobos/std/file.d
+@@ -1082,6 +1082,7 @@ private void removeImpl(scope const(char)[] name, scope const(FSChar)* namez) @t
+ 
+ @safe unittest
+ {
++    import std.algorithm.searching : startsWith;
+     import std.exception : collectExceptionMsg, assertThrown;
+ 
+     string filename = null; // e.g. as returned by File.tmpfile.name
+@@ -1090,12 +1091,10 @@ private void removeImpl(scope const(char)[] name, scope const(FSChar)* namez) @t
+     {
+         // exact exception message is OS-dependent
+         auto msg = filename.remove.collectExceptionMsg!FileException;
+-        assert("Failed to remove file (null): Bad address" == msg, msg);
++        assert(msg.startsWith("Failed to remove file (null):"), msg);
+     }
+     else version (Windows)
+     {
+-        import std.algorithm.searching : startsWith;
+-
+         // don't test exact message on windows, it's language dependent
+         auto msg = filename.remove.collectExceptionMsg!FileException;
+         assert(msg.startsWith("(null):"), msg);

diff --git a/dev-lang/ldc2/files/ldc2-1.36.0-lit-cfg-disable-gdb.patch b/dev-lang/ldc2/files/ldc2-1.36.0-lit-cfg-disable-gdb.patch
new file mode 100644
index 0000000..9809440
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-1.36.0-lit-cfg-disable-gdb.patch
@@ -0,0 +1,13 @@
+diff --git a/tests/lit.site.cfg.in b/tests/lit.site.cfg.in
+index 9b0b9c8..320a6d8 100644
+--- a/tests/lit.site.cfg.in
++++ b/tests/lit.site.cfg.in
+@@ -200,7 +200,7 @@ if (platform.system() == 'Windows') and os.path.isfile( cdb ):
+     config.substitutions.append( ('%cdb', '"' + cdb.replace('\\', '\\\\') + '"') )
+ 
+ # Check whether GDB is present
+-if (platform.system() != 'Windows') and lit.util.which('gdb', config.environment['PATH']):
++if False:
+     config.available_features.add('gdb')
+     gdb_dflags = ''
+     command = ['gdb', '--version']

diff --git a/dev-lang/ldc2/files/ldc2-1.36.0-tests-dshell-remove--m-switch.patch b/dev-lang/ldc2/files/ldc2-1.36.0-tests-dshell-remove--m-switch.patch
new file mode 100644
index 0000000..6c1180c
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-1.36.0-tests-dshell-remove--m-switch.patch
@@ -0,0 +1,13 @@
+diff --git a/tests/dmd/dshell/dll_cxx.d b/tests/dmd/dshell/dll_cxx.d
+index 77393ba331..b39ec0bc6a 100644
+--- a/tests/dmd/dshell/dll_cxx.d
++++ b/tests/dmd/dshell/dll_cxx.d
+@@ -45,7 +45,7 @@ int main()
+     }
+     else
+     {
+-        dllCmd ~= [ `-m` ~ Vars.MODEL, `-shared`, `-fPIC`, `-o`, Vars.DLL ];
++        dllCmd ~= [ `-shared`, `-fPIC`, `-o`, Vars.DLL ];
+         mainExtra = `-fPIC -L-L$OUTPUT_BASE -L$DLL -L-lstdc++ -L--no-demangle`;
+         if (environment.get("NO_ARCH_VARIANT", "") != "1")
+             dllCmd ~= `-m` ~ Vars.MODEL;

diff --git a/dev-lang/ldc2/files/ldc2-remove-dmd-common-int128-unittest.patch b/dev-lang/ldc2/files/ldc2-remove-dmd-common-int128-unittest.patch
new file mode 100644
index 0000000..bed0a83
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-remove-dmd-common-int128-unittest.patch
@@ -0,0 +1,17 @@
+diff --git a/dmd/common/int128.d b/dmd/common/int128.d
+index 796687b1f7..b020cf92ce 100644
+--- a/dmd/common/int128.d
++++ b/dmd/common/int128.d
+@@ -770,6 +770,7 @@ version (unittest)
+     }
+ }
+ 
++/+
+ unittest
+ {
+     const C0 = Zero;
+@@ -919,3 +920,4 @@ unittest
+     assert(rol(C7_9, 1) == rol1(C7_9));
+     assert(ror(C7_9, 1) == ror1(C7_9));
+ }
+++/

diff --git a/dev-lang/ldc2/ldc2-1.36.0-r2.ebuild b/dev-lang/ldc2/ldc2-1.36.0-r2.ebuild
index 84a0413..95fe554 100644
--- a/dev-lang/ldc2/ldc2-1.36.0-r2.ebuild
+++ b/dev-lang/ldc2/ldc2-1.36.0-r2.ebuild
@@ -3,7 +3,10 @@
 
 EAPI=8
 
-inherit flag-o-matic multilib-build cmake
+# Upstream supports LLVM 11.0 through 17.0.
+LLVM_COMPAT=( {15..17} )
+PYTHON_COMPAT=( python3_{10..12} )
+inherit cmake flag-o-matic llvm-r1 multilib-build multiprocessing python-any-r1 toolchain-funcs
 
 MY_PV="${PV//_/-}"
 MY_P="ldc-${MY_PV}-src"
@@ -18,14 +21,12 @@ LICENSE="BSD"
 # is an actual ABI bkreakage.
 SLOT="$(ver_cut 1-2)/$(ver_cut 3)"
 
-IUSE="static-libs"
-RESTRICT="test"
+IUSE="static-libs test"
+RESTRICT="!test? ( test )"
 
-# Upstream supports LLVM 11.0 through 17.0.
-LLVM_COMPAT=( {15..17} )
 DLANG_COMPAT=( dmd-2_{106..107} gdc-13 ldc2-1_{35..36} )
 
-inherit llvm-r1 dlang-single
+inherit dlang-single
 
 REQUIRED_USE=${DLANG_REQUIRED_USE}
 DEPEND="
@@ -33,15 +34,53 @@ DEPEND="
 	$(llvm_gen_dep '
 	  sys-devel/llvm:${LLVM_SLOT}=
 	')
+	net-misc/curl[${MULTILIB_USEDEP}]
 "
 IDEPEND=">=app-eselect/eselect-dlang-20140709"
 RDEPEND="
 	${DEPEND}
 	${IDEPEND}
 "
-BDEPEND=${DLANG_DEPS}
+BDEPEND="
+	${DLANG_DEPS}
+	test? (
+		  ${PYTHON_DEPS}
+		  $(python_gen_any_dep '
+			  dev-python/lit[${PYTHON_USEDEP}]
+		  ')
+	)
+"
+
+python_check_deps() {
+		python_has_version "dev-python/lit[${PYTHON_USEDEP}]"
+}
 
-PATCHES="${FILESDIR}/ldc2-1.15.0-link-defaultlib-shared.patch"
+PATCHES=(
+	"${FILESDIR}"/ldc2-1.15.0-link-defaultlib-shared.patch
+	"${FILESDIR}/${PN}"-1.36.0-disable-compiler-rt-sanitizers-tests.patch
+	"${FILESDIR}/${PN}"-1.36.0-lit-cfg-disable-gdb.patch
+
+	# https://github.com/dlang/phobos/pull/8956
+	"${FILESDIR}/${PN}"-1.36.0-fix-phobos-OS-dependent-test-string.patch
+	# https://github.com/ldc-developers/ldc/pull/4612
+	"${FILESDIR}/${PN}"-1.36.0-tests-dshell-remove--m-switch.patch
+	# https://github.com/ldc-developers/ldc/issues/4614#issuecomment-2034169152
+	"${FILESDIR}/${PN}"-remove-dmd-common-int128-unittest.patch
+)
+
+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
+
+	cmake_src_prepare
+}
 
 src_configure() {
 	# We disable assertions so we have to apply the same workaround as for
@@ -63,6 +102,89 @@ src_configure() {
 	cmake_src_configure
 }
 
+src_test()
+{
+	# Call the same tests that .github/actions/main.yml does
+
+	local jobs=$(get_makeopts_jobs)
+
+	### 4a-test-ldc2 ###
+
+	# We build it explicitly so that MAKEOPTS is respected
+	cmake_src_compile ldc2-unittest
+	cmake_src_test -R ldc2-unittest
+
+	### 4b-test-lit ###
+
+	# https://github.com/ldc-developers/ldc/pull/4611
+	sed -i '1 iREQUIRES: PGO_RT' "${S}"/tests/PGO/final_switch_release.d || die
+
+	if [[ ${ARCH} == x86 ]]; then
+		# Fails on x86 due to stack coruption unrelated to the test.
+		# It has been fixed since.
+		rm -f "${S}"/tests/codegen/mangling.d || die
+	fi
+
+	# 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
+
+	### 4c-test-dmd ###
+
+	# https://github.com/dlang/dmd/pull/16353
+	# Requires gdb but isn't named appropriately
+	mv "${S}"/tests/dmd/runnable/{,gdb-}b18504.d || die
+	# Calss gcc directly
+	sed -i "s/gcc/$(tc-getCC)/" "${S}"/tests/dmd/runnable/importc-test1.sh || die
+	# Fails on aarch64 due to int128
+	if [[ ${ARCH} == arm64 ]]; then
+		# https://github.com/dlang/dmd/pull/16352
+		rm -f "${S}"/tests/dmd/compilable/stdcheaders.c || die
+	fi
+
+	# 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 simultaniously 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
+
+	### 4d-test-libs ###
+
+	# 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 are the targets tested above
+		ldc2-unittest
+		lit-tests
+		dmd-testsuite
+
+		# These tests call gdb
+		druntime-test-exceptions
+		# Require valgrind
+		druntime-test-gc
+		druntime-test-valgrind
+
+		# 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
+
+		# Hangs with optimizations (or segfaults)
+		CMAKE_SKIP_TESTS+=( core.thread.fiber )
+		# fails due to "innacuracy"
+		CMAKE_SKIP_TESTS+=( std.internal.math.gammafunction )
+		# Bad code generation with optimizations?
+		CMAKE_SKIP_TESTS+=( std.math.exponential )
+	fi
+
+	cmake_src_test
+}
+
 src_install() {
 	cmake_src_install
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] repo/user/dlang:master commit in: dev-lang/ldc2/, dev-lang/ldc2/files/
@ 2024-07-05 18:19 Horodniceanu Andrei
  0 siblings, 0 replies; 2+ messages in thread
From: Horodniceanu Andrei @ 2024-07-05 18:19 UTC (permalink / raw
  To: gentoo-commits

commit:     0c9782ce5fe4b41cab39e44c0245eb95148a9c8d
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Fri Jul  5 17:51:11 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Fri Jul  5 17:51:28 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=0c9782ce

dev-lang/ldc2: remove github PRs from SRC_URI and put them in FILESDIR

pkgcheck has warned me that fetching them from github may lead to them
changing, which is exactly what happened leading to manifest failures.

I did it because I thought that, since the PR is closed and I'm the
author, the possibility of it changing is slim and the alternative was
to get a size violation warning from pkgcheck.

I have now learned why I shouldn't ignore pkgcheck errors and, if
commits need to be taken from upstream, I should keep their size to a
minimum and only backport commits that fix stuff, not commits which add
features.

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

 dev-lang/ldc2/Manifest                             |   3 -
 ...-autodetect-and-compiler-rt-fixes-pr-4659.patch | 585 +++++++++++++++++++++
 .../files/ldc2-x86-mangling-test-fix-pr-4661.patch |  55 ++
 ...x86-tests-avoid-calling-amd64-gcc-pr-4662.patch |  39 ++
 dev-lang/ldc2/ldc2-1.38.0.ebuild                   |  12 +-
 5 files changed, 683 insertions(+), 11 deletions(-)

diff --git a/dev-lang/ldc2/Manifest b/dev-lang/ldc2/Manifest
index a4a3083..0aa65e2 100644
--- a/dev-lang/ldc2/Manifest
+++ b/dev-lang/ldc2/Manifest
@@ -5,6 +5,3 @@ DIST ldc-1.35.0-src.tar.gz 8241960 BLAKE2B fb531841e57225f82cddf5135d0b0da98624d
 DIST ldc-1.36.0-src.tar.gz 8551871 BLAKE2B b0f09128ab37e332f2eebab3288cac687f91b696ba758d9ecd6fc4d98dc70d13e6fc4e02878028ac530cc9d9449d1148c8c3ed052fecfb18c95bd76437537467 SHA512 e8060ae30ddf659c51b2e57989b14f1d94c58537a3aa0c5afd3cf2906503d66421598014c33fdeb063a5aaea00034b4b11769a2c07cc2dabd7644840241183b4
 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 ldc2-pr-4659.patch 29459 BLAKE2B d4a24ea28d8ddca26924051973aa9ac27489c399849137996043fa8023ae43353fa80c8aa4cbe504b3cc1f45a7a25ec66b01a14dc072f37ea74286cf203fe7bf SHA512 d1a4fd76b3aa4a1527cf4434129918da821c52d74cdfb044c22e177db38fcbca692e1b597a2f2658c2bf26d6e581674637d4aa77cb464bf12535ba1161c6dced
-DIST ldc2-pr-4661.patch 2230 BLAKE2B 0819499e30b90c4089ae5f7295e67675def2579c374f40d0a0918f7563235768350c2b5ff9d32619f9f5c63ace1f7386a6fc3301f92b30d03bd39ddcefeb17cc SHA512 a3215efd1771ddf185ccbe360c66372d0f7cb450c0094c9b96e9df3bd5596dfb2cc9841e205076c339fd01e3864ab4a859074e836f7420b2856d1ee6062fe12c
-DIST ldc2-pr-4662.patch 1438 BLAKE2B e9f8027bba8723f766d33fc049058dd3206914a7cc0890bed361ceeff0a3c9684755cf6d70133409b57e54718855533c78f61d1b6af0e77532e5c7174409d696 SHA512 f35242fd2d97c7f40028b468b24bfb23d46a611d3bcc9aa58a63fe3c0aea19812bb5d9862927a3bd65d46a58fa0a61198df6d2b9f5cb894d92f1b9e7e385a4e8

diff --git a/dev-lang/ldc2/files/ldc2-cmake-autodetect-and-compiler-rt-fixes-pr-4659.patch b/dev-lang/ldc2/files/ldc2-cmake-autodetect-and-compiler-rt-fixes-pr-4659.patch
new file mode 100644
index 0000000..7af27a9
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-cmake-autodetect-and-compiler-rt-fixes-pr-4659.patch
@@ -0,0 +1,585 @@
+# A lot of unrelated work in one PR.
+# - It changes some wrong autodetection to lower to amount of stuff being
+# built.
+# - It better supports compiler-rt-sanitizers by handling the way they
+# are installed in Gentoo.
+# - It adds some more fixes for upstream which I didn't take out of the
+# the PR to keep it as is.
+From 58550bbd27e572d1706b04f39132d60c5c2797ac Mon Sep 17 00:00:00 2001
+From: Andrei Horodniceanu <a.horodniceanu@proton.me>
+Date: Wed, 15 May 2024 18:33:46 +0300
+Subject: [PATCH 1/6] utils/CMakeLists.txt: Fix typo split-filea => split-file
+
+Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
+---
+ utils/CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
+index 6b61a068373..379edf2c1b4 100644
+--- a/utils/CMakeLists.txt
++++ b/utils/CMakeLists.txt
+@@ -68,7 +68,7 @@ set_target_properties(
+ target_link_libraries(not  ${LLVM_LIBRARIES} ${CMAKE_DL_LIBS} ${LLVM_LDFLAGS})
+ endif()
+ 
+-if ((TARGET split-file) OR (EXISTS ${LLVM_ROOT_DIR}/bin/split-filea))
++if ((TARGET split-file) OR (EXISTS ${LLVM_ROOT_DIR}/bin/split-file))
+   # already provided by LLVM
+   message(STATUS "Skip building split-file, it is already provided by LLVM")
+ else()
+
+From 9b22e4a2b534fe4da54a02aadde486d9cc963574 Mon Sep 17 00:00:00 2001
+From: Andrei Horodniceanu <a.horodniceanu@proton.me>
+Date: Fri, 17 May 2024 23:12:58 +0300
+Subject: [PATCH 2/6] cmake: Add option to disable bundling ldc-profdata and
+ ldc-profgen
+
+Add the configure option LDC_BUNDLE_LLVM_TOOLS that can be used to
+disable packaging ldc-profdata and ldc-profgen. Since the users's llvm
+installation may contain these programs there should be a way to
+specify to ldc not to build them.
+
+Move the definitions for LDCPROF(DATA|GEN)_BIN from tests/ to tools/
+in order to handle this option.
+
+Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
+---
+ tests/CMakeLists.txt |  3 --
+ tools/CMakeLists.txt | 81 +++++++++++++++++++++++++-------------------
+ 2 files changed, 47 insertions(+), 37 deletions(-)
+
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index fc988f59560..f428d08b5de 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -1,6 +1,4 @@
+ set( LDC2_BIN          ${PROJECT_BINARY_DIR}/bin/${LDC_EXE} )
+-set( LDCPROFDATA_BIN   ${PROJECT_BINARY_DIR}/bin/ldc-profdata )
+-set( LDCPROFGEN_BIN    ${PROJECT_BINARY_DIR}/bin/ldc-profgen )
+ set( LDCPRUNECACHE_BIN ${PROJECT_BINARY_DIR}/bin/${LDCPRUNECACHE_EXE} )
+ set( LDCBUILDPLUGIN_BIN ${PROJECT_BINARY_DIR}/bin/${LDC_BUILD_PLUGIN_EXE} )
+ set( TIMETRACE2TXT_BIN ${PROJECT_BINARY_DIR}/bin/${TIMETRACE2TXT_EXE} )
+@@ -25,4 +23,3 @@ configure_file(runlit.py       runlit.py    COPYONLY)
+ add_test(NAME lit-tests
+     COMMAND ${PYTHON_EXE} runlit.py -v .
+ )
+-
+diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
+index facb939472d..ab147a9d029 100644
+--- a/tools/CMakeLists.txt
++++ b/tools/CMakeLists.txt
+@@ -1,6 +1,8 @@
+ # "tools" are supposed to be packaged with LDC.
+ # (in contrast to "utils" which are only used for building / testing)
+ 
++option(LDC_BUNDLE_LLVM_TOOLS "Build and install ldc-profgen and ldc-profdata utilities instead of using their llvm counterparts" TRUE)
++
+ #############################################################################
+ # Build ldc-prune-cache
+ set(LDCPRUNECACHE_EXE ldc-prune-cache)
+@@ -23,47 +25,58 @@ build_d_executable(
+ )
+ install(PROGRAMS ${LDCPRUNECACHE_EXE_FULL} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+ 
+-#############################################################################
+-# Build ldc-profdata for converting profile data formats (source version depends on LLVM version)
+-set(LDCPROFDATA_SRC ldc-profdata/llvm-profdata-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.cpp)
+-if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LDCPROFDATA_SRC})
+-    add_executable(ldc-profdata ${LDCPROFDATA_SRC})
+-    set_target_properties(
+-        ldc-profdata PROPERTIES
++if(LDC_BUNDLE_LLVM_TOOLS)
++  #############################################################################
++  # Build ldc-profdata for converting profile data formats (source version depends on LLVM version)
++  set(LDCPROFDATA_SRC ldc-profdata/llvm-profdata-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.cpp)
++  if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LDCPROFDATA_SRC})
++      add_executable(ldc-profdata ${LDCPROFDATA_SRC})
++      set_target_properties(
++	ldc-profdata PROPERTIES
++	RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
++	COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LDC_CXXFLAGS}"
++	LINK_FLAGS "${SANITIZE_LDFLAGS}"
++      )
++      target_link_libraries(ldc-profdata ${LLVM_LIBRARIES} ${CMAKE_DL_LIBS} ${LLVM_LDFLAGS})
++      install(TARGETS ldc-profdata DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
++
++      # Set path to executable, used by the lit testsuite.
++      set(LDCPROFDATA_BIN ${PROJECT_BINARY_DIR}/bin/ldc-profdata PARENT_SCOPE)
++  else()
++      message(WARNING "ldc-profdata source (${LDCPROFDATA_SRC}) not found")
++  endif()
++
++  #############################################################################
++  # Build ldc-profgen utility that generates a profile data file from given perf script
++  # data files for sample-based profile guided optimization (-fprofile-sample-use).
++  # https://llvm.org/docs/CommandGuide/llvm-profgen.html
++  # The source in ldc-profgen/ldc-profgen-xx.x is an unmodified copy of llvm's llvm-profgen source dir.
++  if(LDC_LLVM_VER GREATER_EQUAL 1400)
++    macro(add_llvm_tool llvm_name)
++      string(REPLACE "llvm-" "ldc-" ldc_name ${llvm_name})
++      message(STATUS "Configuring ${ldc_name} build target")
++      add_executable(${ldc_name} ${ARGN})
++      set_target_properties(
++        ${ldc_name} PROPERTIES
+         RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
+         COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LDC_CXXFLAGS}"
+         LINK_FLAGS "${SANITIZE_LDFLAGS}"
+-    )
+-    target_link_libraries(ldc-profdata ${LLVM_LIBRARIES} ${CMAKE_DL_LIBS} ${LLVM_LDFLAGS})
+-    install(TARGETS ldc-profdata DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+-else()
+-    message(WARNING "ldc-profdata source (${LDCPROFDATA_SRC}) not found")
+-endif()
+-
+-#############################################################################
+-# Build ldc-profgen utility that generates a profile data file from given perf script
+-# data files for sample-based profile guided optimization (-fprofile-sample-use).
+-# https://llvm.org/docs/CommandGuide/llvm-profgen.html
+-# The source in ldc-profgen/ldc-profgen-xx.x is an unmodified copy of llvm's llvm-profgen source dir.
+-if(LDC_LLVM_VER GREATER_EQUAL 1400)
+-    macro(add_llvm_tool llvm_name)
+-        string(REPLACE "llvm-" "ldc-" ldc_name ${llvm_name})
+-        message(STATUS "Configuring ${ldc_name} build target")
+-        add_executable(${ldc_name} ${ARGN})
+-        set_target_properties(
+-            ${ldc_name} PROPERTIES
+-            RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
+-            COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LDC_CXXFLAGS}"
+-            LINK_FLAGS "${SANITIZE_LDFLAGS}"
+-        )
+-        target_link_libraries(${ldc_name} ${LLVM_LIBRARIES} ${CMAKE_DL_LIBS} ${LLVM_LDFLAGS})
+-        install(TARGETS ${ldc_name} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
++      )
++      target_link_libraries(${ldc_name} ${LLVM_LIBRARIES} ${CMAKE_DL_LIBS} ${LLVM_LDFLAGS})
++      install(TARGETS ${ldc_name} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+     endmacro()
+     if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})
+-        add_subdirectory(ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})
++      add_subdirectory(ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})
++      # Set path to executable, potentially to be used by the lit tests in the future
++      set(LDCPROFGEN_BIN ${PROJECT_BINARY_DIR}/bin/ldc-profgen PARENT_SCOPE)
+     else()
+-        message(WARNING "ldc-profgen source not found (${CMAKE_CURRENT_SOURCE_DIR}/ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})")
++      message(WARNING "ldc-profgen source not found (${CMAKE_CURRENT_SOURCE_DIR}/ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})")
+     endif()
++  endif()
++else()
++  message(STATUS "Using llvm provided llvm-profdata and llvm-profgen")
++  set(LDCPROFDATA_BIN ${LLVM_ROOT_DIR}/bin/llvm-profdata PARENT_SCOPE)
++  set(LDCPROFGEN_BIN ${LLVM_ROOT_DIR}/bin/llvm-profgen PARENT_SCOPE)
+ endif()
+ 
+ #############################################################################
+
+From ddb6c8763c60261d88498a3a09ea8d62bde18ee6 Mon Sep 17 00:00:00 2001
+From: Andrei Horodniceanu <a.horodniceanu@proton.me>
+Date: Fri, 17 May 2024 23:19:03 +0300
+Subject: [PATCH 3/6] Support out-of-llvm compiler-rt installations
+
+Currently, the build systems assumes that the compiler-rt libraries
+are under the ${LLVM_LIBRARY_DIRS} directory. This is not always true,
+e.g on Gentoo they are installed in /usr/lib/clang/... This has been
+fixed by adding the COMPILER_RT_BASE_DIR option.
+
+Additionally the code for determining the os-specific compiler-rt
+directory has been slightly refactored and the option
+LDC_INSTALL_LLVM_RUNTIME_LIBS_OS has been renamed to
+COMPILER_RT_LIBDIR_OS since this value can now be used outside of
+LDC_INSTALL_LLVM_RUNTIME_LIBS.
+
+The configuration files (ldc2*.conf) have been modified to optionally
+embed a compiler-rt libdir in case the default search paths would not
+find the libraries.
+
+Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
+---
+ CMakeLists.txt       | 107 ++++++++++++++++++++++++++++---------------
+ ldc2.conf.in         |   2 +-
+ ldc2_install.conf.in |   2 +-
+ ldc2_phobos.conf.in  |   2 +-
+ 4 files changed, 72 insertions(+), 41 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index b1e41665c07..98bda6d8ce1 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -798,9 +798,38 @@ else()
+ endif()
+ 
+ #
+-# Locate ASan and other LLVM compiler-rt libraries, and copy them to our lib folder
+-# Location is LLVM_LIBRARY_DIRS/clang/<version>/lib/<OS>/ , for example LLVM_LIBRARY_DIRS/clang/4.0.0/lib/darwin/
+-#
++# Locate ASan and other LLVM compiler-rt libraries, and copy them to our lib
++# folder or save that folder in the config files. Location is typically
++# LLVM_LIBRARY_DIRS/clang/<version>/lib/<OS>/ , for example
++# LLVM_LIBRARY_DIRS/clang/4.0.0/lib/darwin/ , but we allow the user to specify
++# another directory.
++set(COMPILER_RT_BASE_DIR "${LLVM_LIBRARY_DIRS}" CACHE PATH "Base path of compiler-rt libraries. If they in are /usr/lib/clang/17/lib/linux/libclang_rt* you should set this value to /usr/lib")
++# If it's different than the default it will need to be added to the config files
++if(COMPILER_RT_BASE_DIR STREQUAL LLVM_LIBRARY_DIRS)
++    set(WANT_COMPILER_RT_LIBDIR_CONFIG FALSE)
++else()
++    set(WANT_COMPILER_RT_LIBDIR_CONFIG TRUE)
++endif()
++set(COMPILER_RT_LIBDIR "${COMPILER_RT_BASE_DIR}/clang")
++if(LDC_LLVM_VER LESS 1600)
++    set(COMPILER_RT_LIBDIR "${COMPILER_RT_LIBDIR}/${LLVM_VERSION_BASE_STRING}")
++else()
++    set(COMPILER_RT_LIBDIR "${COMPILER_RT_LIBDIR}/${LLVM_VERSION_MAJOR}")
++endif()
++set(COMPILER_RT_LIBDIR "${COMPILER_RT_LIBDIR}/lib")
++if(APPLE)
++    set(COMPILER_RT_LIBDIR "${COMPILER_RT_LIBDIR}/darwin")
++elseif(UNIX)
++    if(LDC_LLVM_VER LESS 1500)
++        set(COMPILER_RT_LIBDIR_OS_DEFAULT "linux")
++    else()
++        set(COMPILER_RT_LIBDIR_OS_DEFAULT "x86_64-unknown-linux-gnu")
++    endif()
++    set(COMPILER_RT_LIBDIR_OS "${COMPILER_RT_LIBDIR_OS_DEFAULT}"   CACHE STRING "Non-Mac Posix: OS used as directory name for the compiler-rt source libraries, e.g., 'freebsd'.")
++    set(COMPILER_RT_LIBDIR "${COMPILER_RT_LIBDIR}/${COMPILER_RT_LIBDIR_OS}")
++elseif(WIN32)
++    set(COMPILER_RT_LIBDIR "${COMPILER_RT_LIBDIR}/windows")
++endif()
+ if(LLVM_IS_SHARED)
+     set(LDC_INSTALL_LLVM_RUNTIME_LIBS_DEFAULT OFF)
+ else()
+@@ -808,11 +837,7 @@ else()
+ endif()
+ set(LDC_INSTALL_LLVM_RUNTIME_LIBS ${LDC_INSTALL_LLVM_RUNTIME_LIBS_DEFAULT} CACHE BOOL "Copy/install LLVM compiler-rt libraries (ASan, libFuzzer, ...) from LLVM/Clang into LDC lib dir when available.")
+ function(copy_compilerrt_lib llvm_lib_name ldc_lib_name fixup_dylib)
+-    if(LDC_LLVM_VER LESS 1600)
+-        set(llvm_lib_path ${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_BASE_STRING}/lib/${llvm_lib_name})
+-    else()
+-        set(llvm_lib_path ${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}/lib/${llvm_lib_name})
+-    endif()
++    set(llvm_lib_path ${COMPILER_RT_LIBDIR}/${llvm_lib_name})
+     if(EXISTS ${llvm_lib_path})
+         message(STATUS "--  - ${llvm_lib_path} --> ${ldc_lib_name}")
+         copy_and_install_llvm_library(${llvm_lib_path} ${ldc_lib_name} ${fixup_dylib})
+@@ -824,57 +849,63 @@ message(STATUS "-- Including LLVM compiler-rt libraries (LDC_INSTALL_LLVM_RUNTIM
+ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
+     # Locate LLVM sanitizer runtime libraries, and copy them to our lib folder
+ 
++    # No need to add another libdir, the default ldc one will have the libraries
++    set(WANT_COMPILER_RT_LIBDIR_CONFIG FALSE)
++
+     if(APPLE)
+-        copy_compilerrt_lib("darwin/libclang_rt.asan_osx_dynamic.dylib" "libldc_rt.asan.dylib" TRUE)
+-        copy_compilerrt_lib("darwin/libclang_rt.lsan_osx_dynamic.dylib" "libldc_rt.lsan.dylib" TRUE)
+-        copy_compilerrt_lib("darwin/libclang_rt.tsan_osx_dynamic.dylib" "libldc_rt.tsan.dylib" TRUE)
+-        copy_compilerrt_lib("darwin/libclang_rt.osx.a"                  "libldc_rt.builtins.a" FALSE)
+-        copy_compilerrt_lib("darwin/libclang_rt.profile_osx.a"          "libldc_rt.profile.a"  FALSE)
+-        copy_compilerrt_lib("darwin/libclang_rt.fuzzer_osx.a"           "libldc_rt.fuzzer.a"   FALSE)
+-        copy_compilerrt_lib("darwin/libclang_rt.xray_osx.a"             "libldc_rt.xray.a"     FALSE)
+-        copy_compilerrt_lib("darwin/libclang_rt.xray-basic_osx.a"      "libldc_rt.xray-basic.a"     FALSE)
+-        copy_compilerrt_lib("darwin/libclang_rt.xray-fdr_osx.a"        "libldc_rt.xray-fdr.a"       FALSE)
+-        copy_compilerrt_lib("darwin/libclang_rt.xray-profiling_osx.a"  "libldc_rt.xray-profiling.a" FALSE)
++        copy_compilerrt_lib("libclang_rt.asan_osx_dynamic.dylib" "libldc_rt.asan.dylib" TRUE)
++        copy_compilerrt_lib("libclang_rt.lsan_osx_dynamic.dylib" "libldc_rt.lsan.dylib" TRUE)
++        copy_compilerrt_lib("libclang_rt.tsan_osx_dynamic.dylib" "libldc_rt.tsan.dylib" TRUE)
++        copy_compilerrt_lib("libclang_rt.osx.a"                  "libldc_rt.builtins.a" FALSE)
++        copy_compilerrt_lib("libclang_rt.profile_osx.a"          "libldc_rt.profile.a"  FALSE)
++        copy_compilerrt_lib("libclang_rt.fuzzer_osx.a"           "libldc_rt.fuzzer.a"   FALSE)
++        copy_compilerrt_lib("libclang_rt.xray_osx.a"             "libldc_rt.xray.a"     FALSE)
++        copy_compilerrt_lib("libclang_rt.xray-basic_osx.a"      "libldc_rt.xray-basic.a"     FALSE)
++        copy_compilerrt_lib("libclang_rt.xray-fdr_osx.a"        "libldc_rt.xray-fdr.a"       FALSE)
++        copy_compilerrt_lib("libclang_rt.xray-profiling_osx.a"  "libldc_rt.xray-profiling.a" FALSE)
+     elseif(UNIX)
+         if(LDC_LLVM_VER LESS 1500)
+-            set(LDC_INSTALL_LLVM_RUNTIME_LIBS_OS_DEFAULT "linux")
+             set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT "x86_64")
+         else()
+-            set(LDC_INSTALL_LLVM_RUNTIME_LIBS_OS_DEFAULT "x86_64-unknown-linux-gnu")
+             set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT "")
+         endif()
+-        set(LDC_INSTALL_LLVM_RUNTIME_LIBS_OS   "${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS_DEFAULT}"   CACHE STRING "Non-Mac Posix: OS used as directory name for the compiler-rt source libraries, e.g., 'freebsd'.")
+-        set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH "${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT}" CACHE STRING "Non-Mac Posix: architecture used as libname suffix for the compiler-rt source libraries, e.g., 'aarch64'.")
++        set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH "${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT}" CACHE STRING
++	    "Non-Mac Posix: architecture used as libname suffix for the compiler-rt source libraries, e.g., 'aarch64'.")
+         if(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH STREQUAL "")
+             set(compilerrt_suffix "")
+         else()
+             set(compilerrt_suffix "-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}")
+         endif()
+ 
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.asan${compilerrt_suffix}.a"       "libldc_rt.asan.a"     FALSE)
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.lsan${compilerrt_suffix}.a"       "libldc_rt.lsan.a"     FALSE)
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.msan${compilerrt_suffix}.a"       "libldc_rt.msan.a"     FALSE)
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.tsan${compilerrt_suffix}.a"       "libldc_rt.tsan.a"     FALSE)
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.builtins${compilerrt_suffix}.a"   "libldc_rt.builtins.a" FALSE)
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.profile${compilerrt_suffix}.a"    "libldc_rt.profile.a"  FALSE)
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray${compilerrt_suffix}.a"       "libldc_rt.xray.a"     FALSE)
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.fuzzer${compilerrt_suffix}.a"     "libldc_rt.fuzzer.a"   FALSE)
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-basic${compilerrt_suffix}.a"      "libldc_rt.xray-basic.a"     FALSE)
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-fdr${compilerrt_suffix}.a"        "libldc_rt.xray-fdr.a"       FALSE)
+-        copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-profiling${compilerrt_suffix}.a"  "libldc_rt.xray-profiling.a" FALSE)
++        copy_compilerrt_lib("libclang_rt.asan${compilerrt_suffix}.a"           "libldc_rt.asan.a"     FALSE)
++        copy_compilerrt_lib("libclang_rt.lsan${compilerrt_suffix}.a"           "libldc_rt.lsan.a"     FALSE)
++        copy_compilerrt_lib("libclang_rt.msan${compilerrt_suffix}.a"           "libldc_rt.msan.a"     FALSE)
++        copy_compilerrt_lib("libclang_rt.tsan${compilerrt_suffix}.a"           "libldc_rt.tsan.a"     FALSE)
++        copy_compilerrt_lib("libclang_rt.builtins${compilerrt_suffix}.a"       "libldc_rt.builtins.a" FALSE)
++        copy_compilerrt_lib("libclang_rt.profile${compilerrt_suffix}.a"        "libldc_rt.profile.a"  FALSE)
++        copy_compilerrt_lib("libclang_rt.xray${compilerrt_suffix}.a"           "libldc_rt.xray.a"     FALSE)
++        copy_compilerrt_lib("libclang_rt.fuzzer${compilerrt_suffix}.a"         "libldc_rt.fuzzer.a"   FALSE)
++        copy_compilerrt_lib("libclang_rt.xray-basic${compilerrt_suffix}.a"     "libldc_rt.xray-basic.a"     FALSE)
++        copy_compilerrt_lib("libclang_rt.xray-fdr${compilerrt_suffix}.a"       "libldc_rt.xray-fdr.a"       FALSE)
++        copy_compilerrt_lib("libclang_rt.xray-profiling${compilerrt_suffix}.a" "libldc_rt.xray-profiling.a" FALSE)
+     elseif(WIN32)
+         set(compilerrt_arch_suffix "x86_64")
+         if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+             set(compilerrt_arch_suffix "i386")
+         endif()
+-        copy_compilerrt_lib("windows/clang_rt.asan-${compilerrt_arch_suffix}.lib"       "ldc_rt.asan.lib"     FALSE)
+-        copy_compilerrt_lib("windows/clang_rt.lsan-${compilerrt_arch_suffix}.lib"       "ldc_rt.lsan.lib"     FALSE)
+-        copy_compilerrt_lib("windows/clang_rt.builtins-${compilerrt_arch_suffix}.lib"   "ldc_rt.builtins.lib" FALSE)
+-        copy_compilerrt_lib("windows/clang_rt.profile-${compilerrt_arch_suffix}.lib"    "ldc_rt.profile.lib"  FALSE)
+-        copy_compilerrt_lib("windows/clang_rt.fuzzer-${compilerrt_arch_suffix}.lib"     "ldc_rt.fuzzer.lib"   FALSE)
++        copy_compilerrt_lib("clang_rt.asan-${compilerrt_arch_suffix}.lib"     "ldc_rt.asan.lib"     FALSE)
++        copy_compilerrt_lib("clang_rt.lsan-${compilerrt_arch_suffix}.lib"     "ldc_rt.lsan.lib"     FALSE)
++        copy_compilerrt_lib("clang_rt.builtins-${compilerrt_arch_suffix}.lib" "ldc_rt.builtins.lib" FALSE)
++        copy_compilerrt_lib("clang_rt.profile-${compilerrt_arch_suffix}.lib"  "ldc_rt.profile.lib"  FALSE)
++        copy_compilerrt_lib("clang_rt.fuzzer-${compilerrt_arch_suffix}.lib"   "ldc_rt.fuzzer.lib"   FALSE)
+     endif()
+ endif()
+ 
++if(WANT_COMPILER_RT_LIBDIR_CONFIG)
++    message(STATUS "Adding ${COMPILER_RT_LIBDIR} to libdir in configuration files")
++    set(OPTIONAL_COMPILER_RT_DIR "\n        \"${COMPILER_RT_LIBDIR}\",")
++endif()
++
+ #
+ # Auxiliary build and test utils.
+ #
+diff --git a/ldc2.conf.in b/ldc2.conf.in
+index 1ec4ce854c4..0ef4caa07a2 100644
+--- a/ldc2.conf.in
++++ b/ldc2.conf.in
+@@ -28,7 +28,7 @@ default:
+     ];
+     // default directories to be searched for libraries when linking
+     lib-dirs = [
+-        "@CMAKE_BINARY_DIR@/lib@LIB_SUFFIX@",
++        "@CMAKE_BINARY_DIR@/lib@LIB_SUFFIX@",@OPTIONAL_COMPILER_RT_DIR@
+     ];
+     // default rpath when linking against the shared default libs
+     rpath = "@SHARED_LIBS_RPATH@";
+diff --git a/ldc2_install.conf.in b/ldc2_install.conf.in
+index 7536f8f0d4f..f8afa42613c 100644
+--- a/ldc2_install.conf.in
++++ b/ldc2_install.conf.in
+@@ -26,7 +26,7 @@ default:
+     ];
+     // default directories to be searched for libraries when linking
+     lib-dirs = [
+-        "@CMAKE_INSTALL_LIBDIR@",
++        "@CMAKE_INSTALL_LIBDIR@",@OPTIONAL_COMPILER_RT_DIR@
+     ];
+     // default rpath when linking against the shared default libs
+     rpath = "@SHARED_LIBS_INSTALL_RPATH@";
+diff --git a/ldc2_phobos.conf.in b/ldc2_phobos.conf.in
+index 9bc5b1aa484..f2c00634f16 100644
+--- a/ldc2_phobos.conf.in
++++ b/ldc2_phobos.conf.in
+@@ -29,7 +29,7 @@ default:
+     ];
+     // default directories to be searched for libraries when linking
+     lib-dirs = [
+-        "@CMAKE_BINARY_DIR@/lib@LIB_SUFFIX@",
++        "@CMAKE_BINARY_DIR@/lib@LIB_SUFFIX@",@OPTIONAL_COMPILER_RT_DIR@
+     ];
+     // default rpath when linking against the shared default libs
+     rpath = "@SHARED_LIBS_RPATH@";
+
+From 25d3243a35761bd520a31732913923c366fdfa1a Mon Sep 17 00:00:00 2001
+From: Andrei Horodniceanu <a.horodniceanu@proton.me>
+Date: Sat, 18 May 2024 00:58:03 +0300
+Subject: [PATCH 4/6] tests/CMakeLists.txt: Add option for controlling
+ compiler-rt tests
+
+https://github.com/ldc-developers/ldc/pull/4636 and
+https://github.com/ldc-developers/ldc/pull/4638 added some checks when
+deciding if tests that require certain compiler-rt libraries will be
+run. They uses globbing to determine if the library files exist. This
+is insufficient as the compiler-rt libs can be in directories other
+than the ldc2 libdir. Globbing also has the downside of tests being
+silently skipped when the failure to find the libraries should have
+been vocal.
+
+To solve this the TEST_COMPILER_RT_LIBRARIES option has been added to
+control which compiler-rt dependent tests will be run.
+
+Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
+---
+ tests/CMakeLists.txt           |  7 +++++++
+ tests/PGO/lit.local.cfg        |  6 ++----
+ tests/instrument/lit.local.cfg |  6 ++----
+ tests/lit.site.cfg.in          |  1 +
+ tests/sanitizers/lit.local.cfg | 15 +++++++--------
+ 5 files changed, 19 insertions(+), 16 deletions(-)
+
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index f428d08b5de..39be385f5d6 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -11,6 +11,13 @@ if(WIN32)
+     set(PYTHON_EXE python)
+ endif()
+ 
++set(TEST_COMPILER_RT_LIBRARIES "all" CACHE STRING "List of compiler-rt libraries to test, separated by ';'. Can be set to 'all' and 'none'")
++if(TEST_COMPILER_RT_LIBRARIES STREQUAL "all")
++    set(TEST_COMPILER_RT_LIBRARIES "profile;xray;lsan;tsan;asan;msan;fuzzer")
++elseif(TEST_COMPILER_RT_LIBRARIES STREQUAL "none")
++    set(TEST_COMPILER_RT_LIBRARIES "")
++endif()
++
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+     set( DEFAULT_TARGET_BITS 64 )
+ else()
+diff --git a/tests/PGO/lit.local.cfg b/tests/PGO/lit.local.cfg
+index d63318065a8..466a9bad6da 100644
+--- a/tests/PGO/lit.local.cfg
++++ b/tests/PGO/lit.local.cfg
+@@ -1,5 +1,3 @@
+-from glob import glob
+-
+-# Add "PGO_RT" feature, if the `profile` compiler-rt library is available
+-if glob(os.path.join(config.ldc2_lib_dir, "*profile*")):
++# Add "PGO_RT" feature
++if 'profile' in config.enabled_rt_libs:
+     config.available_features.add('PGO_RT')
+diff --git a/tests/instrument/lit.local.cfg b/tests/instrument/lit.local.cfg
+index e97afbfa4bc..71968d9cd78 100644
+--- a/tests/instrument/lit.local.cfg
++++ b/tests/instrument/lit.local.cfg
+@@ -1,7 +1,5 @@
+ import platform
+-from glob import glob
+-
+-# Add "XRay_RT" feature on non-Windows, if the compiler-rt libraries are available
++# Add "XRay_RT" feature on non-Windows
+ if (platform.system() != 'Windows'):
+-    if glob(os.path.join(config.ldc2_lib_dir, "*xray*")):
++    if 'xray' in config.enabled_rt_libs:
+         config.available_features.add('XRay_RT')
+diff --git a/tests/lit.site.cfg.in b/tests/lit.site.cfg.in
+index 1e966a78805..4aa1a8294cc 100644
+--- a/tests/lit.site.cfg.in
++++ b/tests/lit.site.cfg.in
+@@ -37,6 +37,7 @@ config.ldc_host_arch       = "@LLVM_NATIVE_ARCH@"
+ config.ldc_with_lld        = @LDC_WITH_LLD@
+ config.spirv_enabled       = @LLVM_SPIRV_FOUND@
+ config.rt_supports_sanitizers = @RT_SUPPORT_SANITIZERS@
++config.enabled_rt_libs        = set("@TEST_COMPILER_RT_LIBRARIES@".split(';'))
+ config.shared_rt_libs_only = "@BUILD_SHARED_LIBS@" == "ON"
+ 
+ config.name = 'LDC'
+diff --git a/tests/sanitizers/lit.local.cfg b/tests/sanitizers/lit.local.cfg
+index 82e35e28dd0..bdac8304b84 100644
+--- a/tests/sanitizers/lit.local.cfg
++++ b/tests/sanitizers/lit.local.cfg
+@@ -1,32 +1,31 @@
+ import os
+ import platform
+-from glob import glob
+ 
+ sys = platform.system()
+ 
+-# Add "LSan" feature, if the compiler-rt library is available
+-if glob(os.path.join(config.ldc2_lib_dir, "*lsan*")):
++# Add "LSan" feature
++if 'lsan' in config.enabled_rt_libs:
+     config.available_features.add('LSan')
+ 
+ # FreeBSD TSan doesn't seem to work,
+ # Linux TSan currently only works with static druntime,
+ # and there's no Windows TSan (yet?).
+ if (sys != 'FreeBSD') and (sys != 'Windows') and not (sys == 'Linux' and config.shared_rt_libs_only):
+-    if glob(os.path.join(config.ldc2_lib_dir, "*tsan*")):
++    if 'tsan' in config.enabled_rt_libs:
+         config.available_features.add('TSan')
+ 
+ # FreeBSD ASan and MSan don't cope well with ASLR (might do with FreeBSD 14 according to https://github.com/llvm/llvm-project/pull/73439)
+ if sys != 'FreeBSD':
+-    if glob(os.path.join(config.ldc2_lib_dir, "*asan*")):
++    if 'asan' in config.enabled_rt_libs:
+         config.available_features.add('ASan')
+ 
+ # MSan is supported on Linux, FreeBSD (modulo ASLR issue), and OpenBSD: https://clang.llvm.org/docs/MemorySanitizer.html#supported-platforms
+ if (sys == 'Linux') or (sys == 'OpenBSD'):
+-    if glob(os.path.join(config.ldc2_lib_dir, "*msan*")):
++    if 'msan' in config.enabled_rt_libs:
+         config.available_features.add('MSan')
+ 
+-# Add "Fuzzer" feature, assuming the compiler-rt library is available
+-if glob(os.path.join(config.ldc2_lib_dir, "*fuzzer*")):
++# Add "Fuzzer" feature
++if 'fuzzer' in config.enabled_rt_libs:
+     config.available_features.add('Fuzzer')
+ 
+ if 'ASan' in config.available_features:
+
+From 46e41aebfec7d5657a9824e05acaa97f87bafa58 Mon Sep 17 00:00:00 2001
+From: Andrei Horodniceanu <a.horodniceanu@proton.me>
+Date: Sat, 18 May 2024 04:25:28 +0300
+Subject: [PATCH 5/6] utils/CMakeLists.txt: Build split-file if llvm is too old
+
+Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
+---
+ utils/CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
+index 379edf2c1b4..abb6312f5b7 100644
+--- a/utils/CMakeLists.txt
++++ b/utils/CMakeLists.txt
+@@ -68,7 +68,7 @@ set_target_properties(
+ target_link_libraries(not  ${LLVM_LIBRARIES} ${CMAKE_DL_LIBS} ${LLVM_LDFLAGS})
+ endif()
+ 
+-if ((TARGET split-file) OR (EXISTS ${LLVM_ROOT_DIR}/bin/split-file))
++if ((TARGET split-file) OR (EXISTS ${LLVM_ROOT_DIR}/bin/split-file AND ${LLVM_VERSION_MAJOR} GREATER_EQUAL 14))
+   # already provided by LLVM
+   message(STATUS "Skip building split-file, it is already provided by LLVM")
+ else()
+
+From cff48ff2b462f2fe4004e6f2dea29744f8b5fa26 Mon Sep 17 00:00:00 2001
+From: Andrei Horodniceanu <a.horodniceanu@proton.me>
+Date: Sat, 18 May 2024 04:27:33 +0300
+Subject: [PATCH 6/6] ci: rename LDC_INSTALL_LLVM_RUNTIME_LIBS_OS to
+ COMPILER_RT_LIBDIR_OS
+
+Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
+---
+ .cirrus.yml                | 2 +-
+ .github/workflows/main.yml | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/.cirrus.yml b/.cirrus.yml
+index c2263856d93..4b4d0689c51 100644
+--- a/.cirrus.yml
++++ b/.cirrus.yml
+@@ -248,7 +248,7 @@ task:
+       -DEXTRA_CXXFLAGS=-flto=full
+       -DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++
+       -DJITRT_EXTRA_LDFLAGS=-static-libstdc++
+-      -DLDC_INSTALL_LLVM_RUNTIME_LIBS_OS=aarch64-unknown-linux-gnu
++      -DCOMPILER_RT_LIBDIR_OS=aarch64-unknown-linux-gnu
+       -DLLVM_ROOT_DIR=$CIRRUS_WORKING_DIR/../llvm
+       -DD_COMPILER=$CIRRUS_WORKING_DIR/../bootstrap-ldc/bin/ldmd2
+     PARALLELISM: 4
+diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
+index bb2474f1fa3..166f00739f1 100644
+--- a/.github/workflows/main.yml
++++ b/.github/workflows/main.yml
+@@ -188,7 +188,7 @@ jobs:
+             arch: aarch64
+             android_x86_arch: x86_64
+             extra_cmake_flags: >-
+-              -DLDC_INSTALL_LLVM_RUNTIME_LIBS_OS=linux
++              -DCOMPILER_RT_LIBDIR_OS=linux
+               -DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=aarch64-android
+ 
+     name: ${{ matrix.job_name }}

diff --git a/dev-lang/ldc2/files/ldc2-x86-mangling-test-fix-pr-4661.patch b/dev-lang/ldc2/files/ldc2-x86-mangling-test-fix-pr-4661.patch
new file mode 100644
index 0000000..522021a
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-x86-mangling-test-fix-pr-4661.patch
@@ -0,0 +1,55 @@
+From 27758f2a20849fe2a6b1c20f44451d1cc58ed232 Mon Sep 17 00:00:00 2001
+From: Andrei Horodniceanu <a.horodniceanu@proton.me>
+Date: Sat, 18 May 2024 22:40:49 +0300
+Subject: [PATCH] tests/codegen/mangling.d: change argument type of naked_dFunc
+ to int
+
+Avoid issues on x86 with the calling convention by having an int
+argument, which can be passed through a register, therefore, lifting
+the burden of cleaning the stack, instead of a double.
+
+Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
+---
+ tests/codegen/inputs/mangling_definitions.d | 6 ++++--
+ tests/codegen/mangling.d                    | 6 +++---
+ 2 files changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/tests/codegen/inputs/mangling_definitions.d b/tests/codegen/inputs/mangling_definitions.d
+index 6234999bfc4..a6ed0fec9e8 100644
+--- a/tests/codegen/inputs/mangling_definitions.d
++++ b/tests/codegen/inputs/mangling_definitions.d
+@@ -46,6 +46,8 @@ version(AsmX86)
+     else
+         static assert(naked_cppFunc.mangleof == "_ZN15cpp_naked_funcs13naked_cppFuncEd");
+ 
+-    int naked_dFunc(double a) { asm { naked; ret; } }
+-    static assert(naked_dFunc.mangleof == "_D11definitions11naked_dFuncFdZi");
++    // Pass an int instead of a double due to x86 calling convetion
++    // See: https://github.com/ldc-developers/ldc/pull/4661
++    int naked_dFunc(int a) { asm { naked; ret; } }
++    static assert(naked_dFunc.mangleof == "_D11definitions11naked_dFuncFiZi");
+ }
+diff --git a/tests/codegen/mangling.d b/tests/codegen/mangling.d
+index d79793192a6..054d4d79926 100644
+--- a/tests/codegen/mangling.d
++++ b/tests/codegen/mangling.d
+@@ -61,8 +61,8 @@ version(AsmX86)
+     extern(C++, decl_cpp_naked_funcs) pragma(mangle, nakedCppFuncMangle)
+     int decl_naked_cppFunc(double a);
+ 
+-    pragma(mangle, "_D11definitions11naked_dFuncFdZi")
+-    int decl_naked_dFunc(double a);
++    pragma(mangle, "_D11definitions11naked_dFuncFiZi")
++    int decl_naked_dFunc(int a);
+ }
+ 
+ // Interfacing with C via pragma(mangle, …), without having to take care
+@@ -84,7 +84,7 @@ void main()
+     {
+         decl_naked_cFunc(1.0);
+         decl_naked_cppFunc(2.0);
+-        decl_naked_dFunc(3.0);
++        decl_naked_dFunc(3);
+     }
+ 
+     assert(decl_cos(0.0) == 1.0);

diff --git a/dev-lang/ldc2/files/ldc2-x86-tests-avoid-calling-amd64-gcc-pr-4662.patch b/dev-lang/ldc2/files/ldc2-x86-tests-avoid-calling-amd64-gcc-pr-4662.patch
new file mode 100644
index 0000000..252d8f1
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-x86-tests-avoid-calling-amd64-gcc-pr-4662.patch
@@ -0,0 +1,39 @@
+From 4b4da9f718f590301fb39f6c2acb109caa801acb Mon Sep 17 00:00:00 2001
+From: Andrei Horodniceanu <a.horodniceanu@proton.me>
+Date: Sun, 19 May 2024 02:06:22 +0300
+Subject: [PATCH] tests/codegen/casm.c: Move to casm.i
+
+Don't call the C preprocessor as it may fail in a cross-compilation
+environment. Drop the `-mtriple` argument and let the test run on all
+platforms.
+
+Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
+---
+ tests/codegen/casm.c | 6 ------
+ tests/codegen/casm.i | 4 ++++
+ 2 files changed, 4 insertions(+), 6 deletions(-)
+ delete mode 100644 tests/codegen/casm.c
+ create mode 100644 tests/codegen/casm.i
+
+diff --git a/tests/codegen/casm.c b/tests/codegen/casm.c
+deleted file mode 100644
+index 5a34f6d00b0..00000000000
+--- a/tests/codegen/casm.c
++++ /dev/null
+@@ -1,6 +0,0 @@
+-// REQUIRES: target_X86
+-// UNSUPPORTED: Windows
+-// RUN: %ldc -mtriple=x86_64-freebsd13 -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
+-
+-// CHECK: module asm ".symver __qsort_r_compat, qsort_r@FBSD_1.0"
+-__asm__(".symver " "__qsort_r_compat" ", " "qsort_r" "@" "FBSD_1.0");
+diff --git a/tests/codegen/casm.i b/tests/codegen/casm.i
+new file mode 100644
+index 00000000000..33b0be8ee73
+--- /dev/null
++++ b/tests/codegen/casm.i
+@@ -0,0 +1,4 @@
++// RUN: %ldc -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
++
++// CHECK: module asm ".symver __qsort_r_compat, qsort_r@FBSD_1.0"
++asm(".symver " "__qsort_r_compat" ", " "qsort_r" "@" "FBSD_1.0");

diff --git a/dev-lang/ldc2/ldc2-1.38.0.ebuild b/dev-lang/ldc2/ldc2-1.38.0.ebuild
index d8ef981..aeaae13 100644
--- a/dev-lang/ldc2/ldc2-1.38.0.ebuild
+++ b/dev-lang/ldc2/ldc2-1.38.0.ebuild
@@ -12,12 +12,7 @@ DESCRIPTION="LLVM D Compiler"
 HOMEPAGE="https://github.com/ldc-developers/ldc"
 MY_PV="${PV//_/-}"
 MY_P="ldc-${MY_PV}-src"
-PR_URL="https://github.com/ldc-developers/ldc/pull"
-SRC_URI="https://github.com/ldc-developers/ldc/releases/download/v${MY_PV}/${MY_P}.tar.gz
-	${PR_URL}/4659.patch -> ${PN}-pr-4659.patch
-	${PR_URL}/4661.patch -> ${PN}-pr-4661.patch
-	${PR_URL}/4662.patch -> ${PN}-pr-4662.patch
-"
+SRC_URI="https://github.com/ldc-developers/ldc/releases/download/v${MY_PV}/${MY_P}.tar.gz"
 S=${WORKDIR}/${MY_P}
 LICENSE="BSD"
 # dmd code + runtime lib
@@ -73,6 +68,9 @@ PATCHES=(
 	"${FILESDIR}/${PN}"-1.36.0-fix-phobos-OS-dependent-test-string.patch
 	# https://github.com/ldc-developers/ldc/issues/4614#issuecomment-2034169152
 	"${FILESDIR}/${PN}"-remove-dmd-common-int128-unittest.patch
+	"${FILESDIR}/${PN}"-cmake-autodetect-and-compiler-rt-fixes-pr-4659.patch
+	"${FILESDIR}/${PN}"-x86-mangling-test-fix-pr-4661.patch
+	"${FILESDIR}/${PN}"-x86-tests-avoid-calling-amd64-gcc-pr-4662.patch
 )
 
 pkg_setup() {
@@ -86,8 +84,6 @@ src_prepare(){
 	# Put this here to avoid trigerring reconfigurations later on.
 	sed -i 's/\(GDB_FLAGS=\)\S\+/\1OFF/' "${S}"/tests/dmd/CMakeLists.txt
 
-	eapply "${DISTDIR}/${PN}-pr-"{4659,4661,4662}".patch"
-
 	cmake_src_prepare
 }
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-05 18:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-13 23:04 [gentoo-commits] repo/user/dlang:master commit in: dev-lang/ldc2/, dev-lang/ldc2/files/ Horodniceanu Andrei
  -- strict thread matches above, loose matches on Subject: below --
2024-07-05 18:19 Horodniceanu Andrei

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