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
@colemancda
colemancda / Float16.patch
Created May 21, 2022 04:23
swift-5.6.1-armv7
diff --git a/stdlib/public/runtime/Float16Support.cpp b/stdlib/public/runtime/Float16Support.cpp
index 817739d4cdf..b1896a4e364 100644
--- a/stdlib/public/runtime/Float16Support.cpp
+++ b/stdlib/public/runtime/Float16Support.cpp
@@ -29,7 +29,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__)) || \
+#if ((defined(__ANDROID__) || defined(__linux__)) && defined(__arm__)) || \
@colemancda
colemancda / arm-yield.patch
Created May 21, 2022 04:20
libdispatch-5.6.1-armv7
diff --git a/src/shims/yield.c b/src/shims/yield.c
index 43f0017..d0c5fff 100644
--- a/src/shims/yield.c
+++ b/src/shims/yield.c
@@ -36,7 +36,7 @@ void *
_dispatch_wait_for_enqueuer(void **ptr)
{
#if !DISPATCH_HW_CONFIG_UP
-#if defined(__arm__) || defined(__arm64__)
+#if (defined(__arm__) && defined(__APPLE__)) || defined(__arm64__)
@colemancda
colemancda / lichee-nano-fel.md
Created May 11, 2022 07:51 — forked from squeuei/lichee-nano-fel.md
How to enter FEL mode on Lichee nano

How to enter FEL mode on Lichee nano

If SPI flash isn't on the board, just remove the TF(microSD) card from the board and supply the power. It's the same if SPI flash is empty,

If your board have a SPI flash with preloaded image, pull D4(SPI CLK) down to GND. You can use the metal part of USB micro B or TF card slot as GND. Diagram is in the comment below. Thanks: @ernestp for the correction and providing a diagram.

Or you can use the special boot image [link]. Just write it to a TF card and boot.

Don't forget to remove the GND connection after entering FEL mode otherwise you will never be able to write the boot image to the SPI flash.

@colemancda
colemancda / mangopi-r3-swift-config
Created May 9, 2022 08:52
MangoPi-R3 Buildroot Config with Swift
#
# Automatically generated file; DO NOT EDIT.
# Buildroot 2022.02-1041-gc82deba6b2-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 / gh-pages.md
Created April 25, 2022 11:10 — forked from ramnathv/gh-pages.md
Creating a clean gh-pages branch

Creating a clean gh-pages branch

This is the sequence of steps to follow to create a root gh-pages branch. It is based on a question at [SO]

cd /path/to/repo-name
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
echo "My GitHub Page" &gt; index.html
@colemancda
colemancda / NetworkInterface.swift
Created April 23, 2022 20:32
Get all network devices on Linux
//
// NetworkInterface.swift
//
//
// Created by Alsey Coleman Miller on 7/5/18.
//
//
#if os(Linux)
import Glibc
@colemancda
colemancda / libdispatch-efficiency-tips.md
Created April 1, 2022 10:42 — forked from tclementdev/libdispatch-efficiency-tips.md
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

[coleman@mac-mini buildroot]$ make swift-reconfigure
rm -f /home/coleman/Developer/buildroot/output/build/swift-5.6/.stamp_installed
rm -f /home/coleman/Developer/buildroot/output/build/swift-5.6/.stamp_staging_installed
rm -f /home/coleman/Developer/buildroot/output/build/swift-5.6/.stamp_target_installed
rm -f /home/coleman/Developer/buildroot/output/build/swift-5.6/.stamp_images_installed
rm -f /home/coleman/Developer/buildroot/output/build/swift-5.6/.stamp_host_installed
rm -f /home/coleman/Developer/buildroot/output/build/swift-5.6/.stamp_built
rm -f /home/coleman/Developer/buildroot/output/build/swift-5.6/.stamp_configured
>>> swift 5.6 Configuring
# Clean
From 4c0b681da8088fb4c21a40a7e75776b11e1be28a Mon Sep 17 00:00:00 2001
From: Alsey Coleman Miller <[email protected]>
Date: Sun, 27 Mar 2022 22:49:31 -0700
Subject: [PATCH 1/1] package/swift: add Swift runtime libraries
Signed-off-by: Alsey Coleman Miller <[email protected]>
---
package/Config.in | 11 +
package/foundation/Config.in | 14 ++
package/foundation/foundation.hash | 1 +
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bc9b6790922..5c15bc7048b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -713,6 +713,8 @@ else()
set(SWIFT_HOST_VARIANT_ARCH_default "powerpc64le")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "s390x")
set(SWIFT_HOST_VARIANT_ARCH_default "s390x")
+ elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "armv5|armv5te")
+ set(SWIFT_HOST_VARIANT_ARCH_default "armv5")