Skip to content

Commit e9a1f98

Browse files
Add a note about unintended _main symbol generation. (#160)
* Add a note about unintended _main symbol generation. * Differentiate between main symbols by target
1 parent 511a3c8 commit e9a1f98

File tree

1 file changed

+2
-0
lines changed
  • Sources/EmbeddedSwift/Documentation.docc/UsingEmbeddedSwift

1 file changed

+2
-0
lines changed

Sources/EmbeddedSwift/Documentation.docc/UsingEmbeddedSwift/Basics.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ $ swiftc -target armv7-none-none-eabi -enable-experimental-feature Embedded -wmo
5252
input1.swift input2.swift ... -c -o output.o
5353
```
5454

55+
> Note: Passing only a single `.swift` file to swiftc results in the generation of a `_main` (Mach-O targets) or `main` (ELF) symbol. During linking, this symbol could potentially clash with other objects that also define one. To avoid this, compile multiple Swift files together or use the `-parse-as-library` flag.
56+
5557
Additionally, you probably want to specify additional Clang and/or LLVM flags to get the compiler to produce code for the exact ISA and ABI you need for your target.
5658

5759
For example, a Raspberry Pi Pico / Pico W should target the ARMv6-M architecture via the `armv6m-*` target triple, but the `-mfloat-abi=soft` Clang option should also be used, and if you want to match ABI with libraries built with the GNU toolchain, you might also need `-fshort-enums`. To pass those to Swift, use the `-Xcc` prefix:

0 commit comments

Comments
 (0)