Hello, thanks for the help!
I installed the main toolchain from Swift.org - Install Swift. swift --version reports the version as:
Apple Swift version 6.0-dev (LLVM 25f401da89fc02a, Swift dbe1a982d9252c9)
Target: arm64-apple-macosx14.0
Running the same command as before but with the new toolchain,
xcrun --toolchain swift \
swiftc \
-target armv7-unknown-none-eabi \
-enable-experimental-feature Embedded \
-wmo test.swift
Gives this error, which seems to imply that armv7-unknown-none-eabi isn't a valid target. Still, different error, thats progress.
<unknown>:0: error: could not find module 'Swift' for target 'armv7-unknown-none-eabi'; found: riscv32-none-none-eabi, armv4t-none-none-eabi, riscv64-none-none-eabi, i686-unknown-none-elf, armv7-apple-none-macho, armv6m-none-none-eabi, aarch64-none-none-elf, wasm64-unknown-none-wasm, arm64-apple-macos, i686-unknown-windows-msvc, x86_64-unknown-none-elf, x86_64-unknown-windows-msvc, arm64-apple-none-macho, armv7-none-none-eabi, armv7em-none-none-eabi, arm64e-apple-macos, x86_64-apple-macos, armv6-apple-none-macho, armv6m-apple-none-macho, wasm32-unknown-none-wasm, armv7em-apple-none-macho, armv6-none-none-eabi, at: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-07-a.xctoolchain/usr/lib/swift/embedded/Swift.swiftmodule
Since armv7-unknown-none-eabi seems similar enough to armv7-none-none-eabi (one of the valid options according to the error), I replaced them:
xcrun --toolchain swift \
swiftc -target armv7-none-none-eabi \
-enable-experimental-feature Embedded \
-wmo test.swift
And now, it seems to be failing at the linking stage, missing a few libraries and a builtin runtime?
error: link command failed with exit code 1 (use -v to see invocation)
ld.lld: error: unable to find library -lc
ld.lld: error: unable to find library -lm
ld.lld: error: unable to find library -lclang_rt.builtins-armv7
clang: error: ld.lld command failed with exit code 1 (use -v to see invocation)
How should I go about fixing this? A quick search for the first error gave me this reddit post: Reddit - Dive into anything which says that i can manually link some library, but I'm not exactly sure what to link.