git: 95f54e562650 - main - lang/swift510: New port

From: Kurt Jaeger <pi_at_FreeBSD.org>
Date: Sun, 22 Jun 2025 09:12:47 UTC
The branch main has been updated by pi:

URL: https://cgit.FreeBSD.org/ports/commit/?id=95f54e562650032c2f9b27e9052d51de4237152f

commit 95f54e562650032c2f9b27e9052d51de4237152f
Author:     Jordan Gordeev <jgopensource@proton.me>
AuthorDate: 2025-06-22 09:11:40 +0000
Commit:     Kurt Jaeger <pi@FreeBSD.org>
CommitDate: 2025-06-22 09:11:40 +0000

    lang/swift510: New port
    
    The Swift programming language -- a modern programming language with
    many great features.
    
    This port includes:
     * the Swift compiler
     * the Swift standard library
     * various tools
     * the Foundation framework
     * the Swift Package Manager (SwiftPM)
     * the run-time support that you need for running compiled programs
    
    PR:             286454
    Reviewed-by:    kib
---
 lang/Makefile                                      |   1 +
 lang/swift510/Makefile                             | 108 +++
 lang/swift510/distinfo                             |  57 ++
 lang/swift510/files/patch-llbuild_Package.swift    |  33 +
 .../patch-llbuild_include_llvm_Config_config.h     |  11 +
 .../patch-llbuild_lib_LLBSQLite3_module.modulemap  |   8 +
 .../files/patch-llbuild_lib_LLBSQLite3_sqlite.h    |  17 +
 ...tch-llbuild_utils_adjust-times_adjust-times.cpp |  11 +
 ...oject_clang_tools_IndexStore_IndexStore.exports |  42 +
 ...-llvm-project_compiler-rt_cmake_config-ix.cmake |  13 +
 ...-project_compiler-rt_lib_tsan_dd_CMakeLists.txt |  11 +
 ...tch-swift-asn1_cmake_modules_SwiftSupport.cmake |  15 +
 ...t-certificates_cmake_modules_SwiftSupport.cmake |  15 +
 ...dation_CoreFoundation_Base.subproj_CFPlatform.c |  26 +
 ...oundation_Base.subproj_CoreFoundation__Prefix.h |  13 +
 ...tion_CoreFoundation_NumberDate.subproj_CFDate.c |  13 +
 ...eFoundation_PlugIn.subproj_CFBundle__Internal.h |  11 +
 ...tion_CoreFoundation_RunLoop.subproj_CFRunLoop.c | 324 +++++++
 ...tion_Sources_Foundation_FileManager+POSIX.swift |  11 +
 ...foundation_Sources_Foundation_FileManager.swift |  29 +
 ...relibs-foundation_Sources_Foundation_Host.swift |  29 +
 ...ibs-foundation_Sources_Foundation_NSError.swift |  20 +
 ...libs-foundation_Sources_Foundation_NSLock.swift |  28 +
 ...-foundation_Sources_Foundation_NSPlatform.swift |  11 +
 ...ndation_Sources_Foundation_NSSwiftRuntime.swift |  11 +
 ...relibs-foundation_Sources_Foundation_Port.swift |  31 +
 ...ibs-foundation_Sources_Foundation_Process.swift |  29 +
 ...libs-foundation_Sources_Foundation_Thread.swift |  38 +
 ...ibs-foundation_cmake_modules_SwiftSupport.cmake |  15 +
 ...bs-libdispatch_cmake_modules_SwiftSupport.cmake |  11 +
 ...ch-swift-corelibs-libdispatch_dispatch_source.h |  29 +
 .../patch-swift-corelibs-libdispatch_src_apply.c   |  10 +
 .../patch-swift-corelibs-libdispatch_src_data.c    |  11 +
 ...-corelibs-libdispatch_src_event_event__config.h |  19 +
 ...-corelibs-libdispatch_src_event_event__kevent.c | 141 +++
 ...wift-corelibs-libdispatch_src_event_workqueue.c | 106 +++
 ...ibs-libdispatch_src_event_workqueue__internal.h |  11 +
 .../patch-swift-corelibs-libdispatch_src_init.c    |  11 +
 .../patch-swift-corelibs-libdispatch_src_io.c      |  11 +
 .../patch-swift-corelibs-libdispatch_src_queue.c   |  90 ++
 ...tch-swift-corelibs-libdispatch_src_shims_lock.c |  70 ++
 ...tch-swift-corelibs-libdispatch_src_shims_lock.h |  28 +
 ...ift-corelibs-libdispatch_src_swift_Source.swift |  47 +
 ...ft-corelibs-libdispatch_src_swift_Wrapper.swift |  29 +
 ...swift-corelibs-libdispatch_tests_CMakeLists.txt |  10 +
 ...ift-corelibs-libdispatch_tests_bsdtestharness.c |  68 ++
 ...orelibs-xctest_cmake_modules_SwiftSupport.cmake |  15 +
 lang/swift510/files/patch-swift-crypto             | 686 +++++++++++++++
 ...h-swift-driver_Utilities_build-script-helper.py |  22 +
 ...h-swift-stress-tester_SwiftEvolve_Package.swift |  11 +
 ...-syntax_cmake_modules_AddSwiftHostLibrary.cmake |  20 +
 .../patch-swift-system_Sources_System_Errno.swift  |  50 ++
 ...system_Sources_System_Internals_Constants.swift |  32 +
 ...ols-support-core_Sources_TSCBasic_Process.swift |  29 +
 ...s-support-core_Sources_TSCUtility_FSWatch.swift |  29 +
 ...-core_Sources_TSCUtility_InterruptHandler.swift |  11 +
 ...ls-support-core_Sources_TSCUtility_Triple.swift |  28 +
 ...tch-swift_cmake_modules_AddSwiftUnittests.cmake |  11 +
 .../patch-swift_cmake_modules_SwiftCXXUtils.cmake  |   9 +
 ...tch-swift_cmake_modules_SwiftConfigureSDK.cmake |  11 +
 ...imizer_Differentiation_DifferentiationInvoker.h |  15 +
 ...patch-swift_lib_ClangImporter_ClangImporter.cpp |  27 +
 .../files/patch-swift_lib_IRGen_GenDecl.cpp        |  22 +
 .../swift510/files/patch-swift_lib_IRGen_IRGen.cpp |  12 +
 ...swift_stdlib_cmake_modules_AddSwiftStdlib.cmake |  13 +
 ...atch-swift_stdlib_public_Cxx_std_CMakeLists.txt |  11 +
 ...tch-swift_stdlib_public_Platform_Platform.swift |  35 +
 ...wift_stdlib_public_Platform_glibc.modulemap.gyb |  11 +
 ...lib_public_SwiftShims_swift_shims_SwiftStdint.h |  11 +
 .../patch-swift_stdlib_public_core_CTypes.swift    |  12 +
 .../patch-swift_stdlib_public_stubs_Random.cpp     |  11 +
 ...SourceKit_cmake_modules_AddSwiftSourceKit.cmake |  11 +
 ...atch-swift_tools_libStaticMirror_CMakeLists.txt |  11 +
 .../patch-swift_tools_libSwiftScan_CMakeLists.txt  |  11 +
 .../files/patch-swift_unittests_AST_CMakeLists.txt |  13 +
 ...ch-swift_unittests_ClangImporter_CMakeLists.txt |  13 +
 .../patch-swift_unittests_Driver_CMakeLists.txt    |  13 +
 .../files/patch-swift_unittests_IDE_CMakeLists.txt |  11 +
 .../patch-swift_unittests_Parse_CMakeLists.txt     |  13 +
 .../patch-swift_unittests_Sema_CMakeLists.txt      |  16 +
 .../files/patch-swift_utils_build-script-impl      |  61 ++
 ...support_swift__build__support_products_cmark.py |   7 +
 ...build__support_swift__build__support_targets.py |  20 +
 .../patch-swiftpm_Sources_Basics_Cancellator.swift |  11 +
 ...es_Basics_DispatchTimeInterval+Extensions.swift |  11 +
 ...atch-swiftpm_Sources_Basics_Triple+Basics.swift |  20 +
 ...pm_Sources_Basics_Vendor_Triple+Platforms.swift |  11 +
 ...atch-swiftpm_Sources_Basics_Vendor_Triple.swift |  20 +
 ...ldDescription_ClangTargetBuildDescription.swift |  17 +
 ...Sources_Build_BuildPlan_BuildPlan+Product.swift |  11 +
 ...patch-swiftpm_Sources_SPMSQLite3_CMakeLists.txt |  10 +
 .../patch-yams_cmake_modules_SwiftSupport.cmake    |  15 +
 lang/swift510/files/pkg-message.in                 |   2 +
 lang/swift510/files/start-build.sh                 |  34 +
 lang/swift510/pkg-descr                            |  10 +
 lang/swift510/pkg-plist                            | 946 +++++++++++++++++++++
 96 files changed, 4145 insertions(+)

diff --git a/lang/Makefile b/lang/Makefile
index 7167c559de66..7d08745b6d77 100644
--- a/lang/Makefile
+++ b/lang/Makefile
@@ -372,6 +372,7 @@
     SUBDIR += squeak
     SUBDIR += squirrel
     SUBDIR += starlark-rust
+    SUBDIR += swift510
     SUBDIR += swipl
     SUBDIR += tauthon
     SUBDIR += tcbasic
diff --git a/lang/swift510/Makefile b/lang/swift510/Makefile
new file mode 100644
index 000000000000..72b367b418f8
--- /dev/null
+++ b/lang/swift510/Makefile
@@ -0,0 +1,108 @@
+PORTNAME=	swift510
+DISTVERSION=	5.10.1
+CATEGORIES=	lang
+DIST_SUBDIR=	${PORTNAME}
+
+MAINTAINER=	jgopensource@proton.me
+COMMENT=	Swift programming language
+WWW=		https://www.swift.org/
+
+ONLY_FOR_ARCHS=	aarch64 amd64
+
+BUILD_DEPENDS=	bash:shells/bash \
+		cmake-core>=3.19.6:devel/cmake-core
+LIB_DEPENDS=	libcurl.so:ftp/curl \
+		libicuuc.so:devel/icu \
+		libuuid.so:misc/e2fsprogs-libuuid \
+		libxml2.so:textproc/libxml2 \
+		libzstd.so:archivers/zstd
+
+USES=		libedit ninja:build perl5 pkgconfig python:3.6+ \
+		shebangfix sqlite:3
+USE_GITHUB=	nodefault
+# The common tag which applies to most repos.
+tag=		swift-${DISTVERSION}-RELEASE
+GH_TUPLE=\
+	swiftlang:indexstore-db:${tag}:indexstore_db/indexstore-db \
+	swiftlang:llvm-project:${tag}:llvm_project/llvm-project \
+	swiftlang:sourcekit-lsp:${tag}:sourcekit_lsp/sourcekit-lsp \
+	swiftlang:swift:${tag}:swift/swift \
+	swiftlang:swift-cmark:${tag}:swift_cmark/cmark \
+	swiftlang:swift-corelibs-foundation:${tag}:swift_corelibs_foundation/swift-corelibs-foundation \
+	swiftlang:swift-corelibs-libdispatch:${tag}:swift_corelibs_libdispatch/swift-corelibs-libdispatch \
+	swiftlang:swift-corelibs-xctest:${tag}:swift_corelibs_xctest/swift-corelibs-xctest \
+	swiftlang:swift-docc:${tag}:swift_docc/swift-docc \
+	swiftlang:swift-docc-symbolkit:${tag}:swift_docc_symbolkit/swift-docc-symbolkit \
+	swiftlang:swift-driver:${tag}:swift_driver/swift-driver \
+	swiftlang:swift-experimental-string-processing:${tag}:swift_experimental_string_processing/swift-experimental-string-processing \
+	swiftlang:swift-format:${tag}:swift_format/swift-format \
+	swiftlang:swift-llbuild:${tag}:llbuild/llbuild \
+	swiftlang:swift-lmdb:${tag}:swift_lmdb/swift-lmdb \
+	swiftlang:swift-markdown:${tag}:swift_markdown/swift-markdown \
+	swiftlang:swift-package-manager:${tag}:swiftpm/swiftpm \
+	swiftlang:swift-stress-tester:${tag}:swift_stress_tester/swift-stress-tester \
+	swiftlang:swift-syntax:${tag}:swift_syntax/swift-syntax \
+	swiftlang:swift-tools-support-core:${tag}:swift_tools_support_core/swift-tools-support-core
+GH_TUPLE+=\
+	apple:swift-argument-parser:1.2.3:swift_argument_parser/swift-argument-parser \
+	apple:swift-asn1:1.0.0:swift_asn1/swift-asn1 \
+	apple:swift-certificates:1.0.1:swift_certificates/swift-certificates \
+	apple:swift-collections:1.0.1:swift_collections/swift-collections \
+	apple:swift-crypto:3.0.0:swift_crypto/swift-crypto \
+	apple:swift-nio:2.31.2:swift_nio/swift-nio \
+	apple:swift-system:1.1.1:swift_system/swift-system
+GH_TUPLE+=jpsim:Yams:5.0.1:yams/yams
+USE_PERL5=	build
+
+SHEBANG_FILES=\
+	swift/utils/api_checker/sdk-module-lists/infer-imports.py \
+	swift/utils/api_checker/swift-api-checker.py \
+	swift/utils/build-script \
+	swift/utils/swift-api-dump.py \
+	swift-driver/Utilities/build-script-helper.py \
+	swiftpm/Utilities/bootstrap \
+
+CONFLICTS=	libdispatch-[0-9]*
+
+value_for_aarch64=	aarch64
+value_for_amd64=	x86_64
+swift_arch=		${value_for_${ARCH}}
+early_stage_dir=	${WRKDIR}/EarlyStageDir
+swift_install_prefix=	${PREFIX}/${PORTNAME}
+MANDIRS=	${swift_install_prefix}/share/man
+
+SUB_FILES=	pkg-message
+SUB_LIST=	SWIFT_INSTALL_PREFIX=${swift_install_prefix}
+
+WRKSRC=		${WRKDIR}/swift-project
+
+PLIST_SUB=	SWIFT_ARCH=${swift_arch} \
+		SWIFT_TARGET_TRIPLE=${swift_arch}-unknown-freebsd${OSREL}
+
+.include <bsd.port.pre.mk>
+
+.if ${OSVERSION} >= 1304500 && ${OSVERSION} <= 1305502
+BROKEN=		Unbuildable due to a problem with libc++. See <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=286342>
+.endif
+
+pre-patch:
+	@${MKDIR} ${WRKSRC}/llbuild/lib/LLBSQLite3
+
+post-patch:
+	@${SED} -E -e 's@^python3=python3$$@python3=${PYTHON_CMD}@' -i .bak ${WRKSRC}/swift/utils/build-script-impl
+
+do-build:
+	@${MKDIR} ${early_stage_dir}
+	@${SH} ${FILESDIR}/start-build.sh ${WRKSRC} ${early_stage_dir} ${swift_install_prefix} ${WRKDIR}/clang-module-cache
+
+do-install:
+	@${FIND} ${early_stage_dir}${swift_install_prefix}/bin -type f -not -name '*.py' -not -name '*.sh' -not -name '*.txt' -exec ${STRIP_CMD} '{}' ';' ; \
+	${FIND} ${early_stage_dir}${swift_install_prefix} -type f -name '*.so*' -exec ${STRIP_CMD} '{}' ';' ; \
+	cd ${early_stage_dir} ; \
+	${COPYTREE_BIN} .${swift_install_prefix}/bin ${STAGEDIR} ; \
+	for subdir in include lib local share; do \
+		${COPYTREE_SHARE} .${swift_install_prefix}/$${subdir} ${STAGEDIR} ; \
+	done ; \
+	${RM} ${STAGEDIR}/var/run/libuuid/*
+
+.include <bsd.port.post.mk>
diff --git a/lang/swift510/distinfo b/lang/swift510/distinfo
new file mode 100644
index 000000000000..390bbe67277c
--- /dev/null
+++ b/lang/swift510/distinfo
@@ -0,0 +1,57 @@
+TIMESTAMP = 1744804731
+SHA256 (swift510/swiftlang-indexstore-db-swift-5.10.1-RELEASE_GH0.tar.gz) = 8be52307236e21e942972417fd3c8182a7865757f7890eec167851c75d156996
+SIZE (swift510/swiftlang-indexstore-db-swift-5.10.1-RELEASE_GH0.tar.gz) = 909365
+SHA256 (swift510/swiftlang-llvm-project-swift-5.10.1-RELEASE_GH0.tar.gz) = fad2de34c6c005b7bc63ce7b4f20d6cdf0e1d60109a7a589ffd782180c23102b
+SIZE (swift510/swiftlang-llvm-project-swift-5.10.1-RELEASE_GH0.tar.gz) = 171145818
+SHA256 (swift510/swiftlang-sourcekit-lsp-swift-5.10.1-RELEASE_GH0.tar.gz) = f83aabe6e66adc2d3ffb7e948ddfd805f7f58fd43c6b33d48bb4a50186ce0abb
+SIZE (swift510/swiftlang-sourcekit-lsp-swift-5.10.1-RELEASE_GH0.tar.gz) = 301167
+SHA256 (swift510/swiftlang-swift-swift-5.10.1-RELEASE_GH0.tar.gz) = 087c59a1b79c46dd23f8e6cb4fe12a27935a5b6581282f48db952827bb3fdf57
+SIZE (swift510/swiftlang-swift-swift-5.10.1-RELEASE_GH0.tar.gz) = 31977733
+SHA256 (swift510/swiftlang-swift-cmark-swift-5.10.1-RELEASE_GH0.tar.gz) = 6d209b8bf81fe0d67ae6d55913e7750ec752bc7fc29fc0ef5da2fdf8a6057406
+SIZE (swift510/swiftlang-swift-cmark-swift-5.10.1-RELEASE_GH0.tar.gz) = 311407
+SHA256 (swift510/swiftlang-swift-corelibs-foundation-swift-5.10.1-RELEASE_GH0.tar.gz) = 94dadc18f527f25cf1ce486d0ddce7de00f725063bc43526bdb73e534c8d97c3
+SIZE (swift510/swiftlang-swift-corelibs-foundation-swift-5.10.1-RELEASE_GH0.tar.gz) = 4479830
+SHA256 (swift510/swiftlang-swift-corelibs-libdispatch-swift-5.10.1-RELEASE_GH0.tar.gz) = affa3544b0fdb60f8f175bc0d2846177436d5848ef8ca73e3e560d23986f38b3
+SIZE (swift510/swiftlang-swift-corelibs-libdispatch-swift-5.10.1-RELEASE_GH0.tar.gz) = 594770
+SHA256 (swift510/swiftlang-swift-corelibs-xctest-swift-5.10.1-RELEASE_GH0.tar.gz) = cec269b435a9f32edcf90958abec16fcf50febcb99e389ed56e9e692c3270e27
+SIZE (swift510/swiftlang-swift-corelibs-xctest-swift-5.10.1-RELEASE_GH0.tar.gz) = 85377
+SHA256 (swift510/swiftlang-swift-docc-swift-5.10.1-RELEASE_GH0.tar.gz) = 1712b83aef420815e0cae2c10e43012435b249e3d138b2a6700adb18b4fc5b81
+SIZE (swift510/swiftlang-swift-docc-swift-5.10.1-RELEASE_GH0.tar.gz) = 16281601
+SHA256 (swift510/swiftlang-swift-docc-symbolkit-swift-5.10.1-RELEASE_GH0.tar.gz) = 2675a9faa010623e9252f84cefc82fbce217a6f3860c7495311cb9bdffa82159
+SIZE (swift510/swiftlang-swift-docc-symbolkit-swift-5.10.1-RELEASE_GH0.tar.gz) = 171631
+SHA256 (swift510/swiftlang-swift-driver-swift-5.10.1-RELEASE_GH0.tar.gz) = 75530eab66f4dffb9cecf422d0c5e582f08f84c8289ce245d48010e73ad1fc71
+SIZE (swift510/swiftlang-swift-driver-swift-5.10.1-RELEASE_GH0.tar.gz) = 2444415
+SHA256 (swift510/swiftlang-swift-experimental-string-processing-swift-5.10.1-RELEASE_GH0.tar.gz) = 7e6ea60653b580abaf0801d697971610e7e22b4eb427edcee486b741b14d2724
+SIZE (swift510/swiftlang-swift-experimental-string-processing-swift-5.10.1-RELEASE_GH0.tar.gz) = 2579674
+SHA256 (swift510/swiftlang-swift-format-swift-5.10.1-RELEASE_GH0.tar.gz) = 1e204fed64ef34217cc871b49a18ab4ddca4930945ac5f564723aadc3daf0bc5
+SIZE (swift510/swiftlang-swift-format-swift-5.10.1-RELEASE_GH0.tar.gz) = 253210
+SHA256 (swift510/swiftlang-swift-llbuild-swift-5.10.1-RELEASE_GH0.tar.gz) = 64d135c1aaf96636b0ff6a2682e605474fe9e33f740a8ba2a3c469e2c8ae9f38
+SIZE (swift510/swiftlang-swift-llbuild-swift-5.10.1-RELEASE_GH0.tar.gz) = 7092051
+SHA256 (swift510/swiftlang-swift-lmdb-swift-5.10.1-RELEASE_GH0.tar.gz) = fd9279b0a007f7c09bc28c614ecd0b055642aa3b08caeee607ca2c4904881ead
+SIZE (swift510/swiftlang-swift-lmdb-swift-5.10.1-RELEASE_GH0.tar.gz) = 153468
+SHA256 (swift510/swiftlang-swift-markdown-swift-5.10.1-RELEASE_GH0.tar.gz) = 568335f685b65f941edbb6771b4d13172ab8a538bf57a040bf8b61cf5717ac10
+SIZE (swift510/swiftlang-swift-markdown-swift-5.10.1-RELEASE_GH0.tar.gz) = 107990
+SHA256 (swift510/swiftlang-swift-package-manager-swift-5.10.1-RELEASE_GH0.tar.gz) = 3d35e35b6e7a061042d3cd4913030525462faa357901a91a2d2f037d12e5987c
+SIZE (swift510/swiftlang-swift-package-manager-swift-5.10.1-RELEASE_GH0.tar.gz) = 1522538
+SHA256 (swift510/swiftlang-swift-stress-tester-swift-5.10.1-RELEASE_GH0.tar.gz) = d5ef9fa05b28f773423a77caed1687f0744b01627fce50989c9ef09f76211c06
+SIZE (swift510/swiftlang-swift-stress-tester-swift-5.10.1-RELEASE_GH0.tar.gz) = 97998
+SHA256 (swift510/swiftlang-swift-syntax-swift-5.10.1-RELEASE_GH0.tar.gz) = 500ff2c6d9435311fa42ad2e87927a3025b6c3682c18ecb9710c522c0be52a53
+SIZE (swift510/swiftlang-swift-syntax-swift-5.10.1-RELEASE_GH0.tar.gz) = 1142270
+SHA256 (swift510/swiftlang-swift-tools-support-core-swift-5.10.1-RELEASE_GH0.tar.gz) = fbc2d5dcf4eb27e7e786a19559e4ab5af6469238e3e89b910511145874bdfc52
+SIZE (swift510/swiftlang-swift-tools-support-core-swift-5.10.1-RELEASE_GH0.tar.gz) = 240649
+SHA256 (swift510/apple-swift-argument-parser-1.2.3_GH0.tar.gz) = 4a10bbef290a2167c5cc340b39f1f7ff6a8cf4e1b5433b68548bf5f1e542e908
+SIZE (swift510/apple-swift-argument-parser-1.2.3_GH0.tar.gz) = 645638
+SHA256 (swift510/apple-swift-asn1-1.0.0_GH0.tar.gz) = e0da995ae53e6fcf8251887f44d4030f6600e2f8f8451d9c92fcaf52b41b6c35
+SIZE (swift510/apple-swift-asn1-1.0.0_GH0.tar.gz) = 72780
+SHA256 (swift510/apple-swift-certificates-1.0.1_GH0.tar.gz) = fcaca458aab45ee69b0f678b72c2194b15664cc5f6f5e48d0e3f62bc5d1202ca
+SIZE (swift510/apple-swift-certificates-1.0.1_GH0.tar.gz) = 456979
+SHA256 (swift510/apple-swift-collections-1.0.1_GH0.tar.gz) = 575cf0f88d9068411f9acc6e3ca5d542bef1cc9e87dc5d69f7b5a1d5aec8c6b6
+SIZE (swift510/apple-swift-collections-1.0.1_GH0.tar.gz) = 3787804
+SHA256 (swift510/apple-swift-crypto-3.0.0_GH0.tar.gz) = 5c860c0306d0393ff06268f361aaf958656e1288353a0e23c3ad20de04319154
+SIZE (swift510/apple-swift-crypto-3.0.0_GH0.tar.gz) = 6840005
+SHA256 (swift510/apple-swift-nio-2.31.2_GH0.tar.gz) = 8818b8e991d36e886b207ae1023fa43c5eada7d6a1951a52ad70f7f71f57d9fe
+SIZE (swift510/apple-swift-nio-2.31.2_GH0.tar.gz) = 761397
+SHA256 (swift510/apple-swift-system-1.1.1_GH0.tar.gz) = 865b8c380455eef27e73109835142920c60ae4c4f4178a3d12ad04acc83f1371
+SIZE (swift510/apple-swift-system-1.1.1_GH0.tar.gz) = 69981
+SHA256 (swift510/jpsim-Yams-5.0.1_GH0.tar.gz) = ec1ad699c30f0db45520006c63a88cc1c946a7d7b36dff32a96460388c0a4af2
+SIZE (swift510/jpsim-Yams-5.0.1_GH0.tar.gz) = 658324
diff --git a/lang/swift510/files/patch-llbuild_Package.swift b/lang/swift510/files/patch-llbuild_Package.swift
new file mode 100644
index 000000000000..e4621f4e7a7b
--- /dev/null
+++ b/lang/swift510/files/patch-llbuild_Package.swift
@@ -0,0 +1,33 @@
+--- llbuild/Package.swift.orig	2024-01-09 06:44:05 UTC
++++ llbuild/Package.swift
+@@ -71,6 +71,13 @@ let package = Package(
+             exclude: []
+         ),
+ 
++        // MARK: sqlite3 as a system library
++        .systemLibrary(
++            name: "LLBSQLite3",
++            path: "lib/LLBSQLite3",
++            pkgConfig: "sqlite3"
++        ),
++
+         // MARK: Components
+         
+         .target(
+@@ -80,7 +87,7 @@ let package = Package(
+         ),
+         .target(
+             name: "llbuildCore",
+-            dependencies: ["llbuildBasic"],
++            dependencies: ["llbuildBasic", "LLBSQLite3"],
+             path: "lib/Core",
+             linkerSettings: [.linkedLibrary("sqlite3")]
+         ),
+@@ -227,6 +234,7 @@ let package = Package(
+             path: "lib/llvm/Support",
+             linkerSettings: [
+                 .linkedLibrary("m", .when(platforms: [.linux])),
++                .linkedLibrary("execinfo"),
+                 .linkedLibrary("ncurses", .when(platforms: [.linux, .macOS, .android]))]
+         ),
+     ],
diff --git a/lang/swift510/files/patch-llbuild_include_llvm_Config_config.h b/lang/swift510/files/patch-llbuild_include_llvm_Config_config.h
new file mode 100644
index 000000000000..94ba8c26ee4c
--- /dev/null
+++ b/lang/swift510/files/patch-llbuild_include_llvm_Config_config.h
@@ -0,0 +1,11 @@
+--- llbuild/include/llvm/Config/config.h.orig	2024-01-09 06:44:05 UTC
++++ llbuild/include/llvm/Config/config.h
+@@ -131,7 +131,7 @@
+ /* #undef HAVE_LSEEK64 */
+ 
+ /* Define to 1 if you have the `mallctl' function. */
+-/* #undef HAVE_MALLCTL */
++#define HAVE_MALLCTL 1
+ 
+ /* Define to 1 if you have the `mallinfo' function. */
+ /* #undef HAVE_MALLINFO */
diff --git a/lang/swift510/files/patch-llbuild_lib_LLBSQLite3_module.modulemap b/lang/swift510/files/patch-llbuild_lib_LLBSQLite3_module.modulemap
new file mode 100644
index 000000000000..20e392f38485
--- /dev/null
+++ b/lang/swift510/files/patch-llbuild_lib_LLBSQLite3_module.modulemap
@@ -0,0 +1,8 @@
+--- llbuild/lib/LLBSQLite3/module.modulemap.orig	2025-01-01 00:00:00 UTC
++++ llbuild/lib/LLBSQLite3/module.modulemap
+@@ -0,0 +1,5 @@
++module LLBSQLite3 [system] {
++  header "sqlite.h"
++  link "sqlite3"
++  export *
++}
diff --git a/lang/swift510/files/patch-llbuild_lib_LLBSQLite3_sqlite.h b/lang/swift510/files/patch-llbuild_lib_LLBSQLite3_sqlite.h
new file mode 100644
index 000000000000..7ae3d43f097f
--- /dev/null
+++ b/lang/swift510/files/patch-llbuild_lib_LLBSQLite3_sqlite.h
@@ -0,0 +1,17 @@
+--- llbuild/lib/LLBSQLite3/sqlite.h.orig	2025-01-01 00:00:00 UTC
++++ llbuild/lib/LLBSQLite3/sqlite.h
+@@ -0,0 +1,14 @@
++//===----------------------------------------------------------------------===//
++//
++// This source file is part of the Swift open source project
++//
++// Copyright (c) 2014-2020 Apple Inc. and the Swift project authors
++// Licensed under Apache License v2.0 with Runtime Library Exception
++//
++// See http://swift.org/LICENSE.txt for license information
++// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
++//
++//===----------------------------------------------------------------------===//
++
++#pragma once
++#include <sqlite3.h>
diff --git a/lang/swift510/files/patch-llbuild_utils_adjust-times_adjust-times.cpp b/lang/swift510/files/patch-llbuild_utils_adjust-times_adjust-times.cpp
new file mode 100644
index 000000000000..405d2a985382
--- /dev/null
+++ b/lang/swift510/files/patch-llbuild_utils_adjust-times_adjust-times.cpp
@@ -0,0 +1,11 @@
+--- llbuild/utils/adjust-times/adjust-times.cpp.orig	2024-01-09 06:44:05 UTC
++++ llbuild/utils/adjust-times/adjust-times.cpp
+@@ -50,7 +50,7 @@ static int file_time_set_fixed(const char* filename, s
+     struct timeval times[2] = { tv, tv };
+     return utimes(filename, times);
+   }
+-#elif defined __linux__
++#elif defined __linux__ || defined(__FreeBSD__)
+   struct timespec times[2] = { time_to_set, time_to_set };
+   return utimensat(AT_FDCWD, filename, times, 0);
+ #else
diff --git a/lang/swift510/files/patch-llvm-project_clang_tools_IndexStore_IndexStore.exports b/lang/swift510/files/patch-llvm-project_clang_tools_IndexStore_IndexStore.exports
new file mode 100644
index 000000000000..5c7f5c4c371e
--- /dev/null
+++ b/lang/swift510/files/patch-llvm-project_clang_tools_IndexStore_IndexStore.exports
@@ -0,0 +1,42 @@
+--- llvm-project/clang/tools/IndexStore/IndexStore.exports.orig	2024-05-24 18:46:43 UTC
++++ llvm-project/clang/tools/IndexStore/IndexStore.exports
+@@ -10,9 +10,7 @@ indexstore_store_get_unit_name_from_output_path
+ indexstore_store_dispose
+ indexstore_store_get_unit_modification_time
+ indexstore_store_get_unit_name_from_output_path
+-indexstore_store_units_apply
+ indexstore_store_units_apply_f
+-indexstore_store_set_unit_event_handler
+ indexstore_store_set_unit_event_handler_f
+ indexstore_store_start_unit_event_listening
+ indexstore_store_stop_unit_event_listening
+@@ -33,19 +31,13 @@ indexstore_occurrence_get_line_col
+ indexstore_occurrence_get_symbol
+ indexstore_occurrence_get_roles
+ indexstore_occurrence_get_line_col
+-indexstore_occurrence_relations_apply
+ indexstore_occurrence_relations_apply_f
+ indexstore_record_reader_create
+ indexstore_record_reader_dispose
+-indexstore_record_reader_search_symbols
+ indexstore_record_reader_search_symbols_f
+-indexstore_record_reader_symbols_apply
+ indexstore_record_reader_symbols_apply_f
+-indexstore_record_reader_occurrences_apply
+ indexstore_record_reader_occurrences_apply_f
+-indexstore_record_reader_occurrences_in_line_range_apply
+ indexstore_record_reader_occurrences_in_line_range_apply_f
+-indexstore_record_reader_occurrences_of_symbols_apply
+ indexstore_record_reader_occurrences_of_symbols_apply_f
+ indexstore_unit_dependency_get_kind
+ indexstore_unit_dependency_get_filepath
+@@ -68,9 +60,7 @@ indexstore_unit_reader_get_target
+ indexstore_unit_reader_get_output_file
+ indexstore_unit_reader_get_sysroot_path
+ indexstore_unit_reader_get_target
+-indexstore_unit_reader_dependencies_apply
+ indexstore_unit_reader_dependencies_apply_f
+-indexstore_unit_reader_includes_apply
+ indexstore_unit_reader_includes_apply_f
+ indexstore_unit_reader_has_main_file
+ indexstore_unit_reader_is_debug_compilation
diff --git a/lang/swift510/files/patch-llvm-project_compiler-rt_cmake_config-ix.cmake b/lang/swift510/files/patch-llvm-project_compiler-rt_cmake_config-ix.cmake
new file mode 100644
index 000000000000..68b83511e683
--- /dev/null
+++ b/lang/swift510/files/patch-llvm-project_compiler-rt_cmake_config-ix.cmake
@@ -0,0 +1,13 @@
+--- llvm-project/compiler-rt/cmake/config-ix.cmake.orig	2024-05-24 18:46:43 UTC
++++ llvm-project/compiler-rt/cmake/config-ix.cmake
+@@ -237,6 +237,10 @@ test_targets()
+ 
+ test_targets()
+ 
++if(COMPILER_RT_SUPPORTED_ARCH)
++  list(REMOVE_ITEM COMPILER_RT_SUPPORTED_ARCH i386)
++endif()
++
+ # Returns a list of architecture specific target cflags in @out_var list.
+ function(get_target_flags_for_arch arch out_var)
+   list(FIND COMPILER_RT_SUPPORTED_ARCH ${arch} ARCH_INDEX)
diff --git a/lang/swift510/files/patch-llvm-project_compiler-rt_lib_tsan_dd_CMakeLists.txt b/lang/swift510/files/patch-llvm-project_compiler-rt_lib_tsan_dd_CMakeLists.txt
new file mode 100644
index 000000000000..e0bc673735d5
--- /dev/null
+++ b/lang/swift510/files/patch-llvm-project_compiler-rt_lib_tsan_dd_CMakeLists.txt
@@ -0,0 +1,11 @@
+--- llvm-project/compiler-rt/lib/tsan/dd/CMakeLists.txt.orig	2024-05-24 18:46:43 UTC
++++ llvm-project/compiler-rt/lib/tsan/dd/CMakeLists.txt
+@@ -23,7 +23,7 @@ set_target_properties(dd PROPERTIES FOLDER "Compiler-R
+ set_target_properties(dd PROPERTIES FOLDER "Compiler-RT Misc")
+ 
+ # Deadlock detector is currently supported on 64-bit Linux only.
+-if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE AND NOT ANDROID)
++if(FALSE)
+   set(arch "x86_64")
+   add_compiler_rt_runtime(clang_rt.dd
+     STATIC
diff --git a/lang/swift510/files/patch-swift-asn1_cmake_modules_SwiftSupport.cmake b/lang/swift510/files/patch-swift-asn1_cmake_modules_SwiftSupport.cmake
new file mode 100644
index 000000000000..6f7457b09293
--- /dev/null
+++ b/lang/swift510/files/patch-swift-asn1_cmake_modules_SwiftSupport.cmake
@@ -0,0 +1,15 @@
+--- swift-asn1/cmake/modules/SwiftSupport.cmake.orig	2023-09-18 10:20:51 UTC
++++ swift-asn1/cmake/modules/SwiftSupport.cmake
+@@ -42,6 +42,12 @@ function(get_swift_host_arch result_var_name)
+     set("${result_var_name}" "armv7" PARENT_SCOPE)
+   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
+     set("${result_var_name}" "x86_64" PARENT_SCOPE)
++  elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64")
++    if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
++      set("${result_var_name}" "x86_64" PARENT_SCOPE)
++    else()
++      set("${result_var_name}" "amd64" PARENT_SCOPE)
++    endif()
+   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "IA64")
+     set("${result_var_name}" "itanium" PARENT_SCOPE)
+   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86")
diff --git a/lang/swift510/files/patch-swift-certificates_cmake_modules_SwiftSupport.cmake b/lang/swift510/files/patch-swift-certificates_cmake_modules_SwiftSupport.cmake
new file mode 100644
index 000000000000..98f5546321e8
--- /dev/null
+++ b/lang/swift510/files/patch-swift-certificates_cmake_modules_SwiftSupport.cmake
@@ -0,0 +1,15 @@
+--- swift-certificates/cmake/modules/SwiftSupport.cmake.orig	2023-09-25 17:11:14 UTC
++++ swift-certificates/cmake/modules/SwiftSupport.cmake
+@@ -42,6 +42,12 @@ function(get_swift_host_arch result_var_name)
+     set("${result_var_name}" "armv7" PARENT_SCOPE)
+   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
+     set("${result_var_name}" "x86_64" PARENT_SCOPE)
++  elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64")
++    if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
++      set("${result_var_name}" "x86_64" PARENT_SCOPE)
++    else()
++      set("${result_var_name}" "amd64" PARENT_SCOPE)
++    endif()
+   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "IA64")
+     set("${result_var_name}" "itanium" PARENT_SCOPE)
+   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86")
diff --git a/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_Base.subproj_CFPlatform.c b/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_Base.subproj_CFPlatform.c
new file mode 100644
index 000000000000..fd55c454982b
--- /dev/null
+++ b/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_Base.subproj_CFPlatform.c
@@ -0,0 +1,26 @@
+--- swift-corelibs-foundation/CoreFoundation/Base.subproj/CFPlatform.c.orig	2024-05-31 00:46:27 UTC
++++ swift-corelibs-foundation/CoreFoundation/Base.subproj/CFPlatform.c
+@@ -125,7 +125,7 @@ static inline void _CFSetProgramNameFromPath(const cha
+     __CFprogname = (__CFprogname ? __CFprogname + 1 : __CFProcessPath);
+ }
+ 
+-#if TARGET_OS_BSD && defined(__OpenBSD__)
++#if TARGET_OS_BSD && (defined(__OpenBSD__) || defined(__FreeBSD__))
+ #include <sys/types.h>
+ #include <sys/sysctl.h>
+ #include <sys/exec.h>
+@@ -199,6 +199,14 @@ const char *_CFProcessPath(void) {
+         struct ps_strings *ps = _ps.val;
+         char *res = realpath(ps->ps_argvstr[0], NULL);
+         argv0 = res? res: strdup(ps->ps_argvstr[0]);
++    }
++#elif defined(__FreeBSD__)
++    int mib[2] = {CTL_KERN, KERN_PS_STRINGS};
++    struct ps_strings *ps;
++    size_t oldlen = sizeof(ps);
++    if (sysctl(mib, 2, &ps, &oldlen, NULL, 0) != -1 && oldlen == sizeof(ps)) {
++        char *res = realpath(ps->ps_argvstr[0], NULL);
++	argv0 = (res != NULL) ? res : strdup(ps->ps_argvstr[0]);
+     }
+ #endif
+ 
diff --git a/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_Base.subproj_CoreFoundation__Prefix.h b/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_Base.subproj_CoreFoundation__Prefix.h
new file mode 100644
index 000000000000..68089e02d030
--- /dev/null
+++ b/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_Base.subproj_CoreFoundation__Prefix.h
@@ -0,0 +1,13 @@
+--- swift-corelibs-foundation/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h.orig	2024-05-31 00:46:27 UTC
++++ swift-corelibs-foundation/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h
+@@ -260,6 +260,10 @@ CF_INLINE uint64_t mach_absolute_time() {
+     ULONGLONG ullTime;
+ 	QueryUnbiasedInterruptTimePrecise(&ullTime);
+     return ullTime;
++#elif defined(__FreeBSD__)
++    struct timespec ts;
++    clock_gettime(CLOCK_UPTIME, &ts);
++    return (uint64_t)ts.tv_nsec + (uint64_t)ts.tv_sec * 1000000000UL;
+ #elif TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_MAC
+     struct timespec ts;
+     clock_gettime(CLOCK_MONOTONIC, &ts);
diff --git a/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_NumberDate.subproj_CFDate.c b/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_NumberDate.subproj_CFDate.c
new file mode 100644
index 000000000000..33a067383138
--- /dev/null
+++ b/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_NumberDate.subproj_CFDate.c
@@ -0,0 +1,13 @@
+--- swift-corelibs-foundation/CoreFoundation/NumberDate.subproj/CFDate.c.orig	2024-05-31 00:46:27 UTC
++++ swift-corelibs-foundation/CoreFoundation/NumberDate.subproj/CFDate.c
+@@ -176,6 +176,10 @@ CF_PRIVATE void __CFDateInitialize(void) {
+     // To get seconds we need to divide the value by 1e7 (10000000).
+     __CFTSRRate = 1.0e7;
+     __CF1_TSRRate = 1.0 / __CFTSRRate;
++#elif defined(__FreeBSD__)
++    // FreeBSD uses nanoseconds
++    __CFTSRRate = 1.0E9;
++    __CF1_TSRRate = 1.0 / __CFTSRRate;
+ #elif TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI
+     struct timespec res;
+     if (clock_getres(CLOCK_MONOTONIC, &res) != 0) {
diff --git a/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_PlugIn.subproj_CFBundle__Internal.h b/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_PlugIn.subproj_CFBundle__Internal.h
new file mode 100644
index 000000000000..29e750e20138
--- /dev/null
+++ b/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_PlugIn.subproj_CFBundle__Internal.h
@@ -0,0 +1,11 @@
+--- swift-corelibs-foundation/CoreFoundation/PlugIn.subproj/CFBundle_Internal.h.orig	2024-05-31 00:46:27 UTC
++++ swift-corelibs-foundation/CoreFoundation/PlugIn.subproj/CFBundle_Internal.h
+@@ -429,7 +429,7 @@ static bool _CFGetPathFromFileDescriptor(int fd, char 
+ // The buffer must be PATH_MAX long or more.
+ static bool _CFGetPathFromFileDescriptor(int fd, char *path);
+ 
+-#if TARGET_OS_MAC || (TARGET_OS_BSD && !defined(__OpenBSD__))
++#if TARGET_OS_MAC
+ 
+ static bool _CFGetPathFromFileDescriptor(int fd, char *path) {
+     return fcntl(fd, F_GETPATH, path) != -1;
diff --git a/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_RunLoop.subproj_CFRunLoop.c b/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_RunLoop.subproj_CFRunLoop.c
new file mode 100644
index 000000000000..7b8c62788bd9
--- /dev/null
+++ b/lang/swift510/files/patch-swift-corelibs-foundation_CoreFoundation_RunLoop.subproj_CFRunLoop.c
@@ -0,0 +1,324 @@
+--- swift-corelibs-foundation/CoreFoundation/RunLoop.subproj/CFRunLoop.c.orig	2024-05-31 00:46:27 UTC
++++ swift-corelibs-foundation/CoreFoundation/RunLoop.subproj/CFRunLoop.c
+@@ -115,6 +115,14 @@ extern void _dispatch_main_queue_callback_4CF(void *_N
+ dispatch_runloop_handle_t _dispatch_get_main_queue_port_4CF(void);
+ extern void _dispatch_main_queue_callback_4CF(void *_Null_unspecified msg);
+ 
++#elif defined(__FreeBSD__)
++
++#include <sys/event.h>
++#include <dlfcn.h>
++
++extern dispatch_runloop_handle_t _dispatch_get_main_queue_port_4CF(void);
++extern void _dispatch_main_queue_callback_4CF(void *_Null_unspecified msg);
++
+ #else
+ dispatch_runloop_handle_t _dispatch_get_main_queue_port_4CF(void);
+ extern void _dispatch_main_queue_callback_4CF(void *_Null_unspecified msg);
+@@ -451,6 +459,98 @@ CF_INLINE void __CFPortSetFree(__CFPortSet portSet) {
+ CF_INLINE void __CFPortSetFree(__CFPortSet portSet) {
+     close(portSet);
+ }
++
++#elif defined(__FreeBSD__)
++
++// A file descriptor.
++typedef int __CFPort;
++// A timer port is a kqueue which monitors a single EVFILT_TIMER event (when the timer is armed).
++// A wakeup port is a kqueue which monitors a single EVFILT_USER event.
++
++#define CFPORT_NULL (-1)
++
++// A kqueue file descriptor.
++typedef int __CFPortSet;
++
++#define CFPORTSET_NULL (-1)
++
++
++static void __THE_SYSTEM_HAS_NO_PORTS_AVAILABLE__(kern_return_t ret) __attribute__((noinline));
++static void __THE_SYSTEM_HAS_NO_PORTS_AVAILABLE__(kern_return_t ret) { HALT; };
++
++static __CFPort __CFPortAllocate(uintptr_t guard) {
++    __CFPort kq = kqueuex(KQUEUE_CLOEXEC);
++    if (kq == -1) {
++        __THE_SYSTEM_HAS_NO_PORTS_AVAILABLE__(errno);
++        return CFPORT_NULL;
++    }
++    struct kevent kev = {
++        .ident = 0,
++        .filter = EVFILT_USER,
++        .flags = EV_ADD | EV_CLEAR,
++    };
++    int r = kevent(kq, &kev, 1, NULL, 0, NULL);
++    if (r == -1) {
++	HALT;
++        return CFPORT_NULL;
++    }
++    return kq;
++}
++
++static void __CFPortFree(__CFPort port, uintptr_t guard) {
++    close(port);
++}
++
++static void __THE_SYSTEM_HAS_NO_PORT_SETS_AVAILABLE__(kern_return_t ret) __attribute__((noinline));
++static void __THE_SYSTEM_HAS_NO_PORT_SETS_AVAILABLE__(kern_return_t ret) { HALT; }
++
++static __CFPortSet __CFPortSetAllocate(void) {
++    __CFPort kq = kqueuex(KQUEUE_CLOEXEC);
++    if (kq == -1) {
++        __THE_SYSTEM_HAS_NO_PORT_SETS_AVAILABLE__(errno);
++        return CFPORT_NULL;
++    }
++    return kq;
++}
++
++static kern_return_t __CFPortSetInsert(__CFPort port, __CFPortSet portSet) {
++    if (port == CFPORT_NULL) {
++        return -1;
++    }
++    struct kevent kev = {
++        .ident = (uintptr_t)port,
++        .filter = EVFILT_READ,
++        .flags = EV_ADD,
++    };
++    int r = kevent(portSet, &kev, 1, NULL, 0, NULL);
++    if (r == -1) {
++        return errno;
++    } else {
++        return 0;
++    }
++}
++
++static kern_return_t __CFPortSetRemove(__CFPort port, __CFPortSet portSet) {
++    if (port == CFPORT_NULL) {
++        return -1;
++    }
++    struct kevent kev = {
++        .ident = (uintptr_t)port,
++        .filter = EVFILT_READ,
++        .flags = EV_DELETE,
++    };
++    int r = kevent(portSet, &kev, 1, NULL, 0, NULL);
++    if (r == -1) {
++        return errno;
++    } else {
++        return 0;
++    }
++}
++
++static void __CFPortSetFree(__CFPortSet portSet) {
++    close(portSet);
++}
++
+ #elif TARGET_OS_BSD
+ 
+ #include <sys/types.h>
+@@ -823,6 +923,58 @@ static kern_return_t mk_timer_cancel(HANDLE name, Abso
+     }
+     return (int)res;
+ }
++#elif defined(__FreeBSD__)
++static __CFPort mk_timer_create(void) {
++    __CFPort kq = kqueuex(KQUEUE_CLOEXEC);
++    if (kq == -1) {
++        HALT;
++        return CFPORT_NULL;
++    }
++    return kq;
++}
++
++static kern_return_t mk_timer_destroy(__CFPort name) {
++    return close(name);
++}
++
++static kern_return_t mk_timer_cancel(__CFPort timer, AbsoluteTime *result_time) {
++    struct kevent kev = {
++        .ident = 0,
++        .filter = EVFILT_TIMER,
++        .flags = EV_DELETE,
++    };
++    int r = kevent(timer, &kev, 1, NULL, 0, NULL);
++    // The returned values are ignored.
++    *result_time = (struct UnsignedWide){ .hi = 0, .lo = 0 };
++    return 0;
++}
++
++static kern_return_t mk_timer_arm(__CFPort timer, uint64_t expire_time) {
++    struct kevent kev = {
++        .ident = 0,
++        .filter = EVFILT_TIMER,
++        .flags = EV_ADD,
++        .fflags = NOTE_NSECONDS | NOTE_ABSTIME,
++        .data = (int64_t)expire_time,
++    };
++    int r = kevent(timer, &kev, 1, NULL, 0, NULL);
++    // The returned value is ignored.
++    return 0;
++}
++
++static Boolean __CFPortTriggerWakeup(__CFPort wakeupPort) {
++    struct kevent kev = {
++        .ident = 0,
++        .filter = EVFILT_USER,
++        .fflags = NOTE_TRIGGER,
++    };
++    int r = kevent(wakeupPort, &kev, 1, NULL, 0, NULL);
++    if (r == -1) {
++        return false;
++    } else {
++        return true;
++    }
++}
+ #elif TARGET_OS_BSD
+ /*
+  * This implementation of the mk_timer_* stubs is defined with the
+@@ -1136,7 +1288,7 @@ static CFRunLoopModeRef __CFRunLoopCopyMode(CFRunLoopR
+     if (KERN_SUCCESS != ret) CRASH("*** Unable to insert timer port into port set. (%d) ***", ret);
+ #endif
+     rlm->_timerPort = CFPORT_NULL;
+-#if TARGET_OS_BSD
++#if TARGET_OS_BSD && !defined(__FreeBSD__)
+     rlm->_timerPort = mk_timer_create(rlm->_portSet);
+ #else
+     rlm->_timerPort = mk_timer_create();
+@@ -2412,7 +2564,7 @@ static void __CFArmNextTimerInMode(CFRunLoopModeRef rl
+                 // <rdar://problem/14447675>
+                 
+                 // Cancel the mk timer
+-                if (rlm->_mkTimerArmed && rlm->_timerPort) {
++                if (rlm->_mkTimerArmed && rlm->_timerPort != CFPORT_NULL) {
+                     AbsoluteTime dummy;
+                     mk_timer_cancel(rlm->_timerPort, &dummy);
+                     rlm->_mkTimerArmed = false;
+@@ -2430,20 +2582,20 @@ static void __CFArmNextTimerInMode(CFRunLoopModeRef rl
+                 }
+                 
+                 // Arm the mk timer
+-                if (rlm->_timerPort) {
++                if (rlm->_timerPort != CFPORT_NULL) {
+                     mk_timer_arm(rlm->_timerPort, nextSoftDeadline);
+                     rlm->_mkTimerArmed = true;
+                 }
+             }
+ #else
+-            if (rlm->_timerPort) {
++            if (rlm->_timerPort != CFPORT_NULL) {
+                 mk_timer_arm(rlm->_timerPort, nextSoftDeadline);
+             }
+ #endif
+         } else if (nextSoftDeadline == UINT64_MAX) {
+             // Disarm the timers - there is no timer scheduled
+             
+-            if (rlm->_mkTimerArmed && rlm->_timerPort) {
++            if (rlm->_mkTimerArmed && rlm->_timerPort != CFPORT_NULL) {
+                 AbsoluteTime dummy;
+                 mk_timer_cancel(rlm->_timerPort, &dummy);
+                 rlm->_mkTimerArmed = false;
+@@ -2916,6 +3068,56 @@ static Boolean __CFRunLoopWaitForMultipleObjects(__CFP
+     return result;
+ }
+ 
++#elif defined(__FreeBSD__)
++
++#define TIMEOUT_INFINITY (-1)
++
++static Boolean __CFRunLoopServicePorts(__CFPortSet portSet, __CFPort singlePort, __CFPort *livePort, int timeout) {
++    *livePort = CFPORT_NULL;
++    if (TIMEOUT_INFINITY == timeout) {
++        CFRUNLOOP_SLEEP();
++    } else {
++        CFRUNLOOP_POLL();
++    }
++    const struct timespec poll_ts = { .tv_sec = 0, .tv_nsec = 0 };
++    struct kevent kev;
++    if (portSet != CFPORTSET_NULL) {
++        // Find out which port has an event waiting.
++        int r = kevent(portSet, NULL, 0, &kev, 1, (timeout == TIMEOUT_INFINITY) ? NULL : &poll_ts);
++        CFRUNLOOP_WAKEUP(r);
++        if (r == 1) {
++            int kq2 = (int)kev.ident;
++            // Receive the event.
++            int r2 = kevent(kq2, NULL, 0, &kev, 1, &poll_ts);
++            if (r2 == 1) {
++                *livePort = kq2;
++                return true;
++            } else if (r2 == 0) {
++                return false;
++            } else {
++                HALT;
++                return false;
++            }
++        } else if (r == 0) {
++            return false;
++        } else {
++            HALT;
++            return false;
++        }
++    } else {
++        int r = kevent(singlePort, NULL, 0, &kev, 1, (timeout == TIMEOUT_INFINITY) ? NULL : &poll_ts);
++        CFRUNLOOP_WAKEUP(r);
++        if (r == 1) {
++            *livePort = singlePort;
++            return true;
++        } else if (r == 0) {
++            return false;
++        } else {
++            HALT;
++            return false;
++        }
++    }
++}
+ #endif
+ 
+ /* rl, rlm are locked on entrance and exit */
+@@ -3034,6 +3236,10 @@ static int32_t __CFRunLoopRun(CFRunLoopRef rl, CFRunLo
+             if (__CFRunLoopWaitForMultipleObjects(NULL, &dispatchPort, 0, 0, &livePort, NULL)) {
+                 goto handle_msg;
+             }
++#elif defined(__FreeBSD__)
++            if (__CFRunLoopServicePorts(CFPORTSET_NULL, dispatchPort, &livePort, 0)) {
++                goto handle_msg;
++            }
+ #elif TARGET_OS_BSD
+             if (__CFRunLoopServiceFileDescriptors(CFPORTSET_NULL, dispatchPort, 0, &livePort)) {
+                 goto handle_msg;
+@@ -3095,6 +3301,8 @@ static int32_t __CFRunLoopRun(CFRunLoopRef rl, CFRunLo
+         __CFRunLoopWaitForMultipleObjects(waitSet, NULL, poll ? 0 : TIMEOUT_INFINITY, rlm->_msgQMask, &livePort, &windowsMessageReceived);
+ #elif TARGET_OS_LINUX
+         __CFRunLoopServiceFileDescriptors(waitSet, CFPORT_NULL, poll ? 0 : TIMEOUT_INFINITY, &livePort);
++#elif defined(__FreeBSD__)
++        __CFRunLoopServicePorts(waitSet, CFPORT_NULL, &livePort, poll ? 0 : TIMEOUT_INFINITY);
+ #elif TARGET_OS_BSD
+         __CFRunLoopServiceFileDescriptors(waitSet, CFPORT_NULL, poll ? 0 : TIMEOUT_INFINITY, &livePort);
+ #else
+@@ -3406,6 +3614,9 @@ void CFRunLoopWakeUp(CFRunLoopRef rl) {
+     CFAssert1(0 == ret, __kCFLogAssertion, "%s(): Unable to send wake message to eventfd", __PRETTY_FUNCTION__);
+ #elif TARGET_OS_WIN32
+     SetEvent(rl->_wakeUpPort);
++#elif defined(__FreeBSD__)
++    Boolean success = __CFPortTriggerWakeup(rl->_wakeUpPort);
++    if (!success) HALT;
+ #elif TARGET_OS_BSD
+     __CFPortTrigger(rl->_wakeUpPort);
+ #else
+@@ -4131,6 +4342,10 @@ CFRunLoopSourceRef CFRunLoopSourceCreate(CFAllocatorRe
+ 	size = sizeof(CFRunLoopSourceContext);
+ 	break;
+     case 1:
++#if defined(__FreeBSD__)
++	// V1 sources are not implemented on FreeBSD yet
++	HALT;
++#endif
+ 	size = sizeof(CFRunLoopSourceContext1);
+ 	break;
+     }
+@@ -4275,7 +4490,7 @@ static CFStringRef __CFRunLoopObserverCopyDescription(
+     }
+ #if TARGET_OS_WIN32
+     result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFRunLoopObserver %p [%p]>{valid = %s, activities = 0x%x, repeats = %s, order = %d, callout = %p, context = %@}"), cf, CFGetAllocator(rlo), __CFIsValid(rlo) ? "Yes" : "No", rlo->_activities, __CFRunLoopObserverRepeats(rlo) ? "Yes" : "No", rlo->_order, rlo->_callout, contextDesc);    
+-#elif TARGET_OS_MAC || (TARGET_OS_LINUX && !TARGET_OS_CYGWIN)
++#elif TARGET_OS_MAC || (TARGET_OS_LINUX && !TARGET_OS_CYGWIN) || defined(__FreeBSD__)
+     void *addr = rlo->_callout;
+     Dl_info info;
+     const char *name = (dladdr(addr, &info) && info.dli_saddr == addr && info.dli_sname) ? info.dli_sname : "???";
diff --git a/lang/swift510/files/patch-swift-corelibs-foundation_Sources_Foundation_FileManager+POSIX.swift b/lang/swift510/files/patch-swift-corelibs-foundation_Sources_Foundation_FileManager+POSIX.swift
new file mode 100644
index 000000000000..0056f21febc2
--- /dev/null
+++ b/lang/swift510/files/patch-swift-corelibs-foundation_Sources_Foundation_FileManager+POSIX.swift
@@ -0,0 +1,11 @@
+--- swift-corelibs-foundation/Sources/Foundation/FileManager+POSIX.swift.orig	2024-05-31 00:46:27 UTC
++++ swift-corelibs-foundation/Sources/Foundation/FileManager+POSIX.swift
+@@ -70,7 +70,7 @@ extension FileManager {
+             }
+             urls = mountPoints(statBuf, Int(fsCount))
+         }
+-#elseif os(OpenBSD)
++#elseif os(OpenBSD) || os(FreeBSD)
+         func mountPoints(_ statBufs: UnsafePointer<statfs>, _ fsCount: Int) -> [URL] {
+             var urls: [URL] = []
+ 
diff --git a/lang/swift510/files/patch-swift-corelibs-foundation_Sources_Foundation_FileManager.swift b/lang/swift510/files/patch-swift-corelibs-foundation_Sources_Foundation_FileManager.swift
new file mode 100644
index 000000000000..99e66583fe93
--- /dev/null
*** 3863 LINES SKIPPED ***