aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Horodniceanu <a.horodniceanu@proton.me>2024-07-05 20:51:11 +0300
committerAndrei Horodniceanu <a.horodniceanu@proton.me>2024-07-05 20:51:28 +0300
commit0c9782ce5fe4b41cab39e44c0245eb95148a9c8d (patch)
treee346344c8201ede808f203f2c74de3e0ef169e6c
parentx11-terms/tilix: enable gdc-14 (diff)
downloaddlang-0c9782ce5fe4b41cab39e44c0245eb95148a9c8d.tar.gz
dlang-0c9782ce5fe4b41cab39e44c0245eb95148a9c8d.tar.bz2
dlang-0c9782ce5fe4b41cab39e44c0245eb95148a9c8d.zip
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@proton.me>
-rw-r--r--dev-lang/ldc2/Manifest3
-rw-r--r--dev-lang/ldc2/files/ldc2-cmake-autodetect-and-compiler-rt-fixes-pr-4659.patch585
-rw-r--r--dev-lang/ldc2/files/ldc2-x86-mangling-test-fix-pr-4661.patch55
-rw-r--r--dev-lang/ldc2/files/ldc2-x86-tests-avoid-calling-amd64-gcc-pr-4662.patch39
-rw-r--r--dev-lang/ldc2/ldc2-1.38.0.ebuild12
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
}