Skip to content

Commit 08e4e65

Browse files
authored
Fix build with latest Swift toolchain snapshot (#157)
- Update .swift-version to main-snapshot-2026-01-09 - Add C standard library shim headers to CPlaydate to avoid ARM newlib module conflicts with _DarwinFoundation on macOS 16+ - Remove ARM toolchain/sysroot include paths from Package.swift since shims now provide the required declarations - Add newlib syscall stubs and posix_memalign to setup.c for the new toolchain's linker requirements - Move posix_memalign from Swift to C for proper linking - Add TARGET_PLAYDATE=1 to toolset_device.json for conditional compilation - Fix Xkpd CLodePNG/CQRCode build with minimal shim headers - Fix qrcode_getModule Bool return type usage in Comic.swift
1 parent 944734c commit 08e4e65

File tree

15 files changed

+123
-71
lines changed

15 files changed

+123
-71
lines changed

.github/workflows/Build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
matrix:
1313
os:
1414
- macos-15
15+
- macos-26
1516
- ubuntu-latest
1617
steps:
1718
- uses: actions/checkout@v4

.github/workflows/Examples.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
matrix:
1313
os:
1414
- macos-15
15+
- macos-26
1516
- ubuntu-latest
1617
steps:
1718
- uses: actions/checkout@v4
@@ -31,6 +32,7 @@ jobs:
3132
matrix:
3233
os:
3334
- macos-15
35+
- macos-26
3436
- ubuntu-latest
3537
steps:
3638
- uses: actions/checkout@v4
@@ -50,6 +52,7 @@ jobs:
5052
matrix:
5153
os:
5254
- macos-15
55+
- macos-26
5356
- ubuntu-latest
5457
steps:
5558
- uses: actions/checkout@v4
@@ -77,5 +80,5 @@ jobs:
7780
if: ${{ runner.os == 'macOS' }}
7881
uses: actions/upload-artifact@v4
7982
with:
80-
name: Xkpd
83+
name: Xkpd-${{ matrix.os }}
8184
path: Examples/Xkpd/.build/plugins/PDCPlugin/outputs/Xkpd.pdx

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
main-snapshot-2025-05-25
1+
main-snapshot-2026-01-09

Examples/FlappySwift/Package.resolved

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Pong/Package.resolved

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Xkpd/Package.resolved

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Xkpd/Package.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// swift-tools-version: 6.1
22

3-
import Foundation
43
import PackageDescription
54

65
/// Hack to force Xcode builds to not produce a dylib, since linking fails
@@ -14,16 +13,6 @@ let playdateSDKPath: String = if let path = Context.environment["PLAYDATE_SDK_PA
1413
"\(Context.environment["HOME"]!)/Developer/PlaydateSDK/"
1514
}
1615

17-
let armSysrootPath: String = if let path = Context.environment["ARM_NONE_EABI_SYSROOT_PATH"] {
18-
path
19-
} else {
20-
#if os(Linux)
21-
"/usr/lib/arm-none-eabi"
22-
#else
23-
"/usr/local/playdate/gcc-arm-none-eabi-9-2019-q4-major/arm-none-eabi"
24-
#endif
25-
}
26-
2716
let package = Package(
2817
name: "Xkpd",
2918
platforms: [.macOS(.v14)],
@@ -66,7 +55,6 @@ let package = Package(
6655
"-DLODEPNG_NO_COMPILE_DISK",
6756
"-DLODEPNG_NO_COMPILE_ALLOCATORS",
6857
"-DLODEPNG_NO_COMPILE_ANCILLARY_CHUNKS",
69-
"-I", "\(armSysrootPath)/include",
7058
])
7159
],
7260
),
@@ -78,7 +66,6 @@ let package = Package(
7866
cSettings: [
7967
.unsafeFlags([
8068
"-v",
81-
"-I", "\(armSysrootPath)/include",
8269
])
8370
]
8471
),

Examples/Xkpd/Sources/CLodePNG/include/string.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@
55

66
#include <stddef.h>
77

8+
void *memset(void *, int, size_t);
9+
void *memcpy(void *, const void *, size_t);
10+
void *memmove(void *, const void *, size_t);
11+
int memcmp(const void *, const void *, size_t);
12+
size_t strlen(const char *);
13+
int strcmp(const char *, const char *);
14+
815
#endif
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#ifdef TARGET_PLAYDATE
2-
extern void* pdrealloc(void* ptr, size_t size);
3-
void* lodepng_malloc(size_t size) { return pdrealloc(NULL, size); }
4-
void* lodepng_realloc(void* ptr, size_t size) { return pdrealloc(ptr, size); }
5-
void lodepng_free(void* ptr) { if(ptr) pdrealloc(ptr, 0); }
2+
#include <stddef.h>
3+
extern void* malloc(size_t);
4+
extern void* realloc(void*, size_t);
5+
extern void free(void*);
66
#else
77
#include <stdlib.h>
8-
void* lodepng_malloc(size_t size) { return malloc(size); }
9-
void* lodepng_realloc(void* ptr, size_t size) { return realloc(ptr, size); }
10-
void lodepng_free(void* ptr) { free(ptr); }
118
#endif
129

10+
void* lodepng_malloc(size_t size) { return malloc(size); }
11+
void* lodepng_realloc(void* ptr, size_t size) { return realloc(ptr, size); }
12+
void lodepng_free(void* ptr) { free(ptr); }
13+

Package.swift

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,6 @@
22

33
import PackageDescription
44

5-
let armToolchainPath: String = if let path = Context.environment["ARM_NONE_EABI_GCC_PATH"] {
6-
path
7-
} else {
8-
#if os(Linux)
9-
"/usr/lib/gcc/arm-none-eabi/10.3.1"
10-
#else
11-
"/usr/local/playdate/gcc-arm-none-eabi-9-2019-q4-major/lib/gcc/arm-none-eabi/9.2.1"
12-
#endif
13-
}
14-
15-
let armSysrootPath: String = if let path = Context.environment["ARM_NONE_EABI_SYSROOT_PATH"] {
16-
path
17-
} else {
18-
#if os(Linux)
19-
"/usr/lib/arm-none-eabi"
20-
#else
21-
"/usr/local/playdate/gcc-arm-none-eabi-9-2019-q4-major/arm-none-eabi"
22-
#endif
23-
}
24-
255
let playdateSDKPath: String = if let path = Context.environment["PLAYDATE_SDK_PATH"] {
266
path
277
} else {
@@ -50,9 +30,6 @@ let package = Package(
5030
"-Xfrontend", "-function-sections",
5131
"-Xfrontend", "-gline-tables-only",
5232
"-Xcc", "-DTARGET_EXTENSION",
53-
"-Xcc", "-I", "-Xcc", "\(armToolchainPath)/include",
54-
"-Xcc", "-I", "-Xcc", "\(armToolchainPath)/include-fixed",
55-
"-Xcc", "-I", "-Xcc", "\(armSysrootPath)/include",
5633
"-I", "\(playdateSDKPath)/C_API"
5734
]),
5835
]
@@ -70,9 +47,6 @@ let package = Package(
7047
"-Xfrontend", "-function-sections",
7148
"-Xfrontend", "-gline-tables-only",
7249
"-Xcc", "-DTARGET_EXTENSION",
73-
"-Xcc", "-I", "-Xcc", "\(armToolchainPath)/include",
74-
"-Xcc", "-I", "-Xcc", "\(armToolchainPath)/include-fixed",
75-
"-Xcc", "-I", "-Xcc", "\(armSysrootPath)/include",
7650
"-I", "\(playdateSDKPath)/C_API"
7751
]),
7852
]
@@ -82,9 +56,6 @@ let package = Package(
8256
cSettings: [
8357
.unsafeFlags([
8458
"-DTARGET_EXTENSION",
85-
"-I", "\(armToolchainPath)/include",
86-
"-I", "\(armToolchainPath)/include-fixed",
87-
"-I", "\(armSysrootPath)/include",
8859
"-I", "\(playdateSDKPath)/C_API"
8960
])
9061
]

0 commit comments

Comments
 (0)