summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorJonas Meeuws <jonas.meeuws@gmail.com>2026-08-02 21:47:32 +0200
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2026-08-22 16:49:15 +0200
commit6f6e3abf8d105660c2958a670da41d59e138271d (patch)
tree6e1f4fd87bd3a9757d05e45741c58ed6b3324b29 /gnu
parent2658c53e40ef5a0178b2b66b430a9eb6f98fc95e (diff)
gnu: ldc: Improve packaging.
* gnu/packages/dlang.scm (ldc-bootstrap)[source] <patches>: Add “ldc-phobos-support-TZDIR.patch”. [#:configure-flags]: Add “-DCMAKE_INSTALL_RPATH” and “-DINCLUDE_INSTALL_DIR”. [#:build-type]: Change to “Debug”. [#:phases]: Add target-bin-sh, target-bin-clang, target-clang-runtime, target-lib-curl, native-bin-clang and native-bin-clang++ helpers. <patch-default-cc, patch-importc-float128, patch-paths-in-phobos> <patch-getInstalledTZNames-infinite-symlink, create-lib-output>: New phases. <patch-compiler-rt-library-discover>: Adjust accordingly. <disable-problematic-tests>: Rename to… <patch-tests>: … this. Enable more tests. <set-cc-and-cxx-to-use-clang>: Rename to… <set-cc>: … this. Use native-bin-clang and native-bin-clang++. <check>: Define run-tests helper and use it. [inputs]: Add ‘clang-runtime-18’, ‘libconfig’, ‘llvm-18’, ‘clang’ and ‘curl’. [native-inputs]: Remove ‘make-lld-wrapper’ and ‘unzip’. Replace ‘clang-17’ with ‘clang’. Add ’lld-as-ld-wrapper’, ‘ld-gold-wrapper’ and ‘gdb’. [description]: Replace with a modern description. Add a frontend version note. [license]: Update comment with druntime and phobos licensing info. [properties]<max-silent-time>: Only apply this ARMv7-specific timeout to arm32. (ldc)[#:make-flags]: Remove. [#:disallowed-references]: Add ‘gdmd’ and ‘tzdata-for-tests’. [#:configure-flags]: Remove deletion of “-DBUILD_SHARED_LIBS=OFF”. Remove “-DBUILD_SHARED_LIBS=ON” (is the default). Add deletion of “-DD_COMPILER_FLAGS=-fPIC” TODO needed?. [#:build-type]: Set to “RelWithDebInfo”. [native-inputs]: Run ‘modify-inputs’ on ‘package-native-inputs’ of ‘base’ instead. * gnu/packages/patches/ldc-phobos-support-TZDIR.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
Diffstat (limited to 'gnu')
-rw-r--r--gnu/local.mk3
-rw-r--r--gnu/packages/dlang.scm494
-rw-r--r--gnu/packages/patches/ldc-phobos-support-TZDIR.patch42
3 files changed, 350 insertions, 189 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 836a8d60200..10ab386e580 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1783,7 +1783,8 @@ dist_patch_DATA = \
1783 %D%/packages/patches/kwin-unwrap-executable-name-for-dot-desktop-search.patch\ 1783 %D%/packages/patches/kwin-unwrap-executable-name-for-dot-desktop-search.patch\
1784 %D%/packages/patches/laby-make-install.patch \ 1784 %D%/packages/patches/laby-make-install.patch \
1785 %D%/packages/patches/laby-use-tmpdir-from-runtime.patch \ 1785 %D%/packages/patches/laby-use-tmpdir-from-runtime.patch \
1786 %D%/packages/patches/ldc-i686-int128-alignment.patch \ 1786 %D%/packages/patches/ldc-i686-int128-alignment.patch \
1787 %D%/packages/patches/ldc-phobos-support-TZDIR.patch \
1787 %D%/packages/patches/ldns-drill-examples.patch \ 1788 %D%/packages/patches/ldns-drill-examples.patch \
1788 %D%/packages/patches/leela-zero-gtest.patch \ 1789 %D%/packages/patches/leela-zero-gtest.patch \
1789 %D%/packages/patches/less-hurd-path-max.patch \ 1790 %D%/packages/patches/less-hurd-path-max.patch \
diff --git a/gnu/packages/dlang.scm b/gnu/packages/dlang.scm
index e65fca79399..03f1a05febb 100644
--- a/gnu/packages/dlang.scm
+++ b/gnu/packages/dlang.scm
@@ -35,6 +35,7 @@
35 #:use-module (guix gexp) 35 #:use-module (guix gexp)
36 #:use-module (guix utils) 36 #:use-module (guix utils)
37 #:use-module ((guix build utils) #:hide (delete which)) 37 #:use-module ((guix build utils) #:hide (delete which))
38 #:use-module (guix build-system)
38 #:use-module (guix build-system gnu) 39 #:use-module (guix build-system gnu)
39 #:use-module (guix build-system cmake) 40 #:use-module (guix build-system cmake)
40 #:use-module (guix build-system copy) 41 #:use-module (guix build-system copy)
@@ -65,8 +66,6 @@
65 66
66;; LLVM-based D compiler 67;; LLVM-based D compiler
67 68
68;; We use GDC, the D frontend for GCC, to bootstrap ldc. We then use
69;; ldc to bootstrap itself so that no reference remains to GDC.
70(define-public ldc-bootstrap 69(define-public ldc-bootstrap
71 (package 70 (package
72 (name "ldc") 71 (name "ldc")
@@ -84,7 +83,8 @@
84 (sha256 83 (sha256
85 (base32 84 (base32
86 "068gqv368mhi9jywk9dcx9xssywcix5ypixxs9hi87cz3w913xbp")) 85 "068gqv368mhi9jywk9dcx9xssywcix5ypixxs9hi87cz3w913xbp"))
87 (patches (search-patches "ldc-i686-int128-alignment.patch")))) 86 (patches (search-patches "ldc-i686-int128-alignment.patch"
87 "ldc-phobos-support-TZDIR.patch"))))
88 (build-system cmake-build-system) 88 (build-system cmake-build-system)
89 (arguments 89 (arguments
90 (list 90 (list
@@ -96,226 +96,343 @@
96 #:configure-flags 96 #:configure-flags
97 #~(list "-DD_COMPILER_FLAGS=-fPIC" 97 #~(list "-DD_COMPILER_FLAGS=-fPIC"
98 "-DBUILD_SHARED_LIBS=OFF" ; see .github/actions/2-build-bootstrap 98 "-DBUILD_SHARED_LIBS=OFF" ; see .github/actions/2-build-bootstrap
99 (format #f "-DCMAKE_INSTALL_RPATH=~a/lib"
100 (assoc-ref %outputs "lib"))
99 #$@(if (target-riscv64?) 101 #$@(if (target-riscv64?)
100 #~("-DCMAKE_EXE_LINKER_FLAGS=-latomic") 102 #~(("-DCMAKE_EXE_LINKER_FLAGS=-latomic"))
101 #~())) 103 #~())
102 #:build-type "Release" 104 (format #f "-DINCLUDE_INSTALL_DIR=~a/include/d/ldc"
105 (assoc-ref %outputs "out")))
106 #:build-type "Debug"
103 #:make-flags #~(list "all") ; used as build targets 107 #:make-flags #~(list "all") ; used as build targets
104 #:tests? #f ; skip in the bootstrap 108 #:tests? #f ; skip in the bootstrap
105 #:phases 109 #:phases
106 (let* ((target-file 110 (let* ((target-file
107 (lambda (pkg path) 111 (lambda (pkg path)
108 (file-append (this-package-input pkg) path))) 112 (file-append (this-package-input pkg) path)))
109 (target-bin-sh (target-file "bash-minimal" "/bin/sh"))) 113 (native-file
114 (lambda (pkg path)
115 (file-append (this-package-native-input pkg) path)))
116 (target-bin-sh (target-file "bash-minimal" "/bin/sh"))
117 (target-bin-clang (target-file "clang" "/bin/clang"))
118 (target-clang-runtime (target-file "clang-runtime" ""))
119 (target-lib-curl (target-file "curl" "/lib/libcurl.so"))
120 (native-bin-clang (native-file "clang" "/bin/clang"))
121 (native-bin-clang++ (native-file "clang" "/bin/clang++")))
110 #~(modify-phases %standard-phases 122 #~(modify-phases %standard-phases
123 ;; LDC needs a C compiler as a linker wrapper.
124 ;; Change the default fallback "cc" to clang.
125 ;; Discovery implemented in ldc v1.19.0.
126 (add-after 'patch-usr-bin-file 'patch-default-cc
127 (lambda _
128 (substitute* "driver/tool.h"
129 (("\"cc\"")
130 (format #f "~s" #$target-bin-clang)))))
111 (add-after 'unpack 'patch-compiler-rt-library-discovery 131 (add-after 'unpack 'patch-compiler-rt-library-discovery
112 (lambda* (#:key inputs #:allow-other-keys) 132 (lambda _
113 (let ((clang-runtime (assoc-ref inputs "clang-runtime")) 133 (let* ((system #$(or (%current-target-system)
114 (system #$(or (%current-target-system) 134 (%current-system)))
115 (%current-system)))) 135 (arch (car (string-split system #\-)))
116 (define (gnu-triplet->clang-arch system) 136 (clang-arch (cond
117 (let ((system-prefix 137 ((string-suffix? "86" arch) "i386")
118 (car (string-tokenize 138 (#t arch))))
119 system (char-set-complement (char-set #\-))))))
120 (cond
121 ((equal? system-prefix "i686") "i386")
122 (#t system-prefix))))
123 ;; Coax LLVM into agreeing with Clang about system target 139 ;; Coax LLVM into agreeing with Clang about system target
124 ;; naming. 140 ;; naming.
125 (substitute* "driver/linker-gcc.cpp" 141 (substitute* "driver/linker-gcc.cpp"
126 (("triple.getArchName\\(\\)") 142 (("triple.getArchName\\(\\)")
127 (format #f "~s" (gnu-triplet->clang-arch system)))) 143 (format #f "~s" clang-arch)))
128 ;; Augment the configuration of the ldc2 binaries so they can 144 ;; Augment the configuration of the ldc2 binaries so they
129 ;; find the compiler-rt libraries they need to be linked with 145 ;; can find the compiler-rt libraries they need to be
130 ;; for the tests. 146 ;; linked with for the tests.
131 (substitute* (find-files "." "^ldc2.*\\.conf\\.in$") 147 (substitute* (find-files "." "^ldc2.*\\.conf\\.in$")
132 ((".*LIB_SUFFIX.*" all) 148 ((".*LIB_SUFFIX.*" all)
133 (string-append all 149 (string-append all
134 " \"" clang-runtime 150 " \""
151 #$target-clang-runtime
135 "/lib/linux\",\n")))))) 152 "/lib/linux\",\n"))))))
153 ;; Using ImportC will always emit warnings when using gcc 14+
154 ;; as its preprocessor, causing tests that read stderr to
155 ;; fail.
156 ;; Introduced in ldc v1.29.0.
157 ;; Fixed (like this) in ldc v1.40.0.
158 (add-after 'unpack 'patch-importc-system-header
159 (lambda _
160 (substitute* "runtime/druntime/src/importc.h"
161 (("^#define __IMPORTC__ 1.*$" all)
162 (string-append
163 all
164 "\n"
165 "#ifdef __GNUC__\n"
166 "#pragma GCC system_header\n"
167 "#endif\n")))))
168 ;; Using ImportC with clang as preprocessor will cause
169 ;; ImportC to fail on glibc float headers.
170 ;; Introduced in ldc v1.33.0.
171 (add-after 'unpack 'patch-importc-float128
172 (lambda _
173 (substitute* "runtime/druntime/src/importc.h"
174 (("^#ifndef __aarch64__.*$")
175 (string-append
176 "#if !defined(__aarch64__) && defined(__clang__)\n"
177 "#define __float128 long double\n"
178 "#elif !defined(__aarch64__)\n")))))
136 (add-after 'unpack 'patch-paths-in-phobos 179 (add-after 'unpack 'patch-paths-in-phobos
137 (lambda* (#:key inputs #:allow-other-keys)
138 (substitute* "runtime/phobos/std/process.d"
139 (("/bin/sh") #$target-bin-sh)
140 (("echo") (which "echo")))))
141 (add-after 'unpack 'patch-paths-in-tests
142 (lambda _ 180 (lambda _
181 (with-directory-excursion "runtime/phobos"
182 (substitute* "std/net/curl.d"
183 (("\"libcurl\\.so\"")
184 (format #f "~s" #$target-lib-curl)))
185 (substitute* "std/process.d"
186 (("return \"/bin/sh\";")
187 (format #f "return ~s;" #$target-bin-sh))
188 (("#!/bin/sh")
189 (string-append "#!" #$target-bin-sh))))))
190 (add-after 'unpack 'patch-getInstalledTZNames-infinite-symlink
191 (lambda _
192 ;; Disable following directory symlinks when iterating tzdata.
193 (substitute* "runtime/phobos/std/datetime/timezone.d"
194 (("SpanMode\\.depth\\)") "SpanMode.depth, false)"))))
195 (add-after 'unpack 'patch-tests
196 (lambda _
197 ;; Fails often. Relies on guessing the test binary size,
198 ;; sleeps, and file timestamps.
199 ;; Introduced in ldc v1.1.0.
200 (delete-file "tests/linking/ir2obj_cache_pruning2.d")
201 ;; Very unreliable.
202 ;; Introduced in ldc v1.4.0.
203 (delete-file "tests/sanitizers/fuzz_asan.d")
204 ;; These 2 tests try to build a Makefile on their own.
205 ;; Introduced in ldc v1.8.0.
206 (delete-file-recursively "tests/plugins")
207 ;; This test doesn't expect the linker to demangle D symbols.
208 ;; Introduced in ldc v1.8.1.
209 (substitute* "tests/dmd/fail_compilation/needspkgmod.d"
210 (("_D7imports9pkgmod3133mod3barFZv")
211 "imports.pkgmod313.mod.bar()"))
212 ;; Our gdb is more clever than expected.
213 ;; Introduced in ldc v1.13.0. Fixed (like this) in v1.40.0.
214 (substitute* "tests/debuginfo/print_gdb.d"
215 (("GDB: p b_Glob")
216 "GDB: p inputs.import_b.b_Glob"))
217 ;; These CTFE tests fail on riscv64-linux.
218 ;; Test for signbit introduced in ldc v1.19.0.
219 ;; Test for getNaNPayload introduced in ldc v1.25.0.
220 ;; std.math was split into modules in ldc v1.27.0.
221 #$@(if (target-riscv64?)
222 #~((substitute* "runtime/phobos/std/math/operations.d"
223 (("static assert\\(getNaNPayload\\(a\\)" line)
224 (string-append "//" line)))
225 (substitute* "runtime/phobos/std/math/traits.d"
226 (("static assert\\(signbit\\(-.*\\.nan" line)
227 (string-append "//" line))))
228 #~())
229 ;; This test creates a shell script and runs it.
230 ;; Introduced in ldc v1.22.0.
231 (substitute* "tests/dmd/dshell/test6952.d"
232 (("/usr/bin/env bash") #$target-bin-sh))
233 ;; Fails to detect the race condition for some reason.
234 ;; Introduced in ldc v1.23.0.
235 (for-each delete-file
236 '("tests/sanitizers/tsan_tiny_race.d"
237 "tests/sanitizers/tsan_tiny_race_TLS.d"))
238 ;; Likewise. Introduced in ldc v1.27.0.
239 (for-each delete-file
240 '("tests/sanitizers/msan_noerror.d"
241 "tests/sanitizers/msan_uninitialized.d"))
242 ;; Likewise. Introduced in ldc v1.30.0.
243 (for-each delete-file
244 '("tests/sanitizers/lsan_memleak.d"))
245 ;; Also related to ImportC with clang breaking on floats.
246 ;; Introduced in ldc v1.36.0
247 ;; Fixed (like this) in ldc v1.41.0.
248 (delete-file "tests/dmd/compilable/fix24187.c")
249 ;; Patch a shell path in the druntime profile test Makefile.
250 ;; Introduced in ldc v1.34.0.
143 (substitute* "runtime/druntime/test/profile/Makefile" 251 (substitute* "runtime/druntime/test/profile/Makefile"
144 (("/bin/bash") #$target-bin-sh)) 252 (("SHELL=/bin/bash")
253 (string-append "SHELL=" #$target-bin-sh)))
254 ;; Since the implementation of SOURCE_DATE_EPOCH support in
255 ;; Ddoc, this test fails, as it expects Ddoc timestamps to
256 ;; match the output of the `date` command.
257 ;; Introduced in ldc v1.36.0.
258 (substitute*
259 "tests/dmd/compilable/extra-files/ddocYear-postscript.sh"
260 (("^YEAR=.*$") "YEAR=1970\n"))
261 ;; This tests how the CC env var is handled by the compiler,
262 ;; by setting it to cc, which we don't have.
263 ;; Introduced in ldc v1.37.0.
145 (substitute* "tests/driver/cli_CC_envvar.d" 264 (substitute* "tests/driver/cli_CC_envvar.d"
146 (("cc") #$target-bin-sh)) 265 (("\\bcc\\b") #$native-bin-clang))
147 (substitute* "tests/linking/linker_switches.d" 266 ;; One of these tests hangs when a modern llvm opt is applied.
148 (("echo") (which "echo"))) 267 ;; Fix by only running debug builds.
149 (substitute* "tests/dmd/dshell/test6952.d" 268 ;; Introduced in ldc v1.41.0.
150 (("/usr/bin/env bash") #$target-bin-sh))))
151 (add-after 'unpack 'disable-problematic-tests
152 (lambda* (#:key inputs #:allow-other-keys)
153 ;; Disable unittests in the following files.
154 (substitute* '("runtime/phobos/std/net/curl.d"
155 "runtime/phobos/std/datetime/systime.d"
156 "runtime/phobos/std/datetime/timezone.d")
157 (("version(unittest)") "version(skipunittest)")
158 ((" unittest") " version(skipunittest) unittest"))
159 ;; The following tests plugins we don't have.
160 (delete-file "tests/plugins/addFuncEntryCall/testPlugin.d")
161 (delete-file "tests/plugins/addFuncEntryCall/testPluginLegacy.d")
162 ;; This unit test requires networking, fails with
163 ;; "core.exception.RangeError@std/socket.d(778): Range
164 ;; violation".
165 (substitute* "runtime/phobos/std/socket.d"
166 (("assert\\(ih.addrList\\[0\\] == 0x7F_00_00_01\\);.*")
167 ""))
168
169 ;; These tests fail on riscv64-linux.
170 (substitute* "runtime/phobos/std/math/operations.d"
171 (("static assert\\(getNaNPayload\\(a\\)" all )
172 (string-append "// " all)))
173 (substitute* "runtime/phobos/std/math/traits.d"
174 (("static assert\\(signbit\\(-.*\\.nan" all)
175 (string-append "// " all)))
176
177 ;; The GDB tests suite fails; there are a few bug reports about
178 ;; it upstream.
179 (for-each delete-file (find-files "tests" "gdb.*\\.(c|d|sh)$"))
180 (delete-file "tests/dmd/runnable/b18504.d")
181 (substitute* "runtime/druntime/test/exceptions/Makefile" 269 (substitute* "runtime/druntime/test/exceptions/Makefile"
182 ((".*TESTS\\+=rt_trap_exceptions_drt_gdb.*") 270 (("TESTS\\+=memoryerror.*$" all)
183 "")) 271 (string-append "ifeq ($(BUILD),debug)\n" all "endif\n")))
184 ;; Unsupported with glibc-2.35.
185 (delete-file "tests/dmd/compilable/stdcheaders.c")
186 (delete-file "tests/dmd/compilable/test23958.c")
187 (delete-file "tests/dmd/runnable/test23889.c")
188 (delete-file "tests/dmd/runnable/test23402.d")
189 (delete-file "tests/dmd/runnable/helloc.c")
190 ;; Only works in 2024 and without SOURCE_DATE_EPOCH
191 (delete-file "tests/dmd/compilable/ddocYear.d")
192 ;; Drop gdb_dflags from the test suite.
193 (substitute* "tests/dmd/CMakeLists.txt"
194 (("\\$\\{gdb_dflags\\}") ""))
195 ;; The following tests fail on some systems, not all of 272 ;; The following tests fail on some systems, not all of
196 ;; which are tested upstream. 273 ;; which are tested upstream.
197 (with-directory-excursion "tests" 274 (for-each
198 (cond 275 (lambda (path) (false-if-file-not-found (delete-file path)))
199 (#$(or (target-x86-32?) 276 (list
200 (target-arm32?)) 277 #$@(if (or (target-x86-32?)
201 (for-each delete-file 278 (target-arm32?))
202 '("PGO/profile_rt_calls.d" 279 #~("tests/codegen/mangling.d"
203 "codegen/mangling.d" 280 "tests/dmd/runnable_cxx/cppa.d"
204 "instrument/xray_check_pipeline.d" 281 "tests/instrument/xray_check_pipeline.d"
205 "instrument/xray_link.d" 282 "tests/instrument/xray_link.d"
206 "instrument/xray_simple_execution.d" 283 "tests/instrument/xray_simple_execution.d"
207 "sanitizers/msan_noerror.d" 284 "tests/PGO/profile_rt_calls.d"
208 "sanitizers/msan_uninitialized.d" 285 "tests/sanitizers/msan_noerror.d"
209 "dmd/runnable_cxx/cppa.d"))) 286 "tests/sanitizers/msan_uninitialized.d")
210 (#$(target-riscv64?) 287 #~())
211 (for-each delete-file 288 #$@(if (target-riscv64?)
212 '("codegen/simd_alignment.d" 289 #~("tests/dmd/codegen/simd_alignment.d"
213 "dmd/runnable/argufilem.d" 290 "tests/dmd/compilable/test23705.d"
214 "dmd/compilable/test23705.d" 291 "tests/dmd/fail_compilation/diag7420.d"
215 "dmd/fail_compilation/diag7420.d"))) 292 "tests/dmd/runnable/argufilem.d"
216 (#t '()))))) 293 "tests/dmd/runnable_cxx/cppa.d")
294 #~())))))
217 ;; The tests require to be built with Clang; build everything 295 ;; The tests require to be built with Clang; build everything
218 ;; with it, for simplicity. 296 ;; with it, for simplicity.
219 (add-before 'configure 'set-cc-and-cxx-to-use-clang 297 (add-before 'configure 'set-cc
220 (lambda _ 298 (lambda _
221 (setenv "CC" (which "clang")) 299 (setenv "CC" #$native-bin-clang)
222 (setenv "CXX" (which "clang++")))) 300 (setenv "CXX" #$native-bin-clang++)))
301 ;; The test targets are tested separately to provide
302 ;; finer-grained diagnostics (see the `.github/actions/4*`
303 ;; files in the source).
223 (replace 'check 304 (replace 'check
224 (lambda* (#:key tests? parallel-tests? #:allow-other-keys) 305 (lambda* (#:key tests? parallel-tests? #:allow-other-keys)
306 (define* (run-tests name includes excludes
307 #:key
308 (job-count (if parallel-tests?
309 (parallel-job-count)
310 1)))
311 (define (regex-flags prefix patterns)
312 (if (> (length patterns) 0)
313 (list prefix
314 (format #f "(~a)" (string-join patterns "|")))
315 '()))
316 (format #t "running the ~a...\n" name)
317 (apply invoke
318 `("ctest"
319 "--output-on-failure"
320 "-j" ,(number->string job-count)
321 ,@(regex-flags "-R" includes)
322 ,@(regex-flags "-E" excludes))))
225 (when tests? 323 (when tests?
226 (let ((job-count (number->string 324 (run-tests "ldc2 unit tests"
227 (or (and parallel-tests? 325 (list "ldc2-unittest")
228 (parallel-job-count)) 326 (list))
229 1)))) 327 (run-tests "lit test suite"
230 ;; The test targets are tested separately to provide 328 (list "lit-tests")
231 ;; finer-grained diagnostics (see: 329 (list))
232 ;; https://raw.githubusercontent.com/ldc-developers/ 330 ;; This test has a race condition so run it with 1 core.
233 ;; ldc/master/.azure-pipelines/3-posix-test.yml) 331 (run-tests "dmd test suite"
234 (display "running the ldc2 unit tests...\n") 332 (list "dmd-testsuite")
235 (invoke "ctest" "--output-on-failure" "-j" job-count 333 (list)
236 "-R" "ldc2-unittest") 334 #:job-count 1)
237 (display "running the lit test suite...\n") 335 (run-tests "druntime unit tests"
238 (invoke "ctest" "--output-on-failure" "-j" job-count 336 (list "druntime-test-runner"
239 "-R" "lit-tests") 337 "^core\\."
240 (display "running the dmd test suite...\n") 338 "^etc\\.linux" "etc\\.valgrind"
241 ;; This test has a race condition so run it with 1 core. 339 "^ldc\\."
242 (invoke "ctest" "--output-on-failure" "-j" "1" 340 "^object"
243 "-R" "dmd-testsuite") 341 "^rt\\.")
244 (display "running the defaultlib unit tests and druntime \ 342 (list #$@(if (target-riscv64?)
245integration tests...\n") 343 ;; These hang forever
246 (invoke 344 #~("core.thread.fiber-.*shared"
247 "ctest" "--output-on-failure" "-j" job-count "-E" 345 "core.thread.osthread-.*shared")
248 (string-append 346 #~())))
249 "dmd-testsuite|lit-tests|ldc2-unittest" 347 (run-tests "druntime integration tests"
250 #$@(cond 348 (list "druntime-test")
251 ((target-aarch64?) 349 (list "druntime-test-runner"
252 #~("|std.internal.math.gammafunction-shared" 350 #$@(if (target-aarch64?)
253 "|std.math.exponential-shared" 351 #~("druntime-test-exceptions-debug")
254 "|std.internal.math.gammafunction-debug-shared" 352 #~())))
255 "|druntime-test-exceptions-debug")) 353 ;; Building these tests is very resource intensive, so
256 ((target-riscv64?) 354 ;; limit the job count.
257 #~("|std.internal.math.errorfunction-shared" 355 (run-tests
258 "|std.internal.math.gammafunction-shared" 356 "phobos unit tests"
259 "|std.math.exponential-shared" 357 (list "phobos"
260 "|std.math.trigonometry-shared" 358 "etc\\.c\\."
261 "|std.mathspecial-shared" 359 "^std")
262 "|std.socket-shared" 360 (list #$@(if (target-aarch64?)
263 "|std.internal.math.errorfunction-debug-shared" 361 #~("std.internal.math.gammafunction-.*shared"
264 "|std.internal.math.gammafunction-debug-shared" 362 "std.math.exponential-shared")
265 "|std.math.operations-debug-shared" 363 #~())
266 "|std.math.exponential-debug-shared" 364 #$@(if (target-riscv64?)
267 "|std.math.traits-debug-shared" 365 #~("std.internal.math.errorfunction-.*shared"
268 "|std.mathspecial-debug-shared" 366 "std.internal.math.gammafunction-.*shared"
269 "|std.math.trigonometry-debug-shared" 367 "std.math.exponential-.*shared"
270 "|std.socket-debug-shared" 368 "std.math.operations-debug-shared"
271 ;; These four hang forever 369 "std.math.traits-debug-shared"
272 "|core.thread.fiber-shared" 370 "std.math.trigonometry-.*shared"
273 "|core.thread.osthread-shared" 371 "std.mathspecial-.*shared"
274 "|core.thread.fiber-debug-shared" 372 "std.socket-debug-shared"
275 "|core.thread.osthread-debug-shared")) 373 "std.socket-shared")
276 (#t #~())))))))) 374 #~()))
277 (replace 'build 375 #:job-count 1))))
278 ;; Building with Make would result in "make: *** [Makefile:166: 376 (add-after 'install 'create-lib-output
279 ;; all] Error 2". 377 (lambda* (#:key outputs #:allow-other-keys)
280 (lambda* (#:key make-flags parallel-build? #:allow-other-keys) 378 (let* ((out (assoc-ref outputs "out"))
281 (let ((job-count (number->string (or (and parallel-build? 379 (out/etc (string-append out "/etc"))
282 (parallel-job-count)) 380 (out/lib (string-append out "/lib"))
283 1)))) 381 (lib (assoc-ref outputs "lib"))
284 (apply invoke "cmake" "--build" "." "-j" job-count 382 (lib/lib (string-append lib "/lib"))
285 "--target" make-flags)))) 383 (libs (find-files out/lib "\\.so")))
286 (replace 'install 384 (mkdir-p lib/lib)
287 (lambda _ 385 (for-each (lambda (original)
288 (invoke "cmake" "--install" "."))))))) 386 (install-file original lib/lib)
387 (delete-file original))
388 libs)
389 ;; Patch default lib-dirs and rpath in ldc2.conf.
390 (substitute* (string-append out/etc "/ldc2.conf")
391 ;; Append to lib-dirs.
392 (((format #f "\"~a\"," out/lib) all)
393 (format #f "~a~% \"~a\"," all lib/lib))
394 ;; Replace rpath.
395 (((format #f "rpath = \"~a\";" out/lib))
396 (format #f "rpath = \"~a\";" lib/lib))))))))))
289 (inputs 397 (inputs
290 (list bash-minimal 398 (list clang-runtime-18
291 zlib)) 399 libconfig
400 llvm-18
401 zlib
402 clang ; used as a linker wrapper
403 curl ; std.net.curl
404 bash-minimal)) ; std.process
292 (native-inputs 405 (native-inputs
293 (list (make-lld-wrapper lld-17 #:lld-as-ld? #t) 406 (list gdmd
294 clang-17 ; propagates llvm and clang-runtime 407 clang ; propagates llvm and clang-runtime
295 gdmd 408 lld-as-ld-wrapper
409 ;; For testing
410 tzdata-for-tests ; std.datetime.timezone
411 gdb
296 python-wrapper 412 python-wrapper
297 python-setuptools 413 python-setuptools
298 python-lit 414 python-lit))
299 tzdata-for-tests 415 (outputs '("out" "lib" "debug"))
300 unzip))
301 (home-page "http://wiki.dlang.org/LDC") 416 (home-page "http://wiki.dlang.org/LDC")
302 (synopsis "LLVM-based compiler for the D programming language") 417 (synopsis "LLVM-based compiler for the D programming language")
303 (description "LDC is an LLVM compiler for the D programming language. It 418 (description "The LDC project provides a portable D programming language
304is based on the latest DMD compiler that was written in C and is used for 419compiler with modern optimization and code generation capabilities. The
305bootstrapping more recent compilers written in D.") 420compiler uses the official DMD frontend to support the latest version of D2,
421and relies on the LLVM Core libraries for code generation.
422
423This compiler is based on the DMD frontend version 2.108.1.")
306 ;; Most of the code is released under BSD-3, except for code originally 424 ;; Most of the code is released under BSD-3, except for code originally
307 ;; written for GDC, which is released under GPLv2+, and the DMD frontend, 425 ;; written for GDC, which is released under GPLv2+, and the DMD frontend
308 ;; which is released under the "Boost Software License version 1.0". 426 ;; and the druntime and phobos libraries which are released under the
427 ;; "Boost Software License version 1.0".
309 (license (list license:bsd-3 428 (license (list license:bsd-3
310 license:gpl2+ 429 license:gpl2+
311 license:boost1.0)) 430 license:boost1.0))
312 (properties 431 (properties
313 ;; Some of the tests take a very long time on ARMv7. See 432 `((hidden? . #t)
314 ;; <https://lists.gnu.org/archive/html/guix-devel/2018-02/msg00312.html>. 433 ;; Some of the tests take a very long time on ARMv7. See
315 `((max-silent-time . ,(* 3600 3)) 434 ;; https://lists.gnu.org/archive/html/guix-devel/2018-02/msg00312.html.
316 435 ,@(if (target-arm32?) `((max-silent-time . ,(* 3600 3))) '())))))
317 ;; This variant exists solely for bootstrapping purposes.
318 (hidden? . #t)))))
319 436
320(define-public ldc 437(define-public ldc
321 (let ((base ldc-bootstrap)) 438 (let ((base ldc-bootstrap))
@@ -324,17 +441,18 @@ bootstrapping more recent compilers written in D.")
324 (arguments 441 (arguments
325 (substitute-keyword-arguments 442 (substitute-keyword-arguments
326 (strip-keyword-arguments 443 (strip-keyword-arguments
327 '(#:tests?) 444 '(#:tests?) ; reinstate tests
328 (package-arguments base)) 445 (package-arguments base))
329 ((#:make-flags flags #f) 446 ((#:disallowed-references _ ''())
330 #~(append #$flags 447 (list (lookup-package-native-input base "gdmd")
331 (list ;; Also build the test runner binaries. 448 tzdata-for-tests))
332 "ldc2-unittest" "all-test-runners")))
333 ((#:configure-flags flags #~'()) 449 ((#:configure-flags flags #~'())
334 #~(append 450 #~(append
335 (fold delete #$flags '("-DD_COMPILER_FLAGS=-fPIC" 451 (fold delete #$flags '("-DD_COMPILER_FLAGS=-fPIC"
336 "-DBUILD_SHARED_LIBS=OFF")) 452 "-DBUILD_SHARED_LIBS=OFF"))
337 '("-DBUILD_SHARED_LIBS=ON"))))) 453 '("-DBUILD_SHARED_LIBS=ON")))
454 ((#:build-type _ ''())
455 "RelWithDebInfo")))
338 (native-inputs 456 (native-inputs
339 (modify-inputs (package-native-inputs base) 457 (modify-inputs (package-native-inputs base)
340 (delete "gdmd") 458 (delete "gdmd")
diff --git a/gnu/packages/patches/ldc-phobos-support-TZDIR.patch b/gnu/packages/patches/ldc-phobos-support-TZDIR.patch
new file mode 100644
index 00000000000..716e222d565
--- /dev/null
+++ b/gnu/packages/patches/ldc-phobos-support-TZDIR.patch
@@ -0,0 +1,42 @@
1commit 957d704139d6430fcce7e5b0d7058572f220ab09
2Author: Jonas Meeuws <jonas.meeuws@gmail.com>
3Date: Thu Mar 12 01:27:34 2026 +0100
4
5 std.datetime.timezone: Support the TZDIR environment variable on POSIX.
6
7diff --git a/runtime/phobos/std/datetime/timezone.d b/runtime/phobos/std/datetime/timezone.d
8index 6a1898b0e..4e7b1f95b 100644
9--- a/runtime/phobos/std/datetime/timezone.d
10+++ b/runtime/phobos/std/datetime/timezone.d
11@@ -2033,7 +2033,15 @@ public:
12 }
13 else version (Posix)
14 {
15- enum defaultTZDatabaseDir = "/usr/share/zoneinfo/";
16+ static nothrow
17+ string defaultTZDatabaseDir()
18+ {
19+ import std.exception : assumeWontThrow;
20+ import std.process : environment;
21+ return environment
22+ .get("TZDIR", "/usr/share/zoneinfo/")
23+ .assumeWontThrow; // nothrow on POSIX
24+ }
25 }
26 else version (Windows)
27 {
28@@ -2455,11 +2463,13 @@ public:
29 // RefCounted variable, but here, no references to the payload is
30 // escaped to the outside, so this should be @trusted
31 () @trusted {
32- foreach (DirEntry de; dirEntries(tzDatabaseDir, SpanMode.depth))
33+ foreach (DirEntry de; dirEntries(tzDatabaseDir, SpanMode.depth, false))
34 {
35 if (de.isFile)
36 {
37 auto tzName = de.name[tzDatabaseDir.length .. $];
38+ if (tzName.startsWith("/"))
39+ tzName = tzName[1 .. $];
40
41 if (!tzName.extension().empty ||
42 !tzName.startsWith(subName) ||