projects/guix·blob python-team · refs

515 lines · 25.8 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2025 Danny Milosavljevic <[email protected]>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu packages swift)
20 #:use-module (guix packages)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix git-download)
23 #:use-module (guix gexp)
24 #:use-module (guix utils)
25 #:use-module (guix build-system cmake)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages base)
28 #:use-module (gnu packages build-tools)
29 #:use-module (gnu packages check)
30 #:use-module (gnu packages cmake)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages gcc)
33 #:use-module (gnu packages icu4c)
34 #:use-module (gnu packages libedit)
35 #:use-module (gnu packages libffi)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages llvm)
38 #:use-module (gnu packages perl)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages xml))
42
43(define %swift-bootstrap-version "5.7.3")
44
45(define %swift-bootstrap-source
46 (origin
47 (method git-fetch)
48 (uri (git-reference
49 (url "https://github.com/apple/swift.git")
50 (commit (string-append "swift-" %swift-bootstrap-version
51 "-RELEASE"))))
52 (file-name (git-file-name "swift" %swift-bootstrap-version))
53 (sha256
54 (base32
55 "012m91yp2d69l0k6s0gjz6gckxq4hvid197a8kpc5mi9wbchzjvs"))
56 (patches (search-patches "swift-5.7.3-sdk-path.patch"
57 "swift-5.7.3-sourcekit-rpath.patch"))))
58
59(define %swift-6.2-version "6.2")
60
61(define %swift-6.2-source
62 (origin
63 (method git-fetch)
64 (uri (git-reference
65 (url "https://github.com/apple/swift.git")
66 (commit (string-append "swift-" %swift-6.2-version
67 "-RELEASE"))))
68 (file-name (git-file-name "swift" %swift-6.2-version))
69 (sha256
70 (base32
71 "1615yxdjlglfq0skrj0kfxzlp6riig8nkn07qddh2r89whj3gv2g"))
72 (patches (search-patches "swift-5.7.3-sdk-path.patch"
73 "swift-5.7.3-sourcekit-rpath.patch"
74 "swift-6.2-cplus-include-path.patch"
75 "swift-6.2-exclude-scan-test.patch"))))
76
77(define-public swift-cmark
78 (package
79 (name "swift-cmark")
80 (version %swift-bootstrap-version)
81 (source (origin
82 (method git-fetch)
83 (uri (git-reference
84 (url "https://github.com/apple/swift-cmark.git")
85 (commit (string-append "swift-" %swift-bootstrap-version
86 "-RELEASE"))))
87 (file-name (git-file-name "swift-cmark" %swift-bootstrap-version))
88 (sha256
89 (base32
90 "0340j9x2n40yx61ma2pgqfbn3a9ijrh20iwzd1zxqq87rr76hh3z"))))
91 (build-system cmake-build-system)
92 (arguments
93 (list
94 #:tests? #f
95 #:build-type "Release"
96 #:configure-flags
97 #~(list (string-append "-DCMAKE_INSTALL_PREFIX=" #$output))
98 #:phases
99 #~(modify-phases %standard-phases
100 (add-after 'install 'install-cmake-exports
101 (lambda _
102 (install-file "src/cmarkTargets.cmake"
103 (string-append #$output "/src"))
104 (substitute* (string-append #$output "/src/cmarkTargets.cmake")
105 (("/tmp/guix-build-swift-cmark-[^/]+/source/src")
106 #$output)
107 (("/tmp/guix-build-swift-cmark-[^/]+/build/src")
108 (string-append #$output "/lib")))
109 #t)))))
110 (native-inputs
111 (list cmake ninja python-3))
112 (home-page "https://swift.org/")
113 (synopsis "CommonMark parsing and rendering library for Swift")
114 (description
115 "This is Apple's fork of cmark (CommonMark implementation) with
116Swift-specific modifications, required to build Swift 4.2.4.")
117 (license license:bsd-2)))
118
119(define-public swift-cmark-6.2
120 (package
121 (inherit swift-cmark)
122 (version %swift-6.2-version)
123 (source (origin
124 (method git-fetch)
125 (uri (git-reference
126 (url "https://github.com/apple/swift-cmark.git")
127 (commit (string-append "swift-" %swift-6.2-version
128 "-RELEASE"))))
129 (file-name (git-file-name "swift-cmark" %swift-6.2-version))
130 (sha256
131 (base32
132 "1405irbglx933i6jc8546gcrgb3y3703h66jm1jnd6acgfyg74ly"))))
133 (arguments
134 (substitute-keyword-arguments arguments
135 ((#:phases phases)
136 #~(modify-phases #$phases
137 (delete 'install-cmake-exports)))))))
138
139(define %swift-libdispatch-source
140 (origin
141 (method git-fetch)
142 (uri (git-reference
143 (url "https://github.com/apple/swift-corelibs-libdispatch.git")
144 (commit (string-append "swift-" %swift-bootstrap-version
145 "-RELEASE"))))
146 (file-name "swift-corelibs-libdispatch")
147 (sha256
148 (base32
149 "0skg1azbhbg7y0ql2a5sx6lmfip8l1rajqm95zzf9xv45n4dg9nn"))
150 (patches (search-patches "swift-corelibs-libdispatch-5.6.3-lock-cpp.patch"
151 "swift-corelibs-libdispatch-5.7.3-modulemap.patch"))))
152
153(define %swift-libdispatch-6.2-source
154 (origin
155 (method git-fetch)
156 (uri (git-reference
157 (url "https://github.com/apple/swift-corelibs-libdispatch.git")
158 (commit (string-append "swift-" %swift-6.2-version
159 "-RELEASE"))))
160 (file-name "swift-corelibs-libdispatch")
161 (sha256
162 (base32
163 "1nrm69zwf7i5rxgc9gzdknl6p9aggfnzcrydh1qsvqhga3s8dvaf"))
164 (patches (search-patches "swift-corelibs-libdispatch-5.6.3-lock-cpp.patch"))))
165
166(define %swift-syntax-6.2-source
167 (origin
168 (method git-fetch)
169 (uri (git-reference
170 (url "https://github.com/swiftlang/swift-syntax.git")
171 (commit (string-append "swift-" %swift-6.2-version
172 "-RELEASE"))))
173 (file-name "swift-syntax")
174 (sha256
175 (base32
176 "17z2c7kign0cjvnsm2m75c4nsjr3wbxzlzybwb5pnpxnbvmmyxf9"))))
177
178(define-public swift-bootstrap
179 (package
180 (name "swift-bootstrap")
181 (version %swift-bootstrap-version)
182 (source %swift-bootstrap-source)
183 (build-system cmake-build-system)
184 (arguments
185 (list
186 #:tests? #f ; we don't have the compatible (old) googletest
187 #:modules '((ice-9 match)
188 (guix build cmake-build-system)
189 (guix build utils))
190 #:configure-flags
191 #~(list "-GNinja"
192 "-DCMAKE_BUILD_TYPE=Release"
193 ;"-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON"
194 "-DCMAKE_C_FLAGS=-Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector"
195 "-DCMAKE_CXX_FLAGS=-Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector"
196 "-DCMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -DNDEBUG"
197 "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -DNDEBUG"
198 (string-append "-DCMAKE_C_COMPILER="
199 (assoc-ref %build-inputs "swift-llvm")
200 "/bin/clang")
201 (string-append "-DCMAKE_CXX_COMPILER="
202 (assoc-ref %build-inputs "swift-llvm")
203 "/bin/clang++")
204 "-DSWIFT_STDLIB_BUILD_TYPE=Release"
205 "-DSWIFT_STDLIB_ASSERTIONS=TRUE"
206 "-DSWIFT_ENABLE_DISPATCH=TRUE"
207 "-DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS=TRUE"
208 "-DLLVM_ENABLE_ASSERTIONS=TRUE"
209 ;; Python swift.py product class (not build-script-impl).
210 "-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE"
211 ;; Python swift.py product class (not build-script-impl).
212 "-DSWIFT_FORCE_OPTIMIZED_TYPECHECKER=FALSE"
213 ;; Python swift.py product class (not build-script-impl).
214 "-DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING=FALSE"
215 ;; The build-script wrapper passes --swift-analyze-code-coverage false
216 ;; to build-script-impl.
217 "-DSWIFT_ANALYZE_CODE_COVERAGE=FALSE"
218 "-DSWIFT_INCLUDE_TOOLS=TRUE"
219 "-DSWIFT_BUILD_REMOTE_MIRROR=TRUE"
220 "-DSWIFT_STDLIB_SIL_DEBUGGING=FALSE"
221 "-DSWIFT_CHECK_INCREMENTAL_COMPILATION=FALSE"
222 "-DSWIFT_REPORT_STATISTICS=FALSE"
223 (string-append "-DSWIFT_NATIVE_LLVM_TOOLS_PATH="
224 (assoc-ref %build-inputs "swift-llvm")
225 "/bin")
226 ;(string-append "-DSWIFT_NATIVE_CLANG_TOOLS_PATH="
227 ; (assoc-ref %build-inputs "swift-clang")
228 ; "/bin")
229 "-DSWIFT_BUILD_DYNAMIC_STDLIB=TRUE"
230 "-DSWIFT_BUILD_STATIC_STDLIB=FALSE"
231 "-DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=TRUE"
232 "-DSWIFT_BUILD_STATIC_SDK_OVERLAY=FALSE"
233 ; not there "-DSWIFT_BUILD_EXAMPLES=TRUE"
234 "-DSWIFT_INCLUDE_TESTS=FALSE"
235 "-DSWIFT_INCLUDE_TEST_BINARIES=FALSE"
236 "-DSWIFT_INSTALL_EXCLUDE_TESTSUITE_TOOLS=TRUE"
237 "-DSWIFT_EMBED_BITCODE_SECTION=FALSE"
238 "-DSWIFT_TOOLS_ENABLE_LTO="
239 "-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE"
240 ; not there "-DLIBDISPATCH_CMAKE_BUILD_TYPE=Release"
241 "-DSWIFT_NATIVE_SWIFT_TOOLS_PATH:STRING="
242 ; not there "-DSWIFT_BUILD_PERF_TESTSUITE:BOOL=TRUE"
243 ; not there "-DSWIFT_BUILD_EXTERNAL_PERF_TESTSUITE:BOOL=FALSE"
244 "-DLLVM_LIT_ARGS=-sv -j 16"
245 "-DCOVERAGE_DB="
246 ; not there "-DSWIFT_SOURCEKIT_USE_INPROC_LIBRARY:BOOL=TRUE"
247 "-DSWIFT_DARWIN_XCRUN_TOOLCHAIN:STRING=default"
248 "-DSWIFT_AST_VERIFIER:BOOL=TRUE"
249 "-DSWIFT_SIL_VERIFY_ALL:BOOL=FALSE"
250 "-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER:BOOL=FALSE"
251 "-DSWIFT_SDKS:STRING=LINUX"
252 (string-append "-DCMAKE_INSTALL_PREFIX=" #$output)
253 (string-append "-DCMAKE_INSTALL_RPATH=" #$output "/lib/swift/linux;" #$output "/lib")
254 (string-append "-DSWIFT_PATH_TO_CLANG_BUILD="
255 (assoc-ref %build-inputs "swift-llvm"))
256 (string-append "-DLLVM_BUILD_LIBRARY_DIR="
257 (assoc-ref %build-inputs "swift-llvm")
258 "/lib")
259 (string-append "-DLLVM_BUILD_MAIN_INCLUDE_DIR="
260 (assoc-ref %build-inputs "swift-llvm")
261 "/include")
262 (string-append "-DLLVM_BUILD_BINARY_DIR="
263 (assoc-ref %build-inputs "swift-llvm"))
264 (string-append "-DLLVM_BUILD_MAIN_SRC_DIR="
265 (assoc-ref %build-inputs "swift-llvm"))
266 (string-append "-DSWIFT_PATH_TO_CMARK_BUILD="
267 (assoc-ref %build-inputs "swift-cmark"))
268 (string-append "-DSWIFT_CMARK_LIBRARY_DIR="
269 (assoc-ref %build-inputs "swift-cmark")
270 "/lib")
271 (string-append "-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE="
272 (assoc-ref %build-inputs "swift-corelibs-libdispatch"))
273 (string-append "-DLLVM_DIR="
274 (assoc-ref %build-inputs "swift-llvm")
275 "/lib/cmake/llvm")
276 (string-append "-DClang_DIR="
277 (assoc-ref %build-inputs "swift-llvm")
278 "/lib/cmake/clang")
279 ;; Disable gold linker - ld.gold would bypass Guix's ld-wrapper
280 ;; which automatically adds -rpath flags for store libraries.
281 "-DSWIFT_USE_LINKER=")
282 #:phases
283 #~(modify-phases %standard-phases
284 (replace 'check
285 (lambda* (#:key tests? #:allow-other-keys)
286 (when tests?
287 (let ((platform (match #$(or (%current-target-system)
288 (%current-system))
289 ("x86_64-linux" "linux-x86_64")
290 ("aarch64-linux" "linux-aarch64")
291 ("i686-linux" "linux-i686")
292 (system (error "Unsupported system" system)))))
293 (invoke "ninja" (string-append "check-swift-" platform))))))
294 (add-after 'install 'install-dispatch-libs
295 (lambda* (#:key outputs #:allow-other-keys)
296 (let* ((out (assoc-ref outputs "out"))
297 (lib-dir (string-append out "/lib/swift/linux")))
298 (install-file "lib/swift/linux/libdispatch.so" lib-dir)
299 (install-file "lib/swift/linux/libBlocksRuntime.so" lib-dir))))
300 (add-after 'unpack 'setup
301 (lambda* (#:key inputs #:allow-other-keys)
302 ;; The BFD linker has issues wrt relocation of the protocol
303 ;; conformance section on arm and thumb targets.
304 ;;
305 ;; It also generates COPY relocations for final executables.
306 ;; The BFD linker has issues wrt relocations against protected
307 ;; symbols.
308 ;;
309 ;; Nevertheless, we use BFD linker for easier bootstrapping
310 ;; (since we use ld-wrapper to wrap the BFD linker).
311 (substitute* "lib/Driver/UnixToolChains.cpp"
312 (("return \"gold\";")
313 "return \"\";"))
314 ;; New gcc needs explicit #include <cstdint>.
315 (substitute* "include/swift/SIL/SILLinkage.h"
316 (("#include \"llvm/Support/ErrorHandling.h\"")
317 "#include <cstdint>\n#include \"llvm/Support/ErrorHandling.h\""))
318 ;; New gcc needs explicit #include <cstdint>.
319 (substitute* "include/swift/Basic/ExternalUnion.h"
320 (("#include \"llvm/Support/ErrorHandling.h\"")
321 "#include <cstdint>\n#include \"llvm/Support/ErrorHandling.h\""))
322 ;; Take clang from swift-llvm package (clang is built alongside llvm).
323 (substitute* "stdlib/CMakeLists.txt"
324 (("set\\(CMAKE_CXX_COMPILER \"\\$\\{SWIFT_NATIVE_LLVM_TOOLS_PATH\\}/clang\\+\\+\"\\)")
325 (string-append "set(CMAKE_CXX_COMPILER \""
326 (assoc-ref %build-inputs "swift-llvm")
327 "/bin/clang++\")"))
328 (("set\\(CMAKE_C_COMPILER \"\\$\\{SWIFT_NATIVE_LLVM_TOOLS_PATH\\}/clang\"\\)")
329 (string-append "set(CMAKE_C_COMPILER \""
330 (assoc-ref %build-inputs "swift-llvm")
331 "/bin/clang\")")))
332 ;; Fix hardcoded /usr/include path for glibc headers.
333 (substitute* "stdlib/public/Platform/CMakeLists.txt"
334 (("set\\(GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH \"/usr/include\"\\)")
335 (string-append "set(GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH \""
336 (assoc-ref %build-inputs "glibc")
337 "/include\")")))
338 ;; Fix GenerateVersionFromVCS.cmake path
339 (substitute* "lib/Basic/CMakeLists.txt"
340 (("\\$\\{LLVM_MAIN_SRC_DIR\\}/cmake/modules/GenerateVersionFromVCS.cmake")
341 "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake"))
342 ;; Fix features.json path - use installed location instead of source
343 (substitute* "lib/Option/CMakeLists.txt"
344 (("\\$\\{LLVM_MAIN_SRC_DIR\\}/\\.\\./clang/tools/driver/features\\.json")
345 "${LLVM_BUILD_BINARY_DIR}/share/clang/features.json"))
346 ;; cmarkTargets.cmake is already at the correct path via install-cmake-exports phase
347 ;;; clang is built as part of swift-llvm.
348 (substitute* "lib/IRGen/CMakeLists.txt"
349 ((" clangCodeGen")
350 " ${SWIFT_PATH_TO_CLANG_BUILD}/lib/libclangCodeGen.a")
351 ((" clangAST")
352 " ${SWIFT_PATH_TO_CLANG_BUILD}/lib/libclangAST.a"))
353 (substitute* "lib/Markup/CMakeLists.txt"
354 ((" libcmark_static")
355 " ${SWIFT_PATH_TO_CMARK_BUILD}/lib/libcmark.a"))
356 (substitute* "lib/AST/CMakeLists.txt"
357 ((" clangAPINotes")
358 " ${SWIFT_PATH_TO_CLANG_BUILD}/lib/libclangAPINotes.a")
359 ((" clangBasic")
360 " ${SWIFT_PATH_TO_CLANG_BUILD}/lib/libclangBasic.a"))
361 (substitute* "lib/FrontendTool/CMakeLists.txt"
362 ((" clangAPINotes")
363 " ${SWIFT_PATH_TO_CLANG_BUILD}/lib/libclangAPINotes.a")
364 ((" clangBasic")
365 " ${SWIFT_PATH_TO_CLANG_BUILD}/lib/libclangBasic.a")))))))
366 (native-inputs
367 (list cmake
368 ninja
369 perl
370 pkg-config
371 python-3
372 swift-cmark
373 %swift-libdispatch-source))
374 (inputs
375 (list glibc icu4c libedit libxml2 swift-llvm `(,util-linux "lib")))
376 (home-page "https://swift.org/")
377 (synopsis "Swift programming language (bootstrap from C++)")
378 (description
379 "Swift is a general-purpose programming language built using a modern
380approach to safety, performance, and software design patterns. This package
381provides a bootstrap build of Swift 4.2.4 compiled from C++ without requiring
382a previous Swift compiler.")
383 (license license:asl2.0)))
384
385(define-public swift-6.2
386 (package
387 (inherit swift-bootstrap)
388 (name "swift")
389 (version %swift-6.2-version)
390 (source %swift-6.2-source)
391 (arguments
392 (substitute-keyword-arguments arguments
393 ((#:configure-flags flags)
394 #~(append (cons (string-append "-DCMAKE_INSTALL_RPATH="
395 #$output "/lib/swift/linux:"
396 #$output "/lib/swift/host/compiler:"
397 #$output "/lib")
398 (filter (lambda (flag)
399 (not (string-prefix? "-DCMAKE_INSTALL_RPATH=" flag)))
400 #$flags))
401 (list "-DSWIFT_BUILD_SWIFT_SYNTAX=TRUE"
402 (string-append "-DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE="
403 (assoc-ref %build-inputs "swift-syntax"))
404 "-DSWIFT_MODULE_CACHE_PATH=/tmp/module-cache"
405 "-DCMAKE_Swift_FLAGS=-module-cache-path /tmp/module-cache"
406 (string-append "-DCMAKE_Swift_COMPILER="
407 (assoc-ref %build-inputs "swift-bootstrap")
408 "/bin/swiftc")
409 "-DBOOTSTRAPPING_MODE=BOOTSTRAPPING"
410 ;; Disable Swift-in-Swift compiler components because Swift 6.2's
411 ;; CMake forces BOOTSTRAPPING_MODE=HOSTTOOLS when
412 ;; SWIFT_ENABLE_SWIFT_IN_SWIFT is enabled on Linux, which requires
413 ;; Swift 5.8+. We only have Swift 5.7.3 for bootstrap.
414 ;;
415 ;; What we lose by disabling SWIFT_ENABLE_SWIFT_IN_SWIFT:
416 ;;
417 ;; 1. 48 Swift-based optimizer passes:
418 ;; - CopyToBorrowOptimization, AssumeSingleThreaded,
419 ;; BooleanLiteralFolding, DestroyHoisting,
420 ;; ComputeEscapeEffects, ComputeSideEffects,
421 ;; DiagnoseInfiniteRecursion, InitializeStaticGlobals,
422 ;; MandatoryRedundantLoadElimination,
423 ;; EarlyRedundantLoadElimination, RedundantLoadElimination,
424 ;; DeadStoreElimination, LifetimeDependenceDiagnostics,
425 ;; LifetimeDependenceInsertion, LifetimeDependenceScopeFixup,
426 ;; MergeCondFails, ObjCBridgingOptimization, ObjectOutliner,
427 ;; DeinitDevirtualizer, ReleaseDevirtualizer,
428 ;; LetPropertyLowering, FunctionStackProtection, Simplification,
429 ;; OnoneSimplification, LateOnoneSimplification,
430 ;; CleanupDebugSteps, NamedReturnValueOptimization,
431 ;; StripObjectHeaders, StackPromotion, UpdateBorrowedFrom,
432 ;; ExperimentalSwiftBasedClosureSpecialization,
433 ;; AutodiffClosureSpecialization, AsyncDemotion,
434 ;; MandatoryPerformanceOptimizations, ReadOnlyGlobalVariablesPass,
435 ;; StackProtection, DiagnoseUnknownConstValues,
436 ;; and various dumper/test passes
437 ;;
438 ;; 2. 2 C++ optimizer passes that are disabled without Swift-in-Swift
439 ;; (they cause verification failures in C++-only mode):
440 ;; - LoopRotate
441 ;; - SimplifyCFG
442 ;;
443 ;; 3. Swift macro implementations (@OptionSet, @DebugDescription,
444 ;; @TaskLocal, @Swiftify, @DistributedResolvable)
445 ;; The stdlib has fallbacks with #if hasFeature(Macros), so it
446 ;; builds without them.
447 ;;
448 ;; The compiler and stdlib will still build and work for all language
449 ;; features. Core functionality (parsing, type checking, SIL
450 ;; generation, code generation) is unaffected. However, generated code
451 ;; will be less optimized (159 C++ optimizer passes still work).
452 "-DSWIFT_ENABLE_SWIFT_IN_SWIFT=FALSE")))
453 ((#:phases phases)
454 #~(modify-phases #$phases
455 (replace 'setup
456 (lambda* (#:key inputs #:allow-other-keys)
457 (substitute* "lib/Driver/UnixToolChains.cpp"
458 (("return \"gold\";")
459 "return \"\";"))
460 (substitute* "include/swift/SIL/SILLinkage.h"
461 (("#include \"llvm/Support/ErrorHandling.h\"")
462 "#include <cstdint>\n#include \"llvm/Support/ErrorHandling.h\""))
463 (substitute* "include/swift/Basic/ExternalUnion.h"
464 (("#include \"llvm/Support/ErrorHandling.h\"")
465 "#include <cstdint>\n#include \"llvm/Support/ErrorHandling.h\""))
466 (substitute* "stdlib/CMakeLists.txt"
467 (("set\\(CMAKE_CXX_COMPILER \"\\$\\{SWIFT_NATIVE_LLVM_TOOLS_PATH\\}/clang\\+\\+\"\\)")
468 (string-append "set(CMAKE_CXX_COMPILER \""
469 (assoc-ref %build-inputs "swift-llvm")
470 "/bin/clang++\")"))
471 (("set\\(CMAKE_C_COMPILER \"\\$\\{SWIFT_NATIVE_LLVM_TOOLS_PATH\\}/clang\"\\)")
472 (string-append "set(CMAKE_C_COMPILER \""
473 (assoc-ref %build-inputs "swift-llvm")
474 "/bin/clang\")")))
475 (substitute* "stdlib/public/Platform/CMakeLists.txt"
476 (("set\\(GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH \"/usr/include\"\\)")
477 (string-append "set(GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH \""
478 (assoc-ref %build-inputs "glibc")
479 "/include\")")))
480 (substitute* "lib/Basic/CMakeLists.txt"
481 (("\\$\\{LLVM_MAIN_SRC_DIR\\}/cmake/modules/GenerateVersionFromVCS.cmake")
482 "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake"))
483 (substitute* "lib/Option/CMakeLists.txt"
484 (("\\$\\{LLVM_MAIN_SRC_DIR\\}/\\.\\./clang/tools/driver/features\\.json")
485 "${LLVM_BUILD_BINARY_DIR}/share/clang/features.json"))
486 ;; swiftBasic uses clangBasic symbols in Platform.cpp (DarwinSDKInfo)
487 ;; but doesn't declare it as a PUBLIC dependency. Add clangBasic to
488 ;; executables that link swiftBasic but not swiftAST (which provides it).
489 (substitute* "tools/swift-scan-test/CMakeLists.txt"
490 (("swiftBasic\n" all)
491 (string-append all " clangBasic\n")))
492 (substitute* "unittests/Remangler/CMakeLists.txt"
493 (("swiftBasic\n" all)
494 (string-append all " clangBasic\n")))
495 ;; Fix cmark-gfm path - use CMake-installed export with correct include paths
496 (substitute* "cmake/modules/SwiftSharedCMakeConfig.cmake"
497 (("\\$\\{PATH_TO_CMARK_BUILD\\}/src/cmarkTargets\\.cmake")
498 "${PATH_TO_CMARK_BUILD}/lib/cmake/cmark-gfm/cmark-gfm.cmake"))
499 ))))))
500 (native-inputs
501 (list cmake
502 ninja
503 perl
504 pkg-config
505 python-3
506 swift-bootstrap
507 swift-cmark-6.2
508 %swift-libdispatch-6.2-source
509 %swift-syntax-6.2-source))
510 (inputs
511 (list glibc icu4c libedit libxml2 swift-llvm-6.2 `(,util-linux "lib")))
512 (synopsis "Swift programming language")
513 (description
514 "Swift is a general-purpose programming language built using a modern
515approach to safety, performance, and software design patterns.")))