Skip to content

Commit e740320

Browse files
committed
Fix build with latest Swift toolchain snapshot
- 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 edb42dd commit e740320

File tree

17 files changed

+175
-72
lines changed

17 files changed

+175
-72
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: 1 addition & 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
),
@@ -76,9 +64,9 @@ let package = Package(
7664
"QRCode",
7765
],
7866
cSettings: [
67+
.headerSearchPath("shims"),
7968
.unsafeFlags([
8069
"-v",
81-
"-I", "\(armSysrootPath)/include",
8270
])
8371
]
8472
),

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+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Minimal stdlib.h shim for bare-metal builds.
2+
3+
#ifndef _STDLIB_H
4+
#define _STDLIB_H
5+
6+
#include <stddef.h>
7+
8+
int abs(int);
9+
10+
#endif

0 commit comments

Comments
 (0)