Skip to content

Instantly share code, notes, and snippets.

View colemancda's full-sized avatar
🏎️
Working with Swift on ARM

Alsey Coleman Miller colemancda

🏎️
Working with Swift on ARM
View GitHub Profile
diff --git a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
index 98ecb4e1..4f66e89b 100644
--- a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
+++ b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
@@ -44,6 +44,7 @@ extension GenericUnixToolchain {
// 'armv6', so just take a brute-force approach
if triple.archName.contains("armv7") { return "armv7" }
if triple.archName.contains("armv6") { return "armv6" }
+ if triple.archName.contains("armv5") { return "armv5" }
return triple.archName
diff --git a/Sources/TSCUtility/Triple.swift b/Sources/TSCUtility/Triple.swift
index 0b682c8..5f2dbd3 100644
--- a/Sources/TSCUtility/Triple.swift
+++ b/Sources/TSCUtility/Triple.swift
@@ -45,6 +45,8 @@ public struct Triple: Encodable, Equatable {
case aarch64
case amd64
case armv7
+ case armv6
+ case armv5
@colemancda
colemancda / qemu_ppc_mac99_defconfig
Created March 27, 2022 23:09
Buildroot PowerPC-32 bit QEMU with Swift 5.6 configuration
# Architecture
BR2_powerpc=y
BR2_powerpc_7400=y
# System
BR2_SYSTEM_DHCP="eth0"
# Kernel
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
@colemancda
colemancda / swift-ppc32-buildroot-config
Created March 27, 2022 23:07
Swift 5.6 for PowerPC 32-bit Buildroot configuration
#
# Automatically generated file; DO NOT EDIT.
# Buildroot 2022.02-393-g65b624f3bc-dirty Configuration
#
BR2_HAVE_DOT_CONFIG=y
BR2_HOST_GCC_AT_LEAST_4_9=y
BR2_HOST_GCC_AT_LEAST_5=y
BR2_HOST_GCC_AT_LEAST_6=y
BR2_HOST_GCC_AT_LEAST_7=y
BR2_HOST_GCC_AT_LEAST_8=y
@colemancda
colemancda / swift-5.6-ppc32-buildroot.patch
Created March 27, 2022 23:05
Swift 5.6 for Buildroot with PowerPC 32-bit support
diff --git a/package/Config.in b/package/Config.in
index 0d5d763180..b89a49913e 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1422,6 +1422,7 @@ menu "Crypto"
source "package/openssl/Config.in"
source "package/pkcs11-helper/Config.in"
source "package/rhash/Config.in"
+ source "package/swift-crypto/Config.in"
source "package/tinydtls/Config.in"
@colemancda
colemancda / swift-apt-repo-install.sh
Created March 26, 2022 04:09 — forked from futurejones/swift-apt-repo-install.sh
Install script for the Swift Community Apt Repository - https://archive.swiftlang.xyz
#! /bin/bash
#
# Install script for the Swift Community Apt Repository - swiftlang.xyz
#
# check distribution version and infer distro with switch/case
## as all distribution versions have different names we can use this information to infer the distribution name.
check_ver () {
for var in "${SUPPORTED_VER[@]}"
do
@colemancda
colemancda / swift-5.5.3-float16.patch
Created March 19, 2022 04:39
Swift 5.5.3 Float16 shim
diff --git a/stdlib/public/runtime/Float16Support.cpp b/stdlib/public/runtime/Float16Support.cpp
index 817739d4cdf..26d8231d01b 100644
--- a/stdlib/public/runtime/Float16Support.cpp
+++ b/stdlib/public/runtime/Float16Support.cpp
@@ -30,7 +30,7 @@
// Android NDK <r21 do not provide `__aeabi_d2h` in the compiler runtime,
// provide shims in that case.
#if (defined(__ANDROID__) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
- ((defined(__i386__) || defined(__i686__) || defined(__x86_64__)) && !defined(__APPLE__))
+ ((defined(__i386__) || defined(__i686__) || defined(__x86_64__) || defined(__mips__)) && !defined(__APPLE__))
@colemancda
colemancda / swift-5.5.3-soft-float.patch
Created March 19, 2022 04:11
Swift 5.5.3 Soft Float patch
diff --git a/stdlib/cmake/modules/SwiftSource.cmake b/stdlib/cmake/modules/SwiftSource.cmake
index 280e18f8774..6a922b75116 100644
--- a/stdlib/cmake/modules/SwiftSource.cmake
+++ b/stdlib/cmake/modules/SwiftSource.cmake
@@ -467,6 +467,7 @@ function(_compile_swift_files
endif()
list(APPEND swift_flags ${SWIFT_EXPERIMENTAL_EXTRA_FLAGS})
+ list(APPEND swift_flags "-Xcc" "-msoft-float")
@colemancda
colemancda / foundation-5.6-mips.patch
Last active March 18, 2022 18:35
Foundation 5.6 patched for MIPS
diff --git a/Darwin/Foundation-swiftoverlay/Data.swift b/Darwin/Foundation-swiftoverlay/Data.swift
index d1a4386d..31ba9847 100644
--- a/Darwin/Foundation-swiftoverlay/Data.swift
+++ b/Darwin/Foundation-swiftoverlay/Data.swift
@@ -653,11 +653,11 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
@usableFromInline
@frozen
internal struct InlineData {
-#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le)
+#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el)
@colemancda
colemancda / swift-5.6-mips-stdlib-flags.patch
Created March 18, 2022 17:16
Swift 5.6 Soft Float patch for MIPS
diff --git a/stdlib/cmake/modules/SwiftSource.cmake b/stdlib/cmake/modules/SwiftSource.cmake
index 4bc312f7f89..1e0589ad9a0 100644
--- a/stdlib/cmake/modules/SwiftSource.cmake
+++ b/stdlib/cmake/modules/SwiftSource.cmake
@@ -519,6 +519,7 @@ function(_compile_swift_files
endif()
list(APPEND swift_flags ${SWIFT_STDLIB_EXTRA_SWIFT_COMPILE_FLAGS})
+ list(APPEND swift_flags "-Xcc" "-msoft-float")